Opened 4 years ago

Closed 4 years ago

#4796 closed defect (fixed)

st_simplifypreservetopology() fails on some MultiSurfaces

Reported by: tvijlbrief Owned by: pramsey
Priority: medium Milestone: PostGIS 3.1.0
Component: postgis Version: 3.0.x
Keywords: Cc:

Description

select st_simplifypreservetopology('MULTISURFACE(((178632.044 397744.007,178631.118 397743.786,178646.399 397679.574,178693.864 397690.889,178698.958 397669.487,178700.206 397669.784,178758.532 397683.689,178748.351 397726.468,178752.199 397727.384,178748.782 397741.904,178744.897 397740.98,178738.157 397769.303,178632.044 397744.007)))'::geometry,1);

ERROR: Unknown geometry type: 12 - MultiSurface

See also: https://github.com/postgis/postgis/pull/588

Quote from https://postgis.net/docs/ST_SimplifyPreserveTopology.html

Will actually do something only with (multi)lines and (multi)polygons but you can safely call it with any kind of geometry.

but this MultiSurface generates an error

Change History (5)

comment:1 by Algunenano, 4 years ago

I'm wondering if the condition should be a positive one (only continue if the type matches one of the "good" ones) instead, which would make things clearer.

comment:2 by tvijlbrief, 4 years ago

I agree, that would not only be clearer but we would also be actually simplifying these geometries.

I wonder what the positive condition is, more than 1 sub-geometry or at least one with a curve?

This error is generated somewhere in libgeos, so the cause and correct fix are upstream. My PR proposal is just a workaround.

comment:3 by tvijlbrief, 4 years ago

The root cause is that MULTISURFACES without curves are not passed to libgeos() but generate an error in the Postgis code. I changed the code in the github PR.

comment:4 by komzpa, 4 years ago

The problem isn't just Simplify. It's issue with all GEOS functions and should be fixed in converters into GEOS. Generally speaking it should be just downgraded into a collection instead of crash, just like TIN.

select postgis_geos_noop('MULTISURFACE(((178632.044 397744.007,178631.118 397743.786,178646.399 397679.574,178693.864 397690.889,178698.958 397669.487,178700.206 397669.784,178758.532 397683.689,178748.351 397726.468,178752.199 397727.384,178748.782 397741.904,178744.897 397740.98,178738.157 397769.303,178632.044 397744.007)))'::geometry);
ERROR:  XX000: Unknown geometry type: 12 - MultiSurface
LOCATION:  pg_error, lwgeom_pg.c:255

comment:5 by Paul Ramsey <pramsey@…>, 4 years ago

Resolution: fixed
Status: newclosed

In 0a083db6/git:

Polish handling of curvilinear geometry types being
sent to GEOS. GEOS only takes linear types, so all
curvilinear types need to be (a) stroked and (b)
re-typed to a linear type. The lwgeom_has_arc() function
is to exact for that work: it will correctly note
that curve types with no curve components have no arc.
So a new broader test for any type that *might* have
an arc is added, to handle the GEOS transformation
situation.
Closes #4796

Note: See TracTickets for help on using tickets.