[Geoserver-users] mixing Point and Polygon - SLD problem or my datastore problem?

Hi All,

I have a custom datastore that provides me with Polygons with a count at
global levels, so I style it with scaled colours depending on the count -
e.g. higher density the darker the colour. When you zoom in, it swaps
over to Point data.

I had the SLD working ok for the polygons, and then added a rule for when
the count is null (the datastore does this when it is a point type -sets
the count to null) to do a point rendering.

What happened was the point was rendered both by the polygon rule for
count<10 and also as a point, and the global layers were not rendered at
all as polygons.

Is it possible for a datastore to return an abstract parent type
(Geometry) that changes on zoom level - polygon or point. Or does it
require a concrete schema?

Is it possible for SLD to govern the rendering of a single FeatureYype as
either a point or a polygon?

Thanks for any help,

Tim

Hi Tim,

You should be able to declare the type of your geometry to be just
Geometry, and not have to declare polygon or point. Someone with the
renderer can confirm but I know that often a postgis geometry column
just has the type 'GEOMETRY' and there are no problems. And then it
should just be a matter of separating out the appropriate symbolizers
into scale dependent rules.

-Justin

trobertson@anonymised.com wrote:

Hi All,

I have a custom datastore that provides me with Polygons with a count at
global levels, so I style it with scaled colours depending on the count -
e.g. higher density the darker the colour. When you zoom in, it swaps
over to Point data.

I had the SLD working ok for the polygons, and then added a rule for when
the count is null (the datastore does this when it is a point type -sets
the count to null) to do a point rendering.

What happened was the point was rendered both by the polygon rule for
count<10 and also as a point, and the global layers were not rendered at
all as polygons.

Is it possible for a datastore to return an abstract parent type
(Geometry) that changes on zoom level - polygon or point. Or does it
require a concrete schema?

Is it possible for SLD to govern the rendering of a single FeatureYype as
either a point or a polygon?

Thanks for any help,

Tim

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

!DSPAM:4007,46e44d10190421137850744!

--
Justin Deoliveira
The Open Planning Project
http://topp.openplans.org

Hi

I've run into a similar problem using Oracle Spatial with SDO_GEOMETRY holding points, lines and polygons.
The SLD spec says that all symbolisers are applied to the geometry.
This leads to some undesired visual effects when used with stores using base geometries: lines gets filled etc.
The workaround for this in my case was to include a type column (oracle geometrty type) into the table holding the geometry.

Using this integer value, I created rules with filters matchning desired geometry types.

example:

<Rule>
   <Name>Lines</Name>
      <MaxScaleDenominator>25000</MaxScaleDenominator>
      <ogc:Filter>
         <ogc:PropertyIsEqualTo>
             <ogc:PropertyName>GTYPE</ogc:PropertyName>
             <ogc:Literal>2</ogc:Literal>
         </ogc:PropertyIsEqualTo>
      </ogc:Filter>
      <LineSymbolizer>
          ....
      </LineSymbolizer>
</Rule>
<Rule>
   <Name>Points</Name>
      <MaxScaleDenominator>25000</MaxScaleDenominator>
      <ogc:Filter>
         <ogc:PropertyIsEqualTo>
             <ogc:PropertyName>GTYPE</ogc:PropertyName>
             <ogc:Literal>1</ogc:Literal>
         </ogc:PropertyIsEqualTo>
      </ogc:Filter>
      <PointSymbolizer>
          ....
      </PointSymbolizer>
</Rule>

By using <ogc:And> to pair up a geometry type constraint and some other (count >0) constraint, you should be able to render them separatly

regards
Per-Olof

trobertson@anonymised.com skrev:

Hi All,

I have a custom datastore that provides me with Polygons with a count at
global levels, so I style it with scaled colours depending on the count -
e.g. higher density the darker the colour. When you zoom in, it swaps
over to Point data.

I had the SLD working ok for the polygons, and then added a rule for when
the count is null (the datastore does this when it is a point type -sets
the count to null) to do a point rendering.

What happened was the point was rendered both by the polygon rule for
count<10 and also as a point, and the global layers were not rendered at
all as polygons.

Is it possible for a datastore to return an abstract parent type
(Geometry) that changes on zoom level - polygon or point. Or does it
require a concrete schema?

Is it possible for SLD to govern the rendering of a single FeatureYype as
either a point or a polygon?

Thanks for any help,

Tim

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users
  

trobertson@anonymised.com ha scritto:

Hi All,

I have a custom datastore that provides me with Polygons with a count at
global levels, so I style it with scaled colours depending on the count -
e.g. higher density the darker the colour. When you zoom in, it swaps
over to Point data.

I had the SLD working ok for the polygons, and then added a rule for when
the count is null (the datastore does this when it is a point type -sets
the count to null) to do a point rendering.

What happened was the point was rendered both by the polygon rule for
count<10 and also as a point, and the global layers were not rendered at
all as polygons.

Is it possible for a datastore to return an abstract parent type
(Geometry) that changes on zoom level - polygon or point. Or does it
require a concrete schema?

Is it possible for SLD to govern the rendering of a single FeatureYype as
either a point or a polygon?

Yes it is, should work fine. Can we have a look at the sld?
Cheers
Andrea

Hi to all

Thank you for the replies that I have had so far.

My SLD is at the bottom of this response.

My FeatureReader always returns an Integer in the count when it returns a
POLYGON, and always NULL - not the string "null" - when it returns a POINT.

Note that I use the &styles=densityLayer in the request

If I take out the second rule then the polygons all render correctly.

I have also tried using 0 for the count when it is a point and get the same
result.

Thanks for all your time and help

Tim

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor version="1.0.0"
  xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd"
  xmlns="http://www.opengis.net/sld&quot; xmlns:ogc="http://www.opengis.net/ogc&quot;
  xmlns:xlink="http://www.w3.org/1999/xlink&quot;
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot;&gt;
<NamedLayer>
  <Name>densityLayer</Name>
    <UserStyle>
        <FeatureTypeStyle>
            <FeatureTypeName>gbifDensityLayer</FeatureTypeName>
              <!-- If the count is greater than 1, then fill it as a
polygon -->
        <Rule>
          <ogc:Filter>
  
<ogc:PropertyIsGreaterThanOrEqualTo>
  
<ogc:PropertyName>count</ogc:PropertyName>
            <ogc:Literal>1</ogc:Literal>
  
</ogc:PropertyIsGreaterThanOrEqualTo>
          </ogc:Filter>
          <PolygonSymbolizer>
          <Fill>
            <CssParameter name="fill">
  
<ogc:Literal>#009900</ogc:Literal>
            </CssParameter>
            <CssParameter name="fill-opacity">
  
<ogc:Literal>0.9</ogc:Literal>
            </CssParameter>
          </Fill>
          </PolygonSymbolizer>
        </Rule>

        <!-- If the count is null, then it is a
point -->
        <Rule>
          <ogc:Filter>
          <ogc:PropertyIsNull>
  
<ogc:PropertyName>count</ogc:PropertyName>
          </ogc:PropertyIsNull>
          </ogc:Filter>
        <PointSymbolizer>
          <Graphic>
            <Mark>
  
<WellKnownName>circle</WellKnownName>
              <Fill>
  
<CssParameter name="fill">#ff0000</CssParameter>
  
<CssParameter name="fill-opacity">1.0</CssParameter>
              </Fill>
            </Mark>
            <Size>6</Size>
          </Graphic>
        </PointSymbolizer>
        </Rule>
        </FeatureTypeStyle>
    </UserStyle>
    </NamedLayer>
</StyledLayerDescriptor>

-----Original Message-----
From: Andrea Aime [mailto:aaime@anonymised.com]
Sent: Monday, September 10, 2007 9:58 AM
To: trobertson@anonymised.com
Cc: geoserver users
Subject: Re: [Geoserver-users] mixing Point and Polygon - SLD problem or my
datastore problem?

trobertson@anonymised.com ha scritto:

Hi All,

I have a custom datastore that provides me with Polygons with a count at
global levels, so I style it with scaled colours depending on the count -
e.g. higher density the darker the colour. When you zoom in, it swaps
over to Point data.

I had the SLD working ok for the polygons, and then added a rule for when
the count is null (the datastore does this when it is a point type -sets
the count to null) to do a point rendering.

What happened was the point was rendered both by the polygon rule for
count<10 and also as a point, and the global layers were not rendered at
all as polygons.

Is it possible for a datastore to return an abstract parent type
(Geometry) that changes on zoom level - polygon or point. Or does it
require a concrete schema?

Is it possible for SLD to govern the rendering of a single FeatureYype as
either a point or a polygon?

Yes it is, should work fine. Can we have a look at the sld?
Cheers
Andrea

Per-Olof Norén ha scritto:

Hi

I've run into a similar problem using Oracle Spatial with SDO_GEOMETRY holding points, lines and polygons.
The SLD spec says that all symbolisers are applied to the geometry.
This leads to some undesired visual effects when used with stores using base geometries: lines gets filled etc.
The workaround for this in my case was to include a type column (oracle geometrty type) into the table holding the geometry.

I'd just want to point out the availability of a function allowing to
filter on the geometry type without needing to create a column on the db:

<ogc:PropertyIsEqualTo>
   <ogc:Function name="geometryType">
     <ogc:PropertyName>myGeom</ogc:PropertyName>
   </ogc:Function>
   <ogc:Literal>Multipolygon</ogc:Literal>
</ogc:PropertyIsEqualTo>

The only drawback of this one is that this filter won't be encoded
in SQL, so it can't be efficiently used to reduce the number of
records loaded from the db, but it's ok if you have to load
all of the geometries anyways and just want to apply different
symbolizers to them.

Cheers
Andrea

Tim Robertson ha scritto:

Hi to all

Thank you for the replies that I have had so far.

My SLD is at the bottom of this response.

My FeatureReader always returns an Integer in the count when it returns a
POLYGON, and always NULL - not the string "null" - when it returns a POINT.

Note that I use the &styles=densityLayer in the request

If I take out the second rule then the polygons all render correctly.

I have also tried using 0 for the count when it is a point and get the same
result.

Thanks for all your time and help

Hum, something is going on with your datastore maybe?
I just tried a slightly modified version of the filter against topp:states and I only get the green fill, the second symbolizer
is never applied (and it should not, since "persons" attribute is
never null).

So, I'm not really sure what's going on. Maybe you can try the filter
against a straigh postgis or mysql table with null values and see if
it works fine, if it does, then the issue must be looked into the
way your datastore applies the filters.

Cheers
Andrea

Thanks Andrea

That also helps me massively as I would ideally like to use the count to
also indicate multiple occurrences at a single point

-----Original Message-----
From: Andrea Aime [mailto:aaime@anonymised.com]
Sent: Monday, September 10, 2007 11:19 AM
To: Per-Olof Norén
Cc: trobertson@anonymised.com; geoserver users
Subject: Re: [Geoserver-users] mixing Point and Polygon - SLD problem or my
datastore problem?

Per-Olof Norén ha scritto:

Hi

I've run into a similar problem using Oracle Spatial with SDO_GEOMETRY
holding points, lines and polygons.
The SLD spec says that all symbolisers are applied to the geometry.
This leads to some undesired visual effects when used with stores using
base geometries: lines gets filled etc.
The workaround for this in my case was to include a type column (oracle
geometrty type) into the table holding the geometry.

I'd just want to point out the availability of a function allowing to
filter on the geometry type without needing to create a column on the db:

<ogc:PropertyIsEqualTo>
   <ogc:Function name="geometryType">
     <ogc:PropertyName>myGeom</ogc:PropertyName>
   </ogc:Function>
   <ogc:Literal>Multipolygon</ogc:Literal>
</ogc:PropertyIsEqualTo>

The only drawback of this one is that this filter won't be encoded
in SQL, so it can't be efficiently used to reduce the number of
records loaded from the db, but it's ok if you have to load
all of the geometries anyways and just want to apply different
symbolizers to them.

Cheers
Andrea

Hi Andrea

Hmmm... I'm not convinced this is a datastore problem.

If I have only the polygon rendering rule in the SLD, the global zoom level
(e.g. Datastore returns polygon) renders correctly, the zoomed in layer
(e.g. POINT data from datastore) is empty. And vice versa.

So independently, they both work, making me think that the Datastore is
working correctly.

But when I add the rules together... My logs say the DS is returning the
same data, but the result is unusual. The point data is rendering, but the
polygons are not being rendered in some cases, and sometimes rendered
incorrectly (the colors are correct suggesting it is half picking up the
rule).

I'll keep digging

Tim

-----Original Message-----
From: Andrea Aime [mailto:aaime@anonymised.com]
Sent: Monday, September 10, 2007 11:29 AM
To: Tim Robertson
Cc: 'geoserver users'
Subject: Re: [Geoserver-users] mixing Point and Polygon - SLD problem or my
datastore problem?

Tim Robertson ha scritto:

Hi to all

Thank you for the replies that I have had so far.

My SLD is at the bottom of this response.

My FeatureReader always returns an Integer in the count when it returns a
POLYGON, and always NULL - not the string "null" - when it returns a

POINT.

Note that I use the &styles=densityLayer in the request

If I take out the second rule then the polygons all render correctly.

I have also tried using 0 for the count when it is a point and get the

same

result.

Thanks for all your time and help

Hum, something is going on with your datastore maybe?
I just tried a slightly modified version of the filter against
topp:states and I only get the green fill, the second symbolizer
is never applied (and it should not, since "persons" attribute is
never null).

So, I'm not really sure what's going on. Maybe you can try the filter
against a straigh postgis or mysql table with null values and see if
it works fine, if it does, then the issue must be looked into the
way your datastore applies the filters.

Cheers
Andrea

Hi all,

I am trying to use 2 rules in SLD and having difficulty.
Is the literal value here correct? It is case sensitive right?

They don't work as they stand :o(

Thanks

<ogc:Filter>
  <ogc:PropertyIsEqualTo>
    <ogc:Function name="geometryType">
      <ogc:PropertyName>geom</ogc:PropertyName>
    </ogc:Function>
    <ogc:Literal>POINT</ogc:Literal>
  </ogc:PropertyIsEqualTo>
</ogc:Filter>

...

  <ogc:Filter>
  <ogc:PropertyIsEqualTo>
     <ogc:Function name="geometryType">
     <ogc:PropertyName>geom</ogc:PropertyName>
     </ogc:Function>
     <ogc:Literal>POLYGON</ogc:Literal>
  </ogc:PropertyIsEqualTo>
  </ogc:Filter>

Ok - they are meant to be Polygon and Point

But it doesn't work when you combine 2 rules with a filter to inspect the
type returned from the data store

Thanks

Tim

-----Original Message-----
From: geoserver-users-bounces@lists.sourceforge.net
[mailto:geoserver-users-bounces@lists.sourceforge.net] On Behalf Of Tim
Robertson
Sent: Monday, September 10, 2007 1:26 PM
To: 'geoserver users'
Subject: [Geoserver-users] Filters in SLD

Hi all,

I am trying to use 2 rules in SLD and having difficulty.
Is the literal value here correct? It is case sensitive right?

They don't work as they stand :o(

Thanks

<ogc:Filter>
  <ogc:PropertyIsEqualTo>
    <ogc:Function name="geometryType">
      <ogc:PropertyName>geom</ogc:PropertyName>
    </ogc:Function>
    <ogc:Literal>POINT</ogc:Literal>
  </ogc:PropertyIsEqualTo>
</ogc:Filter>

...

  <ogc:Filter>
  <ogc:PropertyIsEqualTo>
     <ogc:Function name="geometryType">
     <ogc:PropertyName>geom</ogc:PropertyName>
     </ogc:Function>
     <ogc:Literal>POLYGON</ogc:Literal>
  </ogc:PropertyIsEqualTo>
  </ogc:Filter>

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Ok...

I think I am getting to the bottom of the problem...

The URL I am calling is:
http://localhost:8080/geoserver/wms?bbox=-180,-90,180,90&styles=densityLayer
&Format=image/png&request=GetMap&layers=gbif:gbifDensityLayer&width=550&heig
ht=250&srs=EPSG:4326&bgcolor=0x000000

Note the BBox is global.

The SLD is posted at the end of this message

When I only have 1 SLD rule defined in URL, the datastore receives the
following Filter:

[[ geom bbox POLYGON ((-180 -90, -180 90, 180 90, 180 -90, -180 -90)) ] AND
[ geometryType([geom]) = Polygon ]]

This seems fine and it works perfectly.

Then when I have both rules active (see SLD at end), the filter is passed
through to the datastore:

[[ geom bbox POLYGON ((-183.92727272727274 -94.32, -183.92727272727274
94.32, 183.92727272727274 94.32, 183.92727272727274 -94.32,
-183.92727272727274 -94.32)) ] AND
[[ geometryType([geom]) = Polygon ] OR [ geometryType([geom]) = Point ]]]

My datastore is barfing at this...

Feature or bug?

Thanks Tim

And now the SLD:

<Rule>
  <ogc:Filter>
  <ogc:PropertyIsEqualTo>
     <ogc:Function name="geometryType">
     <ogc:PropertyName>geom</ogc:PropertyName>
     </ogc:Function>
     <ogc:Literal>Polygon</ogc:Literal>
  </ogc:PropertyIsEqualTo>
  </ogc:Filter>
  <PolygonSymbolizer>
    <Fill>
      <CssParameter name="fill">
        <ogc:Literal>#0000ff</ogc:Literal>
      </CssParameter>
      <CssParameter name="fill-opacity">
        <ogc:Literal>0.9</ogc:Literal>
      </CssParameter>
    </Fill>
  </PolygonSymbolizer>
</Rule>
        
<Rule>
  <ogc:Filter>
    <ogc:PropertyIsEqualTo>
      <ogc:Function name="geometryType">
        <ogc:PropertyName>geom</ogc:PropertyName>
      </ogc:Function>
      <ogc:Literal>Point</ogc:Literal>
    </ogc:PropertyIsEqualTo>
  </ogc:Filter>
  <PointSymbolizer>
    <Graphic>
      <Mark>
        <WellKnownName>circle</WellKnownName>
        <Fill>
          <CssParameter
name="fill">#00ff00</CssParameter>
          <CssParameter
name="fill-opacity">1.0</CssParameter>
        </Fill>
      </Mark>
      <Size>6</Size>
    </Graphic>
  </PointSymbolizer>
</Rule>

-----Original Message-----
From: geoserver-users-bounces@lists.sourceforge.net
[mailto:geoserver-users-bounces@lists.sourceforge.net] On Behalf Of Tim
Robertson
Sent: Monday, September 10, 2007 1:26 PM
To: 'geoserver users'
Subject: [Geoserver-users] Filters in SLD

Hi all,

I am trying to use 2 rules in SLD and having difficulty.
Is the literal value here correct? It is case sensitive right?

They don't work as they stand :o(

Thanks

<ogc:Filter>
  <ogc:PropertyIsEqualTo>
    <ogc:Function name="geometryType">
      <ogc:PropertyName>geom</ogc:PropertyName>
    </ogc:Function>
    <ogc:Literal>POINT</ogc:Literal>
  </ogc:PropertyIsEqualTo>
</ogc:Filter>

...

  <ogc:Filter>
  <ogc:PropertyIsEqualTo>
     <ogc:Function name="geometryType">
     <ogc:PropertyName>geom</ogc:PropertyName>
     </ogc:Function>
     <ogc:Literal>POLYGON</ogc:Literal>
  </ogc:PropertyIsEqualTo>
  </ogc:Filter>

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Tim Robertson ha scritto:

Hi all,

I am trying to use 2 rules in SLD and having difficulty.
Is the literal value here correct? It is case sensitive right?

They don't work as they stand :o(

Point and Polygon, not uppercase. They are the class
names of the JTS objecs holding the geometries, so
Point, MultiPoint, LineString, MultiLineString, LineRing,
Polygon, MultiPolygon, GeometryCollection.

Sigh, it is really unfortunate we have no documentation of
the functions.... I have go and look at the source code
myself to see what a function does.... Any good soul willing
to take this effort and prepare some docs?

Hope this helps
Cheers
Andrea