[postgis-tickets] r17804 - Make ST_Simplify(TRIANGLE) collapse if requested
Raul
raul at rmr.ninja
Thu Sep 5 10:10:57 PDT 2019
Author: algunenano
Date: 2019-09-05 10:10:57 -0700 (Thu, 05 Sep 2019)
New Revision: 17804
Modified:
trunk/NEWS
trunk/liblwgeom/lwgeom.c
trunk/regress/core/simplify.sql
trunk/regress/core/simplify_expected
Log:
Make ST_Simplify(TRIANGLE) collapse if requested
References #4496
Closes https://github.com/postgis/postgis/pull/474
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2019-09-05 15:27:36 UTC (rev 17803)
+++ trunk/NEWS 2019-09-05 17:10:57 UTC (rev 17804)
@@ -9,6 +9,7 @@
- #4494, Fix ST_Simplify output having an outdated bbox (Raúl Marín)
- #4493, Fix ST_RemoveRepeatedPoints output having an outdated bbox (Raúl Marín)
- #4495, Fix ST_SnapToGrid output having an outdated bbox (Raúl Marín)
+ - #4496, Make ST_Simplify(TRIANGLE) collapse if requested (Raúl Marín)
PostGIS 3.0.0alpha4
2019/08/10
Modified: trunk/liblwgeom/lwgeom.c
===================================================================
--- trunk/liblwgeom/lwgeom.c 2019-09-05 15:27:36 UTC (rev 17803)
+++ trunk/liblwgeom/lwgeom.c 2019-09-05 17:10:57 UTC (rev 17804)
@@ -1704,8 +1704,19 @@
{
/* No-op! Cannot simplify points or triangles */
case POINTTYPE:
+ return;
case TRIANGLETYPE:
- return;
+ {
+ if (preserve_collapsed)
+ return;
+ LWTRIANGLE *t = lwgeom_as_lwtriangle(geom);
+ POINTARRAY *pa = t->points;
+ ptarray_simplify_in_place(pa, epsilon, 0);
+ if (pa->npoints < 3)
+ {
+ pa->npoints = 0;
+ }
+ }
case LINETYPE:
{
LWLINE *g = (LWLINE*)(geom);
Modified: trunk/regress/core/simplify.sql
===================================================================
--- trunk/regress/core/simplify.sql 2019-09-05 15:27:36 UTC (rev 17803)
+++ trunk/regress/core/simplify.sql 2019-09-05 17:10:57 UTC (rev 17804)
@@ -21,4 +21,8 @@
(
SELECT ST_Simplify('POLYGON((0 0, 10 0, 10 10, 10.6 10, 10.5 10.5, 10 10, 0 10, 0 0))', 1) as g
)
-Select '15', ST_AsText(g) as geometry, postgis_getbbox(g) AS box from geom;
\ No newline at end of file
+Select '15', ST_AsText(g) as geometry, postgis_getbbox(g) AS box from geom;
+
+-- Triangle should collapse if requested
+SELECT '16', ST_AsText(ST_Simplify('TRIANGLE ((0 0, 0 9, 9 0, 0 0))', 10, true));
+SELECT '17', ST_AsText(ST_Simplify('TRIANGLE ((0 0, 0 9, 9 0, 0 0))', 10, false));
\ No newline at end of file
Modified: trunk/regress/core/simplify_expected
===================================================================
--- trunk/regress/core/simplify_expected 2019-09-05 15:27:36 UTC (rev 17803)
+++ trunk/regress/core/simplify_expected 2019-09-05 17:10:57 UTC (rev 17804)
@@ -13,3 +13,5 @@
13|
14|POLYGON((0 0,10 0,10 10,0 0))
15|POLYGON((0 0,10 0,10.5 10.5,0 10,0 0))|BOX(0 0,10.5 10.5)
+16|TRIANGLE((0 0,0 9,9 0,0 0))
+17|
More information about the postgis-tickets
mailing list