#1698 closed task (fixed)
Review polygon collapse policy in ST_Simplify
Reported by: | strk | Owned by: | strk |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS 2.0.0 |
Component: | postgis | Version: | master |
Keywords: | Cc: |
Description
Current ST_Simplify transforms collapsed polygons into EMPTY polygons, but that's not necessarely a good idea. The goal being generalizing features, _dropping_ the whole location information from them isn't really useful.
This is really depended on use case so we may define policy parameters. A planar subdivision ends up having "holes" if we drop small components. But a central big body with a lot of satellite islands would not get simplified much if we keep all islands.
Attachments (4)
Change History (12)
comment:1 by , 13 years ago
comment:2 by , 13 years ago
An example of the above:
$ select st_asewkt(st_simplify('GEOMETRYCOLLECTION(MULTIPOLYGON(((0 0, 1 0, 1 1, 0 1, 0 0)),((20 0, 20 20, 40 20, 40 0, 20 0))),POINT(10 10))', 2)); GEOMETRYCOLLECTION(MULTIPOLYGON( EMPTY,((20 0,20 20,40 20,40 0,20 0))),POINT(10 10))
By the way, the parser is unable to understand the WKT version of the above. See #1703.
comment:3 by , 13 years ago
Milestone: | PostGIS 2.0.1 → PostGIS 2.0.0 |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:4 by , 13 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
With r9527 r9528 r9529 this is now retaining collapsed shells (but not holes) and keeping at least 3 vertexes when possible for polygons (thus collapsing a most to line but not to point).
I'm pretty satisfied with the results so far. Would be nice to have a user-defined policy but won't do for 2.0.0 for sure.
comment:5 by , 13 years ago
Why retain 3-point rings? They are by nature self-intersecting and invalid. Drop them too!
comment:6 by , 13 years ago
Ok, the whole point of ST_Simplify was (as originally developed) to reduce vectors for sending to clients for rendering. True, a 3-points ring is invalid as is the single-point one.
But they can still have an use ! For example you can _see_ something rendered (modulo rendering limitations as in mapnik/AGG case: https://github.com/mapnik/mapnik/issues/1140) and you know _where_ the feature is located (if you want to zoom to it, which may send more vectors, less simplified, etc).
The other thing is that you can always strip non-valids later. We know we may be introducing non-valids so why having 1-class invalids that we drop lightly and 2-class invalids which we don't drop (complex self-intersections).
I've to say that I'm tempted to revert this to really keep a single vertex rather than 3 vertices, but knowing that AGG won't render them makes me belive we're doing a better service returning at least 3 points than 1. For all AGG users (mapserver,mapnik,what else?).
I'm attaching 2 images of mapnik rendering a set of ~8k simplified polygons representing italian municipalities. The version you don't see much is the one with 1-vertex polygons, the other is with 3-vertex polygons. You can see you can recognize the country by only the collapsed versions of polygons rendered.
comment:7 by , 13 years ago
Sorry but the polygon boundaries are rendered in white, so you'll need a good reader to see them (it's white on transparent). Se the difference between before and after the patch is between knowing the shape and extent of italy and not knowing it.
Forget style-snap-simpNCD.png which is not directly related.
I've also verified that ST_Simplify may return collapsed components of collections as EMPTY. This means creating collection with some empty and some non-empty elements, which is suboptimal and surely NOT simplified form…. see also #1700 as a consequence of this on further operations.