Opened 6 years ago

Closed 3 years ago

Last modified 3 years ago

#4149 closed enhancement (fixed)

MVT: Be able to tweak simplification in St_AsMVTGeom

Reported by: Algunenano Owned by: Algunenano
Priority: medium Milestone: PostGIS 3.2.0
Component: postgis Version: master
Keywords: Cc:

Description

In some situations you want a big extent (e.g. 4096) to represent the geometries in a MVT with precision for the current zoom and, until the request arrives, to temporarily render the next zoom level too, but you don't want the big tile size that having the geometry ready for 4 zoom levels implies since you aren't skipping zoom levels (a.k.a. overzooming).

For those cases it's interesting to have the possibility of simplifying the geometry for a zoom level but keep the main extent to a higher precision. For example, if you use a 4096 extent for the layer and 512 for simplification, any points falling inside the same 512 grid can be considered duplicated, but the final points keep the 4096 precision.

For these use cases what I'm currently doing is simplifying (ST_Simplify(ST_RemoveRepeatedPoints(${geomColumn}, ${tol}), ${tol}, true)) the geometry before entering St_AsMVTGeom. This works but it means that there are 2 simplification processes going on, the external and the (now unnecessary) internal.

I see 2 valid options to handle this:

  • Add the simplify_extent option to St_AsMVTGeom so the simplification process and the final snapping can be detached. This would probably be the option with the best performance.
  • Add the option of disabling the simplification process in St_AsMVTGeom and keep only the external simplification. This is the most future safe option: if you can disable simplification and add you own, you are able not only to change tolerance levels but also change simplification functions (ST_SimplifyPreserveTopology instead of St_Simplify for example).

There is also the option of adding some kind of hook to the St_AsMVTGeom to set the simplification functions on the fly, but I feel that that's just too much complexity.

Change History (11)

comment:1 by Algunenano, 6 years ago

I want to add something extra here, which is that now with wagyu depending on the size of the polygon and tolerance used, simplifying the geometries might be slower that not doing it, so the solution could end up being removing the simplification completely. Needs further performance testing.

comment:2 by komzpa, 6 years ago

I would ask to remove the simplification. Current one breaks overzoom: https://matrix.org/_matrix/media/v1/download/matrix.org/CtmGOQsiGuKmeHUvnwhYSZNF

comment:3 by komzpa, 5 years ago

After giving it some thought: it may be feasible to leave the internal simplification with threshold of 0. This way it will remove points that happen to be really colinear after grid snapping, but not introduce any change into their topological relation compared to what it was before grid snapping.

comment:5 by pramsey, 5 years ago

Resolution: wontfix
Status: assignedclosed

Based on review in PR, closing this out.

comment:6 by Darafei Praliaskouski <me@…>, 5 years ago

In bb78dff8/git:

ST_Simplify: O(N) simplification for tolerance=0

References #4149

comment:7 by komzpa, 5 years ago

Resolution: wontfix
Status: closedreopened

comment:8 by komzpa, 5 years ago

Milestone: PostGIS 3.0.0PostGIS 3.1.0

comment:9 by pramsey, 4 years ago

Milestone: PostGIS 3.1.0PostGIS Fund Me

comment:10 by Darafei Praliaskouski <me@…>, 3 years ago

Resolution: fixed
Status: reopenedclosed

In 0c09010/git:

Zero tolerance simplification in MVT export.

Closes #4149
Closes https://github.com/postgis/postgis/pull/463

comment:11 by robe, 3 years ago

Milestone: PostGIS Fund MePostGIS 3.2.0
Note: See TracTickets for help on using tickets.