[postgis-tickets] r16711 - MVT: Drop geometries smaller than the resolution

Raul raul at rmr.ninja
Wed Aug 29 06:21:10 PDT 2018


Author: algunenano
Date: 2018-08-29 06:21:10 -0700 (Wed, 29 Aug 2018)
New Revision: 16711

Modified:
   trunk/NEWS
   trunk/postgis/mvt.c
Log:
MVT: Drop geometries smaller than the resolution

Closes #4161
Closes https://github.com/postgis/postgis/pull/288



Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2018-08-29 09:36:48 UTC (rev 16710)
+++ trunk/NEWS	2018-08-29 13:21:10 UTC (rev 16711)
@@ -6,6 +6,7 @@
   - #4162, ST_DWithin documentation examples for storing geometry and
     radius in table (Darafei Praliaskouski, github user Boscop).
   - #4163, MVT: Fix resource leak when the first geometry is NULL (Raúl Marín)
+  - #4161, MVT: Drop geometries smaller than the resolution (Raúl Marín)
 
 PostGIS 2.5.0rc1
 2018/08/19

Modified: trunk/postgis/mvt.c
===================================================================
--- trunk/postgis/mvt.c	2018-08-29 09:36:48 UTC (rev 16710)
+++ trunk/postgis/mvt.c	2018-08-29 13:21:10 UTC (rev 16711)
@@ -794,6 +794,17 @@
 	fx = extent / width;
 	fy = -(extent / height);
 
+	if (FLAGS_GET_BBOX(lwgeom->flags) && lwgeom->bbox &&
+		(lwgeom->type == LINETYPE || lwgeom->type == MULTILINETYPE ||
+		lwgeom->type == POLYGONTYPE || lwgeom->type == MULTIPOLYGONTYPE))
+	{
+		// Shortcut to drop geometries smaller than the resolution
+		double bbox_width = lwgeom->bbox->xmax - lwgeom->bbox->xmin;
+		double bbox_height = lwgeom->bbox->ymax - lwgeom->bbox->ymin;
+		if (bbox_height * bbox_height + bbox_width * bbox_width < res * res)
+			return NULL;
+	}
+
 	/* Remove all non-essential points (under the output resolution) */
 	lwgeom_remove_repeated_points_in_place(lwgeom, res);
 	lwgeom_simplify_in_place(lwgeom, res, preserve_collapsed);



More information about the postgis-tickets mailing list