[postgis-tickets] r17805 - Make ST_Simplify(TRIANGLE) collapse if requested
Raul
raul at rmr.ninja
Thu Sep 5 10:11:29 PDT 2019
Author: algunenano
Date: 2019-09-05 10:11:29 -0700 (Thu, 05 Sep 2019)
New Revision: 17805
Modified:
branches/2.5/NEWS
branches/2.5/liblwgeom/lwgeom.c
branches/2.5/regress/simplify.sql
branches/2.5/regress/simplify_expected
Log:
Make ST_Simplify(TRIANGLE) collapse if requested
Closes #4496
Modified: branches/2.5/NEWS
===================================================================
--- branches/2.5/NEWS 2019-09-05 17:10:57 UTC (rev 17804)
+++ branches/2.5/NEWS 2019-09-05 17:11:29 UTC (rev 17805)
@@ -10,6 +10,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 2.5.3
2019/08/11
Modified: branches/2.5/liblwgeom/lwgeom.c
===================================================================
--- branches/2.5/liblwgeom/lwgeom.c 2019-09-05 17:10:57 UTC (rev 17804)
+++ branches/2.5/liblwgeom/lwgeom.c 2019-09-05 17:11:29 UTC (rev 17805)
@@ -1753,8 +1753,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: branches/2.5/regress/simplify.sql
===================================================================
--- branches/2.5/regress/simplify.sql 2019-09-05 17:10:57 UTC (rev 17804)
+++ branches/2.5/regress/simplify.sql 2019-09-05 17:11:29 UTC (rev 17805)
@@ -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: branches/2.5/regress/simplify_expected
===================================================================
--- branches/2.5/regress/simplify_expected 2019-09-05 17:10:57 UTC (rev 17804)
+++ branches/2.5/regress/simplify_expected 2019-09-05 17:11:29 UTC (rev 17805)
@@ -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