1

I’m trying to style a geometry collection column (PostGIS) that stores both polygons and points in each record.

I already read the geoserver manual on how to style mixed geometry types and I don’t think this is possible when you have mixed geometry types in the same record.

I’m using geoserver 2.12.0.

Can anyone please help?

1

3 Answers 3

1

Depending on the structure of your collections it might be possible to pull out the individual geometries using the getGeometryN function which returns the Nth geometry of a collection.

In general, I would avoid storing mixed geometry collections in favour of multiple geometry columns. Maybe a materialised view would help?

1

If you cannot code in Java I'm afraid there are no solutions, unless the multi-geometry structure is regular, for example, if there are always 3 sub-geometries, then you can use getGeometryN and test its type in 3 different rules, summing up to 9 separate rules (one with a filter testing point for geometry 1, one for testing line for geometry 1, and so on).

If you can code in Java, then you could easily write a filter function that returns a multi-X geometry of the chosen type, e.g., given a geometry collection return a multipoint (the subset of points in the original collection), or a multiline, or a multipolygon. Then you can have only 3 rules working against geometry collections of whatever size, and styling the specific geometry subset accordingly.

See this tutorial on how to write functions: https://docs.geotools.org/latest/userguide/tutorial/function.html

0

Thank you all. In the end, I adopted one of the solutions provided in the geoserver guide "Styling mixed geometry types". I've created extra geometry columns, each for each type.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.