Friday 29 November 2019

sld - Mixed geometry types styling with GeoServer 2.2


I have a PostGIS table with geometry column. In this column I have geometries of several types (polygons, points, lines). I publish this this table on GeoServer.


Now I want to create OpenLayers layer with this data. But how to make a style for this data?


I've already read http://docs.geoserver.org/stable/en/user/styling/sld-tipstricks/mixed-geometries.html and don't want to create gtype in PostGIS if this possible.


I try to create new style within GeoServer but I think that do something wrong:



xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd"
xmlns="http://www.opengis.net/sld"
xmlns:ogc="http://www.opengis.net/ogc"

xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">




the_geom

Polygon




#0000ff
1





And get a error:



line 10: cvc-complex-type.2.4.a: Invalid content was found starting with element 'Rule'. One of '{"http://www.opengis.net/sld":Name, "http://www.opengis.net/sld":Title, "http://www.opengis.net/sld":Abstract, "http://www.opengis.net/sld":NamedLayer, "http://www.opengis.net/sld":UserLayer}' is expected.
line 11: cvc-complex-type.2.4.a: Invalid content was found starting with element 'ogc:PropertyIsEqualTo'. One of '{"http://www.opengis.net/sld":Name, "http://www.opengis.net/sld":Title, "http://www.opengis.net/sld":Abstract, "http://www.opengis.net/sld":LegendGraphic, "http://www.opengis.net/ogc":Filter, "http://www.opengis.net/sld":ElseFilter, "http://www.opengis.net/sld":MinScaleDenominator, "http://www.opengis.net/sld":MaxScaleDenominator, "http://www.opengis.net/sld":Symbolizer}' is expected.

What am I doing wrong?


UPDATE


I try to show a points and make this rule for this geom type:


 




the_geom

Point




#0000ff
2





But not see then on my map. What's wrong?



Answer



The first validation error is because you are missing Name, Title, Abstract, NamedLayer and UserLayer elements in your SLD. The second validation error refers to the missing filter element inside your Rule element. So if you add the filter element and the standard elements in the sld elemet your SLD should validate fine. Finally our SLD should look like this:



xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd">












the_geom

Polygon




#0000ff
1









If you want to style other geometrytypes - just create a new rule with the symbolizer and geometrytype filter you want to style.


UPDATE


Your point rule should have a PointSymbolizer element instead of the PolygonSymbolizer. So your point rule look like this:



 



the_geom

Point






circle

#0000ff
2


6





See more on how to style points in the GeoServer SLD Cookbook


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...