From cce6795a9d3d873b6077cd0f9844047619e2958d Mon Sep 17 00:00:00 2001 From: Daniel Baston Date: Wed, 24 Feb 2016 16:35:19 +0000 Subject: [PATCH] #3437, ST_Intersects incorrect for MultiPoints git-svn-id: http://svn.osgeo.org/postgis/trunk@14686 b70326c6-7e19-0410-871a-916f4a2858ee --- postgis/lwgeom_geos_prepared.c | 12 +++++++++++- regress/tickets.sql | 15 +++++++++++++++ regress/tickets_expected | 5 +++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/postgis/lwgeom_geos_prepared.c b/postgis/lwgeom_geos_prepared.c index 791686247..ed9c3e6e0 100644 --- a/postgis/lwgeom_geos_prepared.c +++ b/postgis/lwgeom_geos_prepared.c @@ -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; diff --git a/regress/tickets.sql b/regress/tickets.sql index f4342aa43..660bbbc5e 100644 --- a/regress/tickets.sql +++ b/regress/tickets.sql @@ -937,5 +937,20 @@ SELECT '#3461', ST_GeomFromKML(' +-- #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; diff --git a/regress/tickets_expected b/regress/tickets_expected index b2790eaaf..8a61b1371 100644 --- a/regress/tickets_expected +++ b/regress/tickets_expected @@ -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 -- 2.40.0