Commit a53fb7cd authored by Raúl Marín's avatar Raúl Marín

ST_AsMVTGeom: Always return the simplest geometry

Closes #4300


git-svn-id: http://svn.osgeo.org/postgis/branches/2.5@17161 b70326c6-7e19-0410-871a-916f4a2858ee
parent 39b04eec
Pipeline #43549986 passed with stage
in 24 minutes and 23 seconds
......@@ -28,6 +28,7 @@ XXXX/XX/XX
- #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
......
......@@ -766,15 +766,28 @@ lwgeom_get_basic_type(LWGEOM *geom)
* 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 @@ LWGEOM *mvt_geom(LWGEOM *lwgeom, const GBOX *gbox, uint32_t extent, uint32_t buf
}
/* 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))
{
......
......@@ -17,7 +17,7 @@ PG16|POLYGON((0 10,0 0,10 0,10 10,0 10),(1 9,9 9,9 1,1 1,1 9))
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 - ON |MULTIPOLYGON(((5 5,0 0,10 0,5 5)),((0 10,5 5,10 10,0 10)))
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 @@ D7|POINT(1 4094)
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))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment