PostGIS GeoServer – Styling Layers with Multiple Geometries

draw ordergeometrygeoserverpostgiswms

I've build a table with multiple geometries in PostGIS. This table is published in GeoServer. Now I'm wondering how GeoServer handles this type of layer. specifically the drawing part.

My layer contains all three geometries, points, lines and polygons. In the ideal situation polygons are drawn first, lines second and point third. To prevent polygons overlapping the other geometry types.

The generated WMS looks rather good, all point and lines are visible. My question is: 'Does Geoserver draw objects according to its geometry, in a specific order?'

Best Answer

GeoServer draws things as defined by their rule order and then in feature order with each symbolizer (roughly the order they are in the table in your case).

The tricky thing is that when dealing with mixed geometries SLD will do funny things (and CSS and YSLD are just SLD in the end). Basically if you have the symbolizer you have specified will be applied to all of the geometries and they will be coerced in to the expected geometry type. So, for example, a point symbolizer will use the centroid of a line or polygon, while a polygon symbolizer will connect the ends of a linestring to make a polygon.

The best (and easiest plan) is to separate features out by geometry type into different tables. The next easiest plan is to use a geometryType filter to determine which symbolizer to apply.

While your map may currently look good what happens if the next feature you add is a large polygon the covers everything else.