[postgis-tickets] r17161 - ST_AsMVTGeom: Always return the simplest geometry
Raul
raul at rmr.ninja
Wed Jan 16 02:50:44 PST 2019
Author: algunenano
Date: 2019-01-16 02:50:43 -0800 (Wed, 16 Jan 2019)
New Revision: 17161
Modified:
branches/2.5/NEWS
branches/2.5/postgis/mvt.c
branches/2.5/regress/mvt_expected
Log:
ST_AsMVTGeom: Always return the simplest geometry
Closes #4300
Modified: branches/2.5/NEWS
===================================================================
--- branches/2.5/NEWS 2019-01-16 10:48:55 UTC (rev 17160)
+++ branches/2.5/NEWS 2019-01-16 10:50:43 UTC (rev 17161)
@@ -28,6 +28,7 @@
- #4273, Tighter parsing of WKT (Paul Ramsey)
- #4292, ST_AsMVT: parse JSON numeric values with decimals as doubles (Raúl Marín)
+ - #4300, ST_AsMVTGeom: Always return the simplest geometry (Raúl Marín)
PostGIS 2.5.1
2018/11/18
Modified: branches/2.5/postgis/mvt.c
===================================================================
--- branches/2.5/postgis/mvt.c 2019-01-16 10:48:55 UTC (rev 17160)
+++ branches/2.5/postgis/mvt.c 2019-01-16 10:50:43 UTC (rev 17161)
@@ -766,15 +766,28 @@
* geom be lost? Sure, but your MVT renderer couldn't
* draw it anyways.
*/
-static void
+static inline LWGEOM *
lwgeom_to_basic_type(LWGEOM *geom, uint8 original_type)
{
+ LWGEOM *geom_out = geom;
if (lwgeom_get_type(geom) == COLLECTIONTYPE)
{
LWCOLLECTION *g = (LWCOLLECTION*)geom;
- LWCOLLECTION *gc = lwcollection_extract(g, original_type);
- *g = *gc;
+ geom_out = (LWGEOM *)lwcollection_extract(g, original_type);
}
+
+ /* If a collection only contains 1 geometry return than instead */
+ if (lwgeom_is_collection(geom_out))
+ {
+ LWCOLLECTION *g = (LWCOLLECTION *)geom_out;
+ if (g->ngeoms == 1)
+ {
+ geom_out = g->geoms[0];
+ }
+ }
+
+ geom_out->srid = geom->srid;
+ return geom_out;
}
/**
@@ -898,8 +911,7 @@
}
/* if geometry collection extract highest dimensional geometry type */
- if (lwgeom->type == COLLECTIONTYPE)
- lwgeom_to_basic_type(lwgeom, basic_type);
+ lwgeom = lwgeom_to_basic_type(lwgeom, basic_type);
if (basic_type != lwgeom_get_basic_type(lwgeom))
{
Modified: branches/2.5/regress/mvt_expected
===================================================================
--- branches/2.5/regress/mvt_expected 2019-01-16 10:48:55 UTC (rev 17160)
+++ branches/2.5/regress/mvt_expected 2019-01-16 10:50:43 UTC (rev 17161)
@@ -17,7 +17,7 @@
PG17|MULTIPOLYGON(((0 10,0 0,10 0,10 10,0 10),(1 9,9 9,9 1,1 1,1 9)),((2 8,2 2,8 2,8 8,2 8),(3 7,7 7,7 3,3 3,3 7)))
PG18|MULTIPOINT(1 9,3 8)
PG19|MULTIPOINT(25 4079,26 4078)
-PG20|MULTIPOINT(10 4086)
+PG20|POINT(10 4086)
PG21|LINESTRING(1 9,5 5)
PG22|
PG23|MULTILINESTRING((1 9,5 5),(2 2,5 5))
@@ -48,7 +48,7 @@
PG43 - OFF|MULTIPOLYGON(((5 5,-1 -1,11 -1,5 5)),((5 5,11 11,-1 11,5 5)))
PG44|
PG45|
-PG46|SRID=3857;MULTIPOLYGON(((3245 2224,3262 2030,3253 2158,3245 2224)))
+PG46|SRID=3857;POLYGON((3245 2224,3262 2030,3253 2158,3245 2224))
TG1|GiEKBHRlc3QSDBICAAAYASIECTLePxoCYzEiAigBKIAgeAI=
TG2|GiMKBHRlc3QSDhICAAAYASIGETLePwIBGgJjMSICKAEogCB4Ag==
TG3|GiYKBHRlc3QSERICAAAYAiIJCQCAQArQD88PGgJjMSICKAEogCB4Ag==
@@ -98,4 +98,4 @@
TU2
ERROR: pgis_asmvt_transfn: parameter row cannot be other than a rowtype
TU3|
-#3922|MULTIPOLYGON(((2613 3664,2615 3662,2616 3662,2617 3665,2615 3665,2615 3664,2613 3664)))
+#3922|POLYGON((2613 3664,2615 3662,2616 3662,2617 3665,2615 3665,2615 3664,2613 3664))
More information about the postgis-tickets
mailing list