]> granicus.if.org Git - postgis/commitdiff
#3437, ST_Intersects incorrect for MultiPoints
authorDaniel Baston <dbaston@gmail.com>
Wed, 24 Feb 2016 16:35:19 +0000 (16:35 +0000)
committerDaniel Baston <dbaston@gmail.com>
Wed, 24 Feb 2016 16:35:19 +0000 (16:35 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@14686 b70326c6-7e19-0410-871a-916f4a2858ee

postgis/lwgeom_geos_prepared.c
regress/tickets.sql
regress/tickets_expected

index 791686247c3f48253dfcad08336b67ddd817ec47..ed9c3e6e0c08e476ec809df751bf6733b5574bd5 100644 (file)
@@ -338,7 +338,17 @@ PrepGeomCacheBuilder(const LWGEOM *lwgeom, GeomCache *cache)
        {
                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;
index f4342aa4398dfdcd97b210c8e2e0b3ac9128fcde..660bbbc5ee235067e63aa92d44cc9844e59e241b 100644 (file)
@@ -937,5 +937,20 @@ SELECT '#3461', ST_GeomFromKML('<Polygon>
             
     
 
+-- #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;
index b2790eaafb071a09efb154e7f52e477e2967c2d4..8a61b1371a2119355c9553fc7f8ffe3a3b867349 100644 (file)
@@ -283,3 +283,8 @@ ERROR:  invalid GML representation
 #3399|1000|1000
 #3399|100|100
 ERROR:  invalid KML representation
+#3437a|5
+#3437b|5
+#3437c|5
+#3437d|5
+#3437e|5