]> granicus.if.org Git - postgis/commitdiff
Changed the interface for the GEOS prepared predicates.
authorBen Jubb <benjubb@refractions.net>
Tue, 29 Jan 2008 01:24:34 +0000 (01:24 +0000)
committerBen Jubb <benjubb@refractions.net>
Tue, 29 Jan 2008 01:24:34 +0000 (01:24 +0000)
ST_contains, ST_containsProperly, ST_covers, and ST_intersects are now overloaded.
The new arguments style is ( geometry, geometry, integer).  The third argument is used to determine when the first argument changes.  The assumption is that when the third argument changes, the first argument is assumed to have changed too.  This side-steps the issue of determining when the identity of the first geometry changes.

git-svn-id: http://svn.osgeo.org/postgis/trunk@2735 b70326c6-7e19-0410-871a-916f4a2858ee

lwgeom/lwgeom_geos_c.c
lwgeom/lwpostgis.sql.in
regress/Makefile
regress/regress_ogc_prep.sql
regress/regress_ogc_prep_expected

index 08ff378a427042cc5f2ce6b14683290996796601..3d410d0a3faadb1bb8ef855bbce6f67807831d47 100644 (file)
@@ -3605,8 +3605,7 @@ Datum intersectsPrepared(PG_FUNCTION_ARGS);
 
 typedef struct
 {
-       Size                                    serialized_geom_length;
-       uchar *                                 serialized_geom;
+       int32                                   key;
        GEOSPreparedGeometry *  prepared_geom;
 } PREPARED_GEOM_CACHE;
 
@@ -3620,24 +3619,25 @@ typedef struct
  * get cache
  * if cache not exist
  *   create cache 
- *   geom1 into cache
+ *   key into cache
  *
- * else if geom1 matches cached geom1
+ * else if key matches cached key
  *    if cached prepared not exist
  *        geom1 prepared into cache
  *    
  * else
- *   geom1 into cache
+ *   key into cache
+ *   clear prepared cache
  */
 PREPARED_GEOM_CACHE *
 get_prepared_geometry_cache( 
        PREPARED_GEOM_CACHE *   cache, 
-       uchar *                                 serialized_geom, 
-       Size                                    serialized_geom_length)
+       uchar *                                 serialized_geom,
+       int32                                   key )
 {
        GEOSGeom g;
 
-       if ( !cache || !cache->serialized_geom )
+       if ( !cache )
        {
                #ifdef PGIS_DEBUG
                lwnotice( "get_prepared_geometry_cache: creating cache: %x", cache);
@@ -3646,12 +3646,9 @@ get_prepared_geometry_cache(
                cache = lwalloc( sizeof( PREPARED_GEOM_CACHE ));
                
                cache->prepared_geom = 0;
-               cache->serialized_geom_length = serialized_geom_length;
-               cache->serialized_geom = lwalloc(serialized_geom_length);
-        memcpy( cache->serialized_geom, serialized_geom, serialized_geom_length); 
+               cache->key = key;
        }
-       else if ( serialized_geom_length == cache->serialized_geom_length 
-               && 0 == memcmp( cache->serialized_geom, serialized_geom, cache->serialized_geom_length ))
+       else if ( cache->key == key )
        {
                if ( !cache->prepared_geom )
                {
@@ -3675,21 +3672,16 @@ get_prepared_geometry_cache(
                lwnotice("get_prepared_geometry_cache: obj NOT in cache");
                #endif
 
-               lwfree( cache->serialized_geom);
-               cache->serialized_geom = 0;
-               
                GEOSPreparedGeom_destroy( cache->prepared_geom);
-               cache->prepared_geom = 0;
 
-               cache->serialized_geom_length = serialized_geom_length;
-               cache->serialized_geom = lwalloc(serialized_geom_length);
-        memcpy( cache->serialized_geom, serialized_geom, serialized_geom_length); 
+               cache->prepared_geom = 0;
+               cache->key = key;
        }
        
        return cache;
 }
 
-#endif
+#endif /* PREPARED_GEOM */
 
 
 PG_FUNCTION_INFO_V1(containsPrepared);
@@ -3700,7 +3692,6 @@ Datum containsPrepared(PG_FUNCTION_ARGS)
        PG_RETURN_NULL(); /* never get here */
 
 #else
-    Size                                       arg1_length;
        PG_LWGEOM *                             geom1;
        PG_LWGEOM *                             geom2;
        GEOSGeom                                g1, g2;
@@ -3709,13 +3700,12 @@ Datum containsPrepared(PG_FUNCTION_ARGS)
        BOX2DFLOAT4                     box1, box2;
        PREPARED_GEOM_CACHE *   prep_cache;
        MemoryContext                   old_context;
-
-    /*arg1_length = toast_raw_datum_size(PG_GETARG_DATUM(0)) - VARHDRSZ;*/
+       int32                                   surrogate_key;
 
        geom1 = (PG_LWGEOM *)  PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
        geom2 = (PG_LWGEOM *)  PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
-
-       arg1_length = VARSIZE(geom1) - VARHDRSZ;
+       
+       surrogate_key = PG_GETARG_INT32(2);
        
        errorIfGeometryCollection(geom1,geom2);
        errorIfSRIDMismatch(pglwgeom_getSRID(geom1), pglwgeom_getSRID(geom2));
@@ -3737,7 +3727,7 @@ Datum containsPrepared(PG_FUNCTION_ARGS)
        old_context = MemoryContextSwitchTo(fcinfo->flinfo->fn_mcxt);
        prep_cache =  fcinfo->flinfo->fn_extra;
 
-       prep_cache = get_prepared_geometry_cache( prep_cache, geom1, arg1_length);
+       prep_cache = get_prepared_geometry_cache( prep_cache, geom1, surrogate_key);
 
        fcinfo->flinfo->fn_extra = prep_cache;
        MemoryContextSwitchTo(old_context);
@@ -3772,7 +3762,7 @@ Datum containsPrepared(PG_FUNCTION_ARGS)
        PG_FREE_IF_COPY(geom2, 1);
 
        PG_RETURN_BOOL(result);
-#endif
+#endif /* PREPARED_GEOM */
 }
 
 PG_FUNCTION_INFO_V1(containsProperlyPrepared);
@@ -3783,7 +3773,6 @@ Datum containsProperlyPrepared(PG_FUNCTION_ARGS)
        PG_RETURN_NULL(); /* never get here */
 
 #else
-    Size                                       arg1_length;
        PG_LWGEOM *                             geom1;
        PG_LWGEOM *                             geom2;
        GEOSGeom                                g1, g2;
@@ -3792,13 +3781,12 @@ Datum containsProperlyPrepared(PG_FUNCTION_ARGS)
        BOX2DFLOAT4                     box1, box2;
        PREPARED_GEOM_CACHE *   prep_cache;
        MemoryContext                   old_context;
-
-    /*arg1_length = toast_raw_datum_size(PG_GETARG_DATUM(0)) - VARHDRSZ;*/
+       int32                                   surrogate_key;
 
        geom1 = (PG_LWGEOM *)  PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
        geom2 = (PG_LWGEOM *)  PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
-
-       arg1_length = VARSIZE(geom1) - VARHDRSZ;
+       
+       surrogate_key = PG_GETARG_INT32(2);
        
        errorIfGeometryCollection(geom1,geom2);
        errorIfSRIDMismatch(pglwgeom_getSRID(geom1), pglwgeom_getSRID(geom2));
@@ -3820,7 +3808,7 @@ Datum containsProperlyPrepared(PG_FUNCTION_ARGS)
        old_context = MemoryContextSwitchTo(fcinfo->flinfo->fn_mcxt);
        prep_cache =  fcinfo->flinfo->fn_extra;
        
-       prep_cache = get_prepared_geometry_cache( prep_cache, geom1, arg1_length);
+       prep_cache = get_prepared_geometry_cache( prep_cache, geom1, surrogate_key);
        
        fcinfo->flinfo->fn_extra = prep_cache;
        MemoryContextSwitchTo( old_context);
@@ -3855,7 +3843,7 @@ Datum containsProperlyPrepared(PG_FUNCTION_ARGS)
        PG_FREE_IF_COPY(geom2, 1);
 
        PG_RETURN_BOOL(result);
-#endif
+#endif /* PREPARED_GEOM */
 }
 
 PG_FUNCTION_INFO_V1(coversPrepared);
@@ -3866,7 +3854,6 @@ Datum coversPrepared(PG_FUNCTION_ARGS)
        PG_RETURN_NULL(); /* never get here */
 
 #else
-    Size                                       arg1_length;
        PG_LWGEOM *                             geom1;
        PG_LWGEOM *                             geom2;
        GEOSGeom                                g1, g2;
@@ -3875,13 +3862,12 @@ Datum coversPrepared(PG_FUNCTION_ARGS)
        BOX2DFLOAT4                     box1, box2;
        PREPARED_GEOM_CACHE *   prep_cache;
        MemoryContext                   old_context;
-
-    /*arg1_length = toast_raw_datum_size(PG_GETARG_DATUM(0)) - VARHDRSZ;*/
+       int32                                   surrogate_key;
 
        geom1 = (PG_LWGEOM *)  PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
        geom2 = (PG_LWGEOM *)  PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
-
-       arg1_length = VARSIZE(geom1) - VARHDRSZ;
+       
+       surrogate_key = PG_GETARG_INT32(2);
        
        errorIfGeometryCollection(geom1,geom2);
        errorIfSRIDMismatch(pglwgeom_getSRID(geom1), pglwgeom_getSRID(geom2));
@@ -3903,7 +3889,7 @@ Datum coversPrepared(PG_FUNCTION_ARGS)
        old_context = MemoryContextSwitchTo(fcinfo->flinfo->fn_mcxt);
        prep_cache =  fcinfo->flinfo->fn_extra;
 
-       prep_cache = get_prepared_geometry_cache( prep_cache, geom1, arg1_length);
+       prep_cache = get_prepared_geometry_cache( prep_cache, geom1, surrogate_key);
 
        fcinfo->flinfo->fn_extra = prep_cache;
        MemoryContextSwitchTo(old_context);
@@ -3938,7 +3924,7 @@ Datum coversPrepared(PG_FUNCTION_ARGS)
        PG_FREE_IF_COPY(geom2, 1);
 
        PG_RETURN_BOOL(result);
-#endif
+#endif /* PREPARED_GEOM */
 }
 
 PG_FUNCTION_INFO_V1(intersectsPrepared);
@@ -3949,7 +3935,6 @@ Datum intersectsPrepared(PG_FUNCTION_ARGS)
        PG_RETURN_NULL(); /* never get here */
 
 #else
-    Size                                       arg1_length;
        PG_LWGEOM *                             geom1;
        PG_LWGEOM *                             geom2;
        GEOSGeom                                g1, g2;
@@ -3958,13 +3943,12 @@ Datum intersectsPrepared(PG_FUNCTION_ARGS)
        BOX2DFLOAT4                     box1, box2;
        PREPARED_GEOM_CACHE *   prep_cache;
        MemoryContext                   old_context;
-
-    /*arg1_length = toast_raw_datum_size(PG_GETARG_DATUM(0)) - VARHDRSZ;*/
+       int32                                   surrogate_key;
 
        geom1 = (PG_LWGEOM *)  PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
        geom2 = (PG_LWGEOM *)  PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
-
-       arg1_length = VARSIZE(geom1) - VARHDRSZ;
+       
+       surrogate_key = PG_GETARG_INT32(2);
        
        errorIfGeometryCollection(geom1,geom2);
        errorIfSRIDMismatch(pglwgeom_getSRID(geom1), pglwgeom_getSRID(geom2));
@@ -3986,7 +3970,7 @@ Datum intersectsPrepared(PG_FUNCTION_ARGS)
        old_context = MemoryContextSwitchTo(fcinfo->flinfo->fn_mcxt);
        prep_cache =  fcinfo->flinfo->fn_extra;
 
-       prep_cache = get_prepared_geometry_cache( prep_cache, geom1, arg1_length);
+       prep_cache = get_prepared_geometry_cache( prep_cache, geom1, surrogate_key);
 
        fcinfo->flinfo->fn_extra = prep_cache;
        MemoryContextSwitchTo(old_context);
@@ -4021,6 +4005,6 @@ Datum intersectsPrepared(PG_FUNCTION_ARGS)
        PG_FREE_IF_COPY(geom2, 1);
 
        PG_RETURN_BOOL(result);
-#endif
+#endif /* PREPARED_GEOM */
 }
 
index c79cb0326c56748d586063c9feac8cf3ba3c1303..e71f9bdb78f4982de63d066763e55c1a9c18e087 100644 (file)
@@ -4633,32 +4633,32 @@ CREATEFUNCTION ST_Equals(geometry,geometry)
 
 -----------------------------------------------------------------------
 -- Prepared Geometry Predicates
--- requires GEOS 3.2.0-CAPI-1.5.0
+-- requires GEOS 3.1.0-CAPI-1.5.0 or better
 -----------------------------------------------------------------------
-       
-CREATEFUNCTION _ST_ContainsPrepared(geometry,geometry)
+
+CREATEFUNCTION _ST_ContainsPrepared(geometry,geometry,integer)
     RETURNS boolean
     AS '@MODULE_FILENAME@','containsPrepared'
     LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
 
 -- Availability: 1.3.3
 -- Inlines index magic
-CREATEFUNCTION ST_ContainsPrepared(geometry,geometry)
+CREATEFUNCTION ST_Contains(geometry,geometry,integer)
     RETURNS boolean
-    AS 'SELECT $1 && $2 AND _ST_ContainsPrepared($1,$2)'
+    AS 'SELECT $1 && $2 AND _ST_ContainsPrepared($1,$2,$3)'
     LANGUAGE 'SQL' _IMMUTABLE; -- WITH (iscachable);
 
        
-CREATEFUNCTION _ST_ContainsProperlyPrepared(geometry,geometry)
+CREATEFUNCTION _ST_ContainsProperlyPrepared(geometry,geometry,integer)
     RETURNS boolean
     AS '@MODULE_FILENAME@','containsProperlyPrepared'
     LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
 
 -- Availability: 1.3.3
 -- Inlines index magic
-CREATEFUNCTION ST_ContainsProperlyPrepared(geometry,geometry)
+CREATEFUNCTION ST_ContainsProperly(geometry,geometry,integer)
     RETURNS boolean
-    AS 'SELECT $1 && $2 AND _ST_ContainsProperlyPrepared($1,$2)'
+    AS 'SELECT $1 && $2 AND _ST_ContainsProperlyPrepared($1,$2,$3)'
     LANGUAGE 'SQL' _IMMUTABLE; -- WITH (iscachable);
 
        
@@ -4670,29 +4670,29 @@ CREATE OR REPLACE FUNCTION ST_ContainsProperly(geometry,geometry)
     LANGUAGE 'SQL' IMMUTABLE; 
 
        
-CREATEFUNCTION _ST_CoversPrepared(geometry,geometry)
+CREATEFUNCTION _ST_CoversPrepared(geometry,geometry,integer)
     RETURNS boolean
     AS '@MODULE_FILENAME@','coversPrepared'
     LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
        
 -- Availability: 1.3.3
 -- Inlines index magic
-CREATEFUNCTION ST_CoversPrepared(geometry,geometry)
+CREATEFUNCTION ST_Covers(geometry,geometry,integer)
     RETURNS boolean
-    AS 'SELECT $1 && $2 AND _ST_CoversPrepared($1,$2)'
+    AS 'SELECT $1 && $2 AND _ST_CoversPrepared($1,$2,$3)'
     LANGUAGE 'SQL' _IMMUTABLE; -- WITH (iscachable);
 
        
-CREATEFUNCTION _ST_IntersectsPrepared(geometry,geometry)
+CREATEFUNCTION _ST_IntersectsPrepared(geometry,geometry,integer)
     RETURNS boolean
     AS '@MODULE_FILENAME@','intersectsPrepared'
     LANGUAGE 'C' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
        
 -- Availability: 1.3.3
 -- Inlines index magic
-CREATEFUNCTION ST_IntersectsPrepared(geometry,geometry)
+CREATEFUNCTION ST_Intersects(geometry,geometry,integer)
     RETURNS boolean
-    AS 'SELECT $1 && $2 AND _ST_IntersectsPrepared($1,$2)'
+    AS 'SELECT $1 && $2 AND _ST_IntersectsPrepared($1,$2,$3)'
     LANGUAGE 'SQL' _IMMUTABLE; -- WITH (iscachable);
 
 -----------------------------------------------------------------------
index 7316dce8ba22dcc2f77d18f0654ec445b1de5be5..901fd8d2c135fe8672ddb0fda8baef06fe1582a5 100644 (file)
@@ -35,7 +35,7 @@ TESTS = \
        sql-mm-curvepoly \
        sql-mm-general \
        sql-mm-multicurve \
-       sql-mm-multisurface 
+       sql-mm-multisurface
 
 PREPROC = \
        sql-mm-circularstring_expected \
@@ -45,7 +45,7 @@ PREPROC = \
        sql-mm-multisurface_expected
 
 ifeq ($(USE_GEOS),1)
-       TESTS += regress_ogc regress_bdpoly
+       TESTS += regress_ogc regress_bdpoly regress_ogc_prep
 endif
 
 ifeq ($(USE_PROJ),1)
index bc22e003aeb02ae2b0de06b492fc595e50b308a0..d10e918eefa74e85b292ac2132b23eacdeb08599 100644 (file)
 ---
 ---
 
-SELECT 'intersects', ST_intersectsPrepared('LINESTRING(0 10, 0 -10)', p) from ( values 
+SELECT 'intersects', ST_intersects('LINESTRING(0 10, 0 -10)', p, 0) from ( values 
 ('LINESTRING(0 0, 1 1)'),('LINESTRING(0 0, 1 1)'),('LINESTRING(0 0, 1 1)')
 ) as v(p);
 -- PIP - point within polygon
-SELECT 'intersects100', ST_intersectsPrepared('POINT(5 5)', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))');
+SELECT 'intersects100', ST_intersects('POINT(5 5)', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', 0);
 -- PIP - point on polygon vertex
-SELECT 'intersects101', ST_intersectsPrepared('POINT(0 0)', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))');
+SELECT 'intersects101', ST_intersects('POINT(0 0)', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', 0);
 -- PIP - point outside polygon
-SELECT 'intersects102', ST_intersectsPrepared('POINT(-1 0)', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))');
+SELECT 'intersects102', ST_intersects('POINT(-1 0)', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', 0);
 -- PIP - point on polygon edge
-SELECT 'intersects103', ST_intersectsPrepared('POINT(0 5)', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))');
+SELECT 'intersects103', ST_intersects('POINT(0 5)', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', 0);
 -- PIP - point in line with polygon edge
-SELECT 'intersects104', ST_intersectsPrepared('POINT(0 12)', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))');
+SELECT 'intersects104', ST_intersects('POINT(0 12)', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', 0);
 -- PIP - point vertically aligned with polygon vertex 
-SELECT 'intersects105', ST_intersectsPrepared(ST_GeomFromText('POINT(521513 5377804)', 32631), ST_GeomFromText('POLYGON((521526 5377783, 521481 5377811, 521494 5377832, 521539 5377804, 521526 5377783))', 32631));
+SELECT 'intersects105', ST_intersects(ST_GeomFromText('POINT(521513 5377804)', 32631), ST_GeomFromText('POLYGON((521526 5377783, 521481 5377811, 521494 5377832, 521539 5377804, 521526 5377783))', 32631), 0);
 -- PIP - repeated vertex
-SELECT 'intersects106', ST_intersectsPrepared(ST_GeomFromText('POINT(521543 5377804)', 32631), ST_GeomFromText('POLYGON((521526 5377783, 521482 5377811, 521494 5377832, 521539 5377804, 521526 5377783))', 32631));
+SELECT 'intersects106', ST_intersects(ST_GeomFromText('POINT(521543 5377804)', 32631), ST_GeomFromText('POLYGON((521526 5377783, 521482 5377811, 521494 5377832, 521539 5377804, 521526 5377783))', 32631), 0);
 -- PIP - point within polygon
-SELECT 'intersects150', ST_intersectsPrepared('POINT(5 5)', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))');
+SELECT 'intersects150', ST_intersects('POINT(5 5)', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', 0);
 -- PIP - point on polygon vertex
-SELECT 'intersects151', ST_intersectsPrepared('POINT(0 0)', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))');
+SELECT 'intersects151', ST_intersects('POINT(0 0)', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', 0);
 -- PIP - point outside polygon
-SELECT 'intersects152', ST_intersectsPrepared('POINT(-1 0)', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))');
+SELECT 'intersects152', ST_intersects('POINT(-1 0)', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', 0);
 -- PIP - point on polygon edge
-SELECT 'intersects153', ST_intersectsPrepared('POINT(0 5)', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))');
+SELECT 'intersects153', ST_intersects('POINT(0 5)', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', 0);
 -- PIP - point in line with polygon edge
-SELECT 'intersects154', ST_intersectsPrepared('POINT(0 12)', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))');
+SELECT 'intersects154', ST_intersects('POINT(0 12)', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', 0);
 -- PIP - point vertically aligned with polygon vertex 
-SELECT 'intersects155', ST_intersectsPrepared(ST_GeomFromText('POINT(521513 5377804)', 32631), ST_GeomFromText('POLYGON((521526 5377783, 521481 5377811, 521494 5377832, 521539 5377804, 521526 5377783))', 32631));
+SELECT 'intersects155', ST_intersects(ST_GeomFromText('POINT(521513 5377804)', 32631), ST_GeomFromText('POLYGON((521526 5377783, 521481 5377811, 521494 5377832, 521539 5377804, 521526 5377783))', 32631), 0);
 -- PIP - repeated vertex
-SELECT 'intersects156', ST_intersectsPrepared(ST_GeomFromText('POINT(521543 5377804)', 32631), ST_GeomFromText('POLYGON((521526 5377783, 521482 5377811, 521494 5377832, 521539 5377804, 521526 5377783))', 32631));
+SELECT 'intersects156', ST_intersects(ST_GeomFromText('POINT(521543 5377804)', 32631), ST_GeomFromText('POLYGON((521526 5377783, 521482 5377811, 521494 5377832, 521539 5377804, 521526 5377783))', 32631), 0);
 
-SELECT 'intersects200', ST_intersectsPrepared('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p) from ( values 
+SELECT 'intersects200', ST_intersects('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p, 0) from ( values 
 ('POINT(5 5)'),('POINT(5 5)'),('POINT(5 5)') 
 ) as v(p);
 -- PIP - point on vertex of polygon
-SELECT 'intersects201', ST_intersectsPrepared('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p) from ( values 
+SELECT 'intersects201', ST_intersects('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p, 0) from ( values 
 ('POINT(0 0)'),('POINT(0 0)'),('POINT(0 0)')
 ) as v(p);
 -- PIP - point outside polygon
-SELECT 'intersects202', ST_intersectsPrepared('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p) from ( values 
+SELECT 'intersects202', ST_intersects('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p, 0) from ( values 
 ('POINT(-1 0)'),('POINT(-1 0)'),('POINT(-1 0)')
 ) as v(p);
 -- PIP - point on edge of polygon
-SELECT 'intersects203', ST_intersectsPrepared('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p) from ( values 
+SELECT 'intersects203', ST_intersects('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p, 0) from ( values 
 ('POINT(0 5)'),('POINT(0 5)'),('POINT(0 5)')
 ) as v(p);
 -- PIP - point in line with polygon edge
-SELECT 'intersects204', ST_intersectsPrepared('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p) from ( values 
+SELECT 'intersects204', ST_intersects('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p, 0) from ( values 
 ('POINT(0 12)'),('POINT(0 12)'),('POINT(0 12)')
 ) as v(p);
 -- PIP - point vertically aligned with polygon vertex 
-SELECT 'intersects205', ST_intersectsPrepared(ST_GeomFromText('POLYGON((521526 5377783, 521481 5377811, 521494 5377832, 521539 5377804, 521526 5377783))', 32631), p) from ( values 
+SELECT 'intersects205', ST_intersects(ST_GeomFromText('POLYGON((521526 5377783, 521481 5377811, 521494 5377832, 521539 5377804, 521526 5377783))', 32631), p, 0) from ( values 
 (ST_GeomFromText('POINT(521513 5377804)', 32631)),(ST_GeomFromText('POINT(521513 5377804)', 32631)),(ST_GeomFromText('POINT(521513 5377804)', 32631))
 ) as v(p);
 -- PIP - repeated vertex 
-SELECT 'intersects206', ST_intersectsPrepared(ST_GeomFromText('POLYGON((521526 5377783, 521482 5377811, 521481 5377811, 521494 5377832, 521539 5377804, 521526 5377783))', 32631), p) from ( values 
+SELECT 'intersects206', ST_intersects(ST_GeomFromText('POLYGON((521526 5377783, 521482 5377811, 521481 5377811, 521494 5377832, 521539 5377804, 521526 5377783))', 32631), p, 0) from ( values 
 (ST_GeomFromText('POINT(521513 5377804)', 32631)),(ST_GeomFromText('POINT(521513 5377804)', 32631)),(ST_GeomFromText('POINT(521513 5377804)', 32631))
 ) as v(p);
-SELECT 'intersects210', ST_intersectsPrepared('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p) from ( values 
+SELECT 'intersects210', ST_intersects('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p, 0) from ( values 
 ('LINESTRING(1 10, 9 10, 9 8)'),('LINESTRING(1 10, 9 10, 9 8)'),('LINESTRING(1 10, 9 10, 9 8)')
 ) as v(p);
-SELECT 'intersects211', ST_intersectsPrepared('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p) from ( values 
+SELECT 'intersects211', ST_intersects('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p, 0) from ( values 
 ('LINESTRING(1 10, 10 10, 10 8)'),('LINESTRING(1 10, 10 10, 10 8)'),('LINESTRING(1 10, 10 10, 10 8)')
 ) as v(p);
 
 
 -- PIP - point within polygon
-SELECT 'contains100', ST_ContainsPrepared('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p) from ( values 
+SELECT 'contains100', ST_Contains('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p, 0) from ( values 
 ('POINT(5 5)'),('POINT(5 5)'),('POINT(5 5)')
 ) as v(p);
 -- PIP - point on vertex of polygon
-SELECT 'contains101', ST_ContainsPrepared('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p) from ( values 
+SELECT 'contains101', ST_Contains('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p, 0) from ( values 
 ('POINT(0 0)'),('POINT(0 0)'),('POINT(0 0)')
 ) as v(p);
 -- PIP - point outside polygon
-SELECT 'contains102', ST_ContainsPrepared('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p) from ( values 
+SELECT 'contains102', ST_Contains('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p, 0) from ( values 
 ('POINT(-1 0)'),('POINT(-1 0)'),('POINT(-1 0)')
 ) as v(p);
+-- PIP - point on edge of rect
+SELECT 'contains103', ST_Contains('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p, 0) from ( values 
+('POINT(0 5)'),('POINT(0 5)'),('POINT(0 5)')
+) as v(p);
+-- PIP - point on other edge of rect
+SELECT 'contains103a', ST_Contains('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p, 0) from ( values 
+('POINT(5 0)'),('POINT(5 0)'),('POINT(5 0)')
+) as v(p);
 -- PIP - point on edge of polygon
-SELECT 'contains103', ST_ContainsPrepared('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p) from ( values 
+SELECT 'contains103b', ST_Contains('POLYGON((0 0, 0 10, 10 10, 15 0, 0 0))', p, 0) from ( values 
 ('POINT(0 5)'),('POINT(0 5)'),('POINT(0 5)')
 ) as v(p);
+-- PIP - point on other edge of polygon
+SELECT 'contains103c', ST_Contains('POLYGON((0 0, 0 10, 10 10, 15 0, 0 0))', p, 0) from ( values 
+('POINT(5 0)'),('POINT(5 0)'),('POINT(5 0)')
+) as v(p);
 -- PIP - point in line with polygon edge
-SELECT 'contains104', ST_ContainsPrepared('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p) from ( values 
+SELECT 'contains104', ST_Contains('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p, 0) from ( values 
 ('POINT(0 12)'),('POINT(0 12)'),('POINT(0 12)')
 ) as v(p);
 -- PIP - point vertically aligned with polygon vertex 
-SELECT 'contains105', ST_ContainsPrepared(ST_GeomFromText('POLYGON((521526 5377783, 521481 5377811, 521494 5377832, 521539 5377804, 521526 5377783))', 32631), p) from ( values 
+SELECT 'contains105', ST_Contains(ST_GeomFromText('POLYGON((521526 5377783, 521481 5377811, 521494 5377832, 521539 5377804, 521526 5377783))', 32631), p, 0) from ( values 
 (ST_GeomFromText('POINT(521513 5377804)', 32631)),(ST_GeomFromText('POINT(521513 5377804)', 32631)),(ST_GeomFromText('POINT(521513 5377804)', 32631))
 ) as v(p);
 -- PIP - repeated vertex 
-SELECT 'contains106', ST_ContainsPrepared(ST_GeomFromText('POLYGON((521526 5377783, 521482 5377811, 521481 5377811, 521494 5377832, 521539 5377804, 521526 5377783))', 32631), p) from ( values 
+SELECT 'contains106', ST_Contains(ST_GeomFromText('POLYGON((521526 5377783, 521482 5377811, 521481 5377811, 521494 5377832, 521539 5377804, 521526 5377783))', 32631), p, 0) from ( values 
 (ST_GeomFromText('POINT(521513 5377804)', 32631)),(ST_GeomFromText('POINT(521513 5377804)', 32631)),(ST_GeomFromText('POINT(521513 5377804)', 32631))
 ) as v(p);
-SELECT 'contains110', ST_ContainsPrepared('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p) from ( values 
+SELECT 'contains110', ST_Contains('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p, 0) from ( values 
 ('LINESTRING(1 10, 9 10, 9 8)'),('LINESTRING(1 10, 9 10, 9 8)'),('LINESTRING(1 10, 9 10, 9 8)')
 ) as v(p);
-SELECT 'contains111', ST_ContainsPrepared('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p) from ( values 
+SELECT 'contains111', ST_Contains('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p, 0) from ( values 
 ('LINESTRING(1 10, 10 10, 10 8)'),('LINESTRING(1 10, 10 10, 10 8)'),('LINESTRING(1 10, 10 10, 10 8)')
 ) as v(p);
 
 -- PIP - point within polygon
-SELECT 'containsproperly100', ST_ContainsProperlyPrepared('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p) from ( values 
+SELECT 'containsproperly100', ST_ContainsProperly('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p, 0) from ( values 
 ('POINT(5 5)'),('POINT(5 5)'),('POINT(5 5)')
 ) as v(p);
 -- PIP - point on vertex of polygon
-SELECT 'containsproperly101', ST_ContainsProperlyPrepared('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p) from ( values 
+SELECT 'containsproperly101', ST_ContainsProperly('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p, 0) from ( values 
 ('POINT(0 0)'),('POINT(0 0)'),('POINT(0 0)')
 ) as v(p);
 -- PIP - point outside polygon
-SELECT 'containsproperly102', ST_ContainsProperlyPrepared('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p) from ( values 
+SELECT 'containsproperly102', ST_ContainsProperly('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p, 0) from ( values 
 ('POINT(-1 0)'),('POINT(-1 0)'),('POINT(-1 0)')
 ) as v(p);
+-- PIP - point on edge of rect
+SELECT 'containsproperly103', ST_ContainsProperly('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p, 0) from ( values 
+('POINT(0 5)'),('POINT(0 5)'),('POINT(0 5)')
+) as v(p);
+-- PIP - point on other edge of rect
+SELECT 'containsproperly103a', ST_ContainsProperly('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p, 0) from ( values 
+('POINT(5 0)'),('POINT(5 0)'),('POINT(5 0)')
+) as v(p);
 -- PIP - point on edge of polygon
-SELECT 'containsproperly103', ST_ContainsProperlyPrepared('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p) from ( values 
+SELECT 'containsproperly103b', ST_ContainsProperly('POLYGON((0 0, 0 10, 10 10, 15 0, 0 0))', p, 0) from ( values 
 ('POINT(0 5)'),('POINT(0 5)'),('POINT(0 5)')
 ) as v(p);
+-- PIP - point on other edge of polygon
+SELECT 'containsproperly103c', ST_ContainsProperly('POLYGON((0 0, 0 10, 10 10, 15 0, 0 0))', p, 0) from ( values 
+('POINT(5 0)'),('POINT(5 0)'),('POINT(5 0)')
+) as v(p);
 -- PIP - point in line with polygon edge
-SELECT 'containsproperly104', ST_ContainsProperlyPrepared('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p) from ( values 
+SELECT 'containsproperly104', ST_ContainsProperly('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p, 0) from ( values 
 ('POINT(0 12)'),('POINT(0 12)'),('POINT(0 12)')
 ) as v(p);
 -- PIP - point vertically aligned with polygon vertex 
-SELECT 'containsproperly105', ST_ContainsProperlyPrepared(ST_GeomFromText('POLYGON((521526 5377783, 521481 5377811, 521494 5377832, 521539 5377804, 521526 5377783))', 32631), p) from ( values 
+SELECT 'containsproperly105', ST_ContainsProperly(ST_GeomFromText('POLYGON((521526 5377783, 521481 5377811, 521494 5377832, 521539 5377804, 521526 5377783))', 32631), p, 0) from ( values 
 (ST_GeomFromText('POINT(521513 5377804)', 32631)),(ST_GeomFromText('POINT(521513 5377804)', 32631)),(ST_GeomFromText('POINT(521513 5377804)', 32631))
 ) as v(p);
 -- PIP - repeated vertex 
-SELECT 'containsproperly106', ST_ContainsProperlyPrepared(ST_GeomFromText('POLYGON((521526 5377783, 521482 5377811, 521481 5377811, 521494 5377832, 521539 5377804, 521526 5377783))', 32631), p) from ( values 
+SELECT 'containsproperly106', ST_ContainsProperly(ST_GeomFromText('POLYGON((521526 5377783, 521482 5377811, 521481 5377811, 521494 5377832, 521539 5377804, 521526 5377783))', 32631), p, 0) from ( values 
 (ST_GeomFromText('POINT(521513 5377804)', 32631)),(ST_GeomFromText('POINT(521513 5377804)', 32631)),(ST_GeomFromText('POINT(521513 5377804)', 32631))
 ) as v(p);
-SELECT 'containsproperly110', ST_ContainsProperlyPrepared('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p) from ( values 
+SELECT 'containsproperly110', ST_ContainsProperly('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p, 0) from ( values 
 ('LINESTRING(1 10, 9 10, 9 8)'),('LINESTRING(1 10, 9 10, 9 8)'),('LINESTRING(1 10, 9 10, 9 8)')
 ) as v(p);
-SELECT 'containsproperly111', ST_ContainsProperlyPrepared('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p) from ( values 
+SELECT 'containsproperly111', ST_ContainsProperly('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p, 0) from ( values 
 ('LINESTRING(1 10, 10 10, 10 8)'),('LINESTRING(1 10, 10 10, 10 8)'),('LINESTRING(1 10, 10 10, 10 8)')
 ) as v(p);
 
 -- Covers cases
-SELECT 'covers100', ST_CoversPrepared('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p) from ( values 
+SELECT 'covers100', ST_Covers('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p, 0) from ( values 
 ('LINESTRING(1 10, 9 10, 9 8)'),('LINESTRING(1 10, 9 10, 9 8)'),('LINESTRING(1 10, 9 10, 9 8)')
 ) as v(p);
-SELECT 'covers101', ST_CoversPrepared('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p) from ( values 
+SELECT 'covers101', ST_Covers('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p, 0) from ( values 
 ('LINESTRING(1 10, 10 10, 10 8)'),('LINESTRING(1 10, 10 10, 10 8)'),('LINESTRING(1 10, 10 10, 10 8)')
 ) as v(p);
 -- PIP - point within polygon
-SELECT 'covers102', ST_CoversPrepared('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p) from ( values 
+SELECT 'covers102', ST_Covers('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p, 0) from ( values 
 ('POINT(5 5)'),('POINT(5 5)'),('POINT(5 5)')
 ) as v(p);
 -- PIP - point on vertex of polygon
-SELECT 'covers103', ST_CoversPrepared('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p) from ( values 
+SELECT 'covers103', ST_Covers('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p, 0) from ( values 
 ('POINT(0 0)'),('POINT(0 0)'),('POINT(0 0)')
 ) as v(p);
 -- PIP - point outside polygon
-SELECT 'covers104', ST_CoversPrepared('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p) from ( values 
+SELECT 'covers104', ST_Covers('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p, 0) from ( values 
 ('POINT(-1 0)'),('POINT(-1 0)'),('POINT(-1 0)')
 ) as v(p);
 -- PIP - point on edge of polygon
-SELECT 'covers105', ST_CoversPrepared('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p) from ( values 
+SELECT 'covers105', ST_Covers('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p, 0) from ( values 
 ('POINT(0 5)'),('POINT(0 5)'),('POINT(0 5)')
 ) as v(p);
 -- PIP - point in line with polygon edge
-SELECT 'covers106', ST_CoversPrepared('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p) from ( values 
+SELECT 'covers106', ST_Covers('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p, 0) from ( values 
 ('POINT(0 12)'),('POINT(0 12)'),('POINT(0 12)')
 ) as v(p);
 -- PIP - point vertically aligned with polygon vertex 
-SELECT 'covers107', ST_CoversPrepared(ST_GeomFromText('POLYGON((521526 5377783, 521481 5377811, 521494 5377832, 521539 5377804, 521526 5377783))', 32631), p) from ( values 
+SELECT 'covers107', ST_Covers(ST_GeomFromText('POLYGON((521526 5377783, 521481 5377811, 521494 5377832, 521539 5377804, 521526 5377783))', 32631), p, 0) from ( values 
 (ST_GeomFromText('POINT(521513 5377804)', 32631)),(ST_GeomFromText('POINT(521513 5377804)', 32631)),(ST_GeomFromText('POINT(521513 5377804)', 32631))
 ) as v(p);
 -- PIP - repeated vertex 
-SELECT 'covers108', ST_CoversPrepared(ST_GeomFromText('POLYGON((521526 5377783, 521482 5377811, 521481 5377811, 521494 5377832, 521539 5377804, 521526 5377783))', 32631), p) from ( values 
+SELECT 'covers108', ST_Covers(ST_GeomFromText('POLYGON((521526 5377783, 521482 5377811, 521481 5377811, 521494 5377832, 521539 5377804, 521526 5377783))', 32631), p, 0) from ( values 
 (ST_GeomFromText('POINT(521513 5377804)', 32631)),(ST_GeomFromText('POINT(521513 5377804)', 32631)),(ST_GeomFromText('POINT(521513 5377804)', 32631))
 ) as v(p);
index 18c52459d137969187470798db1eb64b3e7a62ef..0d26077b459c3e1c20e9abed6c5bf05a0aa50297 100644 (file)
@@ -54,6 +54,15 @@ contains102|f
 contains103|f
 contains103|f
 contains103|f
+contains103a|f
+contains103a|f
+contains103a|f
+contains103b|f
+contains103b|f
+contains103b|f
+contains103c|f
+contains103c|f
+contains103c|f
 contains104|f
 contains104|f
 contains104|f
@@ -81,6 +90,15 @@ containsproperly102|f
 containsproperly103|f
 containsproperly103|f
 containsproperly103|f
+containsproperly103a|f
+containsproperly103a|f
+containsproperly103a|f
+containsproperly103b|f
+containsproperly103b|f
+containsproperly103b|f
+containsproperly103c|f
+containsproperly103c|f
+containsproperly103c|f
 containsproperly104|f
 containsproperly104|f
 containsproperly104|f