ctx->feature->tags = tags;
}
+int max_dim(LWCOLLECTION *lwcoll)
+{
+ int i, dim = 1;
+ for (i = 0; i < lwcoll->ngeoms; i++) {
+ uint8_t type = lwcoll->geoms[i]->type;
+ if (type == POLYGONTYPE || type == MULTIPOLYGONTYPE)
+ return 3;
+ else if (type == LINETYPE || type == MULTILINETYPE)
+ dim = 2;
+ }
+ return dim;
+}
+
/**
* Transform a geometry into vector tile coordinate space.
*
lwgeom_force_clockwise(lwgeom_out);
lwgeom_out = lwgeom_make_valid(lwgeom_out);
- int type = lwgeom_out->type;
- int i, extract_type = 1;
- if (type == COLLECTIONTYPE) {
+ if (lwgeom_out->type == COLLECTIONTYPE) {
LWCOLLECTION *lwcoll = (LWCOLLECTION*) lwgeom_out;
- for (i = 0; i < lwcoll->ngeoms; i++) {
- LWGEOM *geom = lwcoll->geoms[i];
- if (geom->type == POLYGONTYPE) {
- extract_type = 3;
- break;
- } else if (geom->type == LINETYPE) {
- extract_type = 2;
- }
- }
lwgeom_out = lwcollection_as_lwgeom(
- lwcollection_extract(lwcoll, extract_type));
+ lwcollection_extract(lwcoll, max_dim(lwcoll)));
lwgeom_out = lwgeom_homogenize(lwgeom_out);
}
-7797789.63692662 1417736.81850415,-7793160.38395328 1412417.61222784,-7792023.4539488 1411512.60791779))'),
ST_MakeBox2D(ST_Point(-20037508.34, 20037508.34), ST_Point(20037508.34, -20037508.34)),
4096, 10, true));
-
+select 'PG8', ST_AsText(ST_AsMVTGeom(
+ ST_GeomFromText('GEOMETRYCOLLECTION(MULTIPOLYGON (((0 0, 10 0, 10 5, 0 -5, 0 0))))'),
+ ST_MakeBox2D(ST_Point(0, 0), ST_Point(4096, 4096)),
+ 4096, 0, false));
-- geometry encoding tests
SELECT 'TG1', encode(ST_AsMVT('test', 4096, 'geom', q), 'base64') FROM (SELECT 1 AS c1,
PG5|POINT(0 4096)
PG6|POLYGON((894 2704,2791 594,600 594,894 2704))
PG7|POLYGON((1252 1904,1251 1904,1252 1905,1253 1906,1253 1905,1252 1904))
+PG8|MULTIPOLYGON(((5 4096,10 4096,10 4091,5 4096)),((0 4096,0 4101,5 4096,0 4096)))
TG1|GiEKBHRlc3QSDBICAAAYASIECTLePxoCYzEiAigBKIAgeAI=
TG2|GiMKBHRlc3QSDhICAAAYASIGETLePwIBGgJjMSICKAEogCB4Ag==
TG3|GiYKBHRlc3QSERICAAAYAiIJCQCAQArQD88PGgJjMSICKAEogCB4Ag==