int extent, buffer;
bool clip_geom;
if (PG_ARGISNULL(0))
- elog(ERROR, "ST_AsMVTGeom: geom cannot be null");
+ PG_RETURN_NULL();
geom_in = PG_GETARG_GSERIALIZED_P(0);
lwgeom_in = lwgeom_from_gserialized(geom_in);
if (PG_ARGISNULL(1))
* Makes best effort to keep validity. Might collapse geometry into lower
* dimension.
*/
-LWGEOM *mvt_geom(LWGEOM *lwgeom, GBOX *gbox, uint32_t extent, uint32_t buffer,
+LWGEOM *mvt_geom(const LWGEOM *lwgeom, const GBOX *gbox, uint32_t extent, uint32_t buffer,
bool clip_geom)
{
AFFINE affine;
double fy = -(extent / height);
double buffer_map_xunits = resx * buffer;
double buffer_map_yunits = resy * buffer;
- const GBOX *ggbox = lwgeom_get_bbox(lwgeom);
+ const GBOX *ggbox;
POSTGIS_DEBUG(2, "mvt_geom called");
+ /* Short circuit out on EMPTY */
+ if (lwgeom_is_empty(lwgeom))
+ return NULL;
+
+ ggbox = lwgeom_get_bbox(lwgeom);
if (width == 0 || height == 0)
elog(ERROR, "mvt_geom: bounds width or height cannot be 0");
uint32_t c;
};
-LWGEOM *mvt_geom(LWGEOM *geom, GBOX *bounds, uint32_t extent, uint32_t buffer,
+LWGEOM *mvt_geom(const LWGEOM *geom, const GBOX *bounds, uint32_t extent, uint32_t buffer,
bool clip_geom);
void mvt_agg_init_context(struct mvt_agg_context *ctx);
void mvt_agg_transfn(struct mvt_agg_context *ctx);
ST_GeomFromText('POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))'),
ST_MakeBox2D(ST_Point(0, 0), ST_Point(5, 5)),
4096, 0, true)));
+SELECT 'PG10', ST_AsText(ST_AsMVTGeom(
+ 'POINT EMPTY'::geometry,
+ 'BOX(0 0,2 2)'::box2d));
-- geometry encoding tests
SELECT 'TG1', encode(ST_AsMVT(q, 'test', 4096, 'geom'), 'base64') FROM (SELECT 1 AS c1,
PG7|POLYGON((1251 1904,1252 1905,1253 1906,1253 1905,1252 1904,1251 1904))
PG8|MULTIPOLYGON(((5 4096,10 4096,10 4091,5 4096)),((0 4096,0 4101,5 4096,0 4096)))
PG9|POLYGON((0 0,0 4096,4096 4096,4096 0,0 0))
+PG10|
TG1|GiEKBHRlc3QSDBICAAAYASIECTLePxoCYzEiAigBKIAgeAI=
TG2|GiMKBHRlc3QSDhICAAAYASIGETTcPwECGgJjMSICKAEogCB4Ag==
TG3|GiYKBHRlc3QSERICAAAYAiIJCQCAQArQD88PGgJjMSICKAEogCB4Ag==