Opened 5 years ago

Closed 5 years ago

#4556 closed defect (fixed)

st_asmvtgeom sometimes produces leaking polygons (wagyu)

Reported by: anneb Owned by: pramsey
Priority: medium Milestone: PostGIS 3.0.1
Component: postgis Version: master
Keywords: Cc:

Description

st_AsMVTgeom in postgis 3.0 built with wagyu 0.43 sometimes produces leaking polygons.

if a polygon is the surface of a circular road, the output polygon of st_asmvtgeom sometimes changes to a filled circle at lower (zoomed-out) zoom levels.

I am attaching an example. Unfortunately I did not yet succeed to reduce the problem to a small data example.

Attachments (3)

asmvtgeom_leak.sql (709.3 KB ) - added by anneb 5 years ago.
mvt_default.png (40.9 KB ) - added by Algunenano 5 years ago.
mvt_nosimplification.png (52.1 KB ) - added by Algunenano 5 years ago.

Download all attachments as: .zip

Change History (8)

by anneb, 5 years ago

Attachment: asmvtgeom_leak.sql added

by Algunenano, 5 years ago

Attachment: mvt_default.png added

by Algunenano, 5 years ago

Attachment: mvt_nosimplification.png added

comment:1 by Algunenano, 5 years ago

It seems this happens because the polygon becomes invalid after the calls to simplify it:

	/* Remove all non-essential points (under the output resolution) */
	lwgeom_remove_repeated_points_in_place(lwgeom, res);
	lwgeom_simplify_in_place(lwgeom, res, preserve_collapsed);

Before doing anything the polygon is valid, and if I remove these lines the output is correct (see mvt_default.png vs mvt_nosimplification.png).

Maybe it's time to revisit https://trac.osgeo.org/postgis/ticket/4149 and maybe remove the simplification step for wagyu at least.

comment:2 by anneb, 5 years ago

I believe just commenting out line:

lwgeom_simplify_in_place(lwgeom, res, preserve_collapsed);

is enough to solve the problem.

After rebuilding, I tried this and several previous problematic polygons and they are now all output correctly.

Commenting out only line

lwgeom_remove_repeated_points_in_place

does not solve the polygon-leak problem.

comment:3 by Algunenano, 5 years ago

I believe just commenting out line: lwgeom_simplify_in_place(lwgeom, res, preserve_collapsed); is enough to solve the problem.

Thanks.

We rely on this step for 2 things:

  • Remove unnecessary points in some scenarios (for example if you have a straight horizontal line (0 0, 0 1, 0 4, 0 10) it'd be transformed into (0 0, 0 10)).
  • For big lines / polygons there are some cases where it's faster to simplify the polygon first before doing the transformation, because the amount of point removed is important. This was true almost always with the GEOS backend, but it isn't anymore.

The ideal situation would be to not need these calls (simplify, removeRepeatedPoints) at all but I'd need to look into it in more detail and see if we can keep the same performance and behaviour without them.

comment:4 by Algunenano, 5 years ago

Milestone: PostGIS 3.0.0PostGIS 3.0.1
Summary: st_asmvtgeom sometimes produces leaking polygons (postgis 3.0)st_asmvtgeom sometimes produces leaking polygons (wagyu)
Version: trunk

comment:5 by Raul Marin <git@…>, 5 years ago

Resolution: fixed
Status: newclosed

In 570fbdb/git:

Fix oversimplification of polygon inner rings

This also adapts a MVT test which is checking whether it crashes with an
input or not. Since the exact output depends on the backend
(GEOS vs wagyu), we just ensure the input passes through the function.

Closes #4568
Closes #4556
Closes https://github.com/postgis/postgis/pull/504

Note: See TracTickets for help on using tickets.