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

Daniel Baston dbaston at gmail.com
Wed Feb 24 08:46:51 PST 2016


Author: dbaston
Date: 2016-02-24 08:46:50 -0800 (Wed, 24 Feb 2016)
New Revision: 14687

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

Modified: branches/2.2/NEWS
===================================================================
--- branches/2.2/NEWS	2016-02-24 16:35:19 UTC (rev 14686)
+++ branches/2.2/NEWS	2016-02-24 16:46:50 UTC (rev 14687)
@@ -9,6 +9,7 @@
   - #3427, Update spatial_ref_sys to EPSG version 8.8
   - #3433, ST_ClusterIntersecting incorrect for MultiPoints
   - #3436, memory handling mistake in ptarray_clone_deep
+  - #3437, ST_Intersects incorrect for MultiPoints
   - #3461, ST_GeomFromKML crashes Postgres when there are 
            innerBoundaryIs and no outerBoundaryIs
 

Modified: branches/2.2/postgis/lwgeom_geos_prepared.c
===================================================================
--- branches/2.2/postgis/lwgeom_geos_prepared.c	2016-02-24 16:35:19 UTC (rev 14686)
+++ branches/2.2/postgis/lwgeom_geos_prepared.c	2016-02-24 16:46:50 UTC (rev 14687)
@@ -316,7 +316,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: branches/2.2/regress/tickets.sql
===================================================================
--- branches/2.2/regress/tickets.sql	2016-02-24 16:35:19 UTC (rev 14686)
+++ branches/2.2/regress/tickets.sql	2016-02-24 16:46:50 UTC (rev 14687)
@@ -919,5 +919,20 @@
 
 SELECT '#3375', ST_AsText(ST_RemoveRepeatedPoints('GEOMETRYCOLLECTION(POINT(0 -7))'::geometry, 1000));
 
+-- #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: branches/2.2/regress/tickets_expected
===================================================================
--- branches/2.2/regress/tickets_expected	2016-02-24 16:35:19 UTC (rev 14686)
+++ branches/2.2/regress/tickets_expected	2016-02-24 16:46:50 UTC (rev 14687)
@@ -280,3 +280,8 @@
 #3367|POLYGON EMPTY
 #3368|\x660001011fb98788d35ed6fbcdc831c580012b959f01469d8d0e9305ff8618ed08b1b607e302a614fe70bc4682b303b4379ab503a228eeb603e2138eb802900cc0b802ba04dab802b801a8840cb0229cca06f401c216f403a016ea05d0c301a8b301cc189226ac15ee27f811a029b40eac2ae00a902b8407c82b9e03d0e305801dfad3239504ce7e8d01e2f701f6019b04d1e2279bf901ff01
 #3375|GEOMETRYCOLLECTION(POINT(0 -7))
+#3437a|5
+#3437b|5
+#3437c|5
+#3437d|5
+#3437e|5



More information about the postgis-tickets mailing list