[postgis-tickets] r14686 - #3437, ST_Intersects incorrect for MultiPoints

Daniel Baston dbaston at gmail.com
Wed Feb 24 08:35:19 PST 2016


Author: dbaston
Date: 2016-02-24 08:35:19 -0800 (Wed, 24 Feb 2016)
New Revision: 14686

Modified:
   trunk/postgis/lwgeom_geos_prepared.c
   trunk/regress/tickets.sql
   trunk/regress/tickets_expected
Log:
#3437, ST_Intersects incorrect for MultiPoints

Modified: trunk/postgis/lwgeom_geos_prepared.c
===================================================================
--- trunk/postgis/lwgeom_geos_prepared.c	2016-02-24 16:25:57 UTC (rev 14685)
+++ trunk/postgis/lwgeom_geos_prepared.c	2016-02-24 16:35:19 UTC (rev 14686)
@@ -338,7 +338,17 @@
 	{
 		lwpgerror("PrepGeomCacheBuilder asked to build new prepcache where one already exists.");
 		return LW_FAILURE;
-	}
+    }
+
+	/*
+	 * Avoid creating a PreparedPoint around a Point or a MultiPoint.
+	 * Consider changing this behavior in the future if supported GEOS
+	 * versions correctly handle prepared points and multipoints and
+	 * provide a performance benefit.
+	 * See https://trac.osgeo.org/postgis/ticket/3437
+	 */
+	if (lwgeom_get_type(lwgeom) == POINTTYPE || lwgeom_get_type(lwgeom) == MULTIPOINTTYPE)
+		return LW_FAILURE;
 	
 	prepcache->geom = LWGEOM2GEOS( lwgeom , 0);
 	if ( ! prepcache->geom ) return LW_FAILURE;

Modified: trunk/regress/tickets.sql
===================================================================
--- trunk/regress/tickets.sql	2016-02-24 16:25:57 UTC (rev 14685)
+++ trunk/regress/tickets.sql	2016-02-24 16:35:19 UTC (rev 14686)
@@ -937,5 +937,20 @@
             
     
 
+-- #3437
+WITH
+mp AS (SELECT ST_Collect(ST_MakePoint(-c, c*c)) AS geom FROM generate_series(1, 5) c),
+p  AS (SELECT (ST_Dump(geom)).geom FROM mp)
+SELECT '#3437a' AS t, count(*) FROM mp INNER JOIN p ON ST_Intersects(mp.geom, p.geom)
+UNION ALL
+SELECT '#3437b' AS t, count(*) FROM mp INNER JOIN p ON ST_Contains(mp.geom, p.geom)
+UNION ALL
+SELECT '#3437c' AS t, count(*) FROM mp INNER JOIN p ON ST_ContainsProperly(mp.geom, p.geom)
+UNION ALL
+SELECT '#3437d' AS t, count(*) FROM mp INNER JOIN p ON ST_Covers(mp.geom, p.geom)
+UNION ALL
+SELECT '#3437e' AS t, count(*) FROM mp INNER JOIN p ON ST_Within(p.geom, mp.geom);
+
+
 -- Clean up
 DELETE FROM spatial_ref_sys;

Modified: trunk/regress/tickets_expected
===================================================================
--- trunk/regress/tickets_expected	2016-02-24 16:25:57 UTC (rev 14685)
+++ trunk/regress/tickets_expected	2016-02-24 16:35:19 UTC (rev 14686)
@@ -283,3 +283,8 @@
 #3399|1000|1000
 #3399|100|100
 ERROR:  invalid KML representation
+#3437a|5
+#3437b|5
+#3437c|5
+#3437d|5
+#3437e|5



More information about the postgis-tickets mailing list