[postgis-tickets] r14835 - #3522, handle POINT and MULTIPOINT correctly in ST_Subdivide

Paul Ramsey pramsey at cleverelephant.ca
Tue Apr 12 14:39:32 PDT 2016


Author: pramsey
Date: 2016-04-12 14:39:32 -0700 (Tue, 12 Apr 2016)
New Revision: 14835

Modified:
   trunk/liblwgeom/cunit/cu_clip_by_rect.c
   trunk/liblwgeom/lwgeom.c
   trunk/regress/tickets.sql
   trunk/regress/tickets_expected
Log:
#3522, handle POINT and MULTIPOINT correctly in ST_Subdivide



Modified: trunk/liblwgeom/cunit/cu_clip_by_rect.c
===================================================================
--- trunk/liblwgeom/cunit/cu_clip_by_rect.c	2016-04-12 21:39:24 UTC (rev 14834)
+++ trunk/liblwgeom/cunit/cu_clip_by_rect.c	2016-04-12 21:39:32 UTC (rev 14835)
@@ -42,7 +42,23 @@
 	CU_ASSERT_STRING_EQUAL(wkt, tmp)
 	lwfree(tmp); lwgeom_free(out); lwgeom_free(in);
 
-  /* Disjoint polygon */
+	wkt = "MULTIPOINT EMPTY";
+	in = lwgeom_from_wkt(wkt, LW_PARSER_CHECK_NONE);
+	out = lwgeom_clip_by_rect(in, 5, 0, 10, 10);
+	tmp = lwgeom_to_ewkt(out);
+	/* printf("%s\n", tmp); */
+	CU_ASSERT_STRING_EQUAL(wkt, tmp)
+	lwfree(tmp); lwgeom_free(out); lwgeom_free(in);
+
+	wkt = "MULTIPOINT(0 0, 6 6, 7 5)";
+	in = lwgeom_from_wkt(wkt, LW_PARSER_CHECK_NONE);
+	out = lwgeom_clip_by_rect(in, 5, 0, 10, 10);
+	tmp = lwgeom_to_ewkt(out);
+	/* printf("%s\n", tmp); */
+	CU_ASSERT_STRING_EQUAL("MULTIPOINT(6 6,7 5)", tmp)
+	lwfree(tmp); lwgeom_free(out); lwgeom_free(in);
+
+	/* Disjoint polygon */
 	wkt = "POLYGON((311017 4773762,311016 4773749,311006 4773744,310990 4773748,310980 4773758,310985 4773771,311003 4773776,311017 4773762))";
 	in = lwgeom_from_wkt(wkt, LW_PARSER_CHECK_NONE);
 	out = lwgeom_clip_by_rect(in, -80, -80, 80, 80);

Modified: trunk/liblwgeom/lwgeom.c
===================================================================
--- trunk/liblwgeom/lwgeom.c	2016-04-12 21:39:24 UTC (rev 14834)
+++ trunk/liblwgeom/lwgeom.c	2016-04-12 21:39:32 UTC (rev 14835)
@@ -1925,10 +1925,20 @@
 	}
 	
 	if ( width == 0.0 && height == 0.0 )
-		return 0;
+	{
+		if ( geom->type == POINTTYPE )
+		{
+			lwcollection_add_lwgeom(col, lwgeom_clone_deep(geom));
+			return 1;			
+		}
+		else
+		{
+			return 0;
+		}
+	}
 	
 	/* Always just recurse into collections */
-	if ( lwgeom_is_collection(geom) )
+	if ( lwgeom_is_collection(geom) && geom->type != MULTIPOINTTYPE )
 	{
 		LWCOLLECTION *incol = (LWCOLLECTION*)geom;
 		int n = 0;

Modified: trunk/regress/tickets.sql
===================================================================
--- trunk/regress/tickets.sql	2016-04-12 21:39:24 UTC (rev 14834)
+++ trunk/regress/tickets.sql	2016-04-12 21:39:32 UTC (rev 14835)
@@ -953,5 +953,7 @@
 SELECT '#3437e' AS t, count(*) FROM mp INNER JOIN p ON ST_Within(p.geom, mp.geom);
 
 
+SELECT '#3522', ST_AsText(ST_Subdivide(ST_GeomFromText('POINT(1 1)',4326),10));
+
 -- Clean up
 DELETE FROM spatial_ref_sys;

Modified: trunk/regress/tickets_expected
===================================================================
--- trunk/regress/tickets_expected	2016-04-12 21:39:24 UTC (rev 14834)
+++ trunk/regress/tickets_expected	2016-04-12 21:39:32 UTC (rev 14835)
@@ -288,3 +288,4 @@
 #3437c|5
 #3437d|5
 #3437e|5
+#3522|POINT(1 1)



More information about the postgis-tickets mailing list