-
Notifications
You must be signed in to change notification settings - Fork 394
Description
I have an issue with ST_SimplifyPreserveTopology with geos >= 3.12.1
I need ST_SimplifyPreserveTopology to be consistent across multiple runs, i.e. produce the same results when run with the the same inputs. In some cases this does not happen with geos >= 3.12.1
I have set up a test in this dbfiddle: https://dbfiddle.uk/GvwR39tT
The function test_simplify3 runs the same test for a certain number of iterations and returns the results as a table.
poly.the_geom is the test geometry, polygon, srid 3857, valid.
ST_SimplifyPreserveTopology(poly.the_geom, 20) is called in subqueries s1,s2.
The function outputs these results about the simplified geometries:
- run: the iteration
- diff: difference
- wkt_difference: difference, as text
- simp_equals: result of st_equals
- simp_ordering_equals: result of st_orderingequals
- eq: result of bare equality
- wkb_eq: result of equality between wkbs
- valid1: whether first geometry is valid
- valid2: same as above for the second geometry
- n1simp: how many points in first geometry
- n2simp: same as above for second geometry
In the dbfiddle the function is called with iterations=500
select * from test_simplify3(500) where st_isempty(diff) is distinct from true;
I have tested the same on another server:
POSTGIS="3.4.2 c19ce56" [EXTENSION] PGSQL="150" GEOS="3.12.1-CAPI-1.18.1" (compiled against GEOS 3.10.2) SFCGAL="SFCGAL 1.4.1, CGAL 5.3.1, BOOST 1.74.0" PROJ="8.2.1 NETWORK_ENABLED=OFF URL_ENDPOINT=https://cdn.proj.org USER_WRITABLE_DIRECTORY=/tmp/proj DATABASE_PATH=/usr/share/proj/proj.db" LIBXML="2.9.13" LIBJSON="0.15" LIBPROTOBUF="1.3.3" WAGYU="0.5.0 (Internal)" (core procs from "3.4.1 ca035b9" need upgrade) (sfcgal procs from "3.4.1 ca035b9" need upgrade)
and I get failures even with less iterations (ex: 100)
As you can see there are cases where:
- st_isempty(diff) = f
- wkt_difference = 'POLYGON EMPTY'
- all other results seem to indicate the two geometries are the same: simp_equals=t, simp_ordering_equals=t, eq=t, wkb_eq=t
I am not able to reproduce the issue in windows with the latest available postgis bundle:
PostgreSQL 15.7, postgis 3.4.2, geos 3.12.1
Tried with iterations=5000, (....it takes a while but) no errors are reported.
On the ubuntu server mentioned above, I have also made a test with the very latest geos release 3.12.2. Probably a coincidence, but the results are worst (~10% failure rate with 100 iterations).
As a side note, I need to use geos >= 3.12.1 because of other ST_SimplifyPreserveTopology instabilities, see this related issue: