typedef struct
{
- Size serialized_geom_length;
- uchar * serialized_geom;
+ int32 key;
GEOSPreparedGeometry * prepared_geom;
} PREPARED_GEOM_CACHE;
* 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);
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 )
{
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);
PG_RETURN_NULL(); /* never get here */
#else
- Size arg1_length;
PG_LWGEOM * geom1;
PG_LWGEOM * geom2;
GEOSGeom g1, g2;
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));
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);
PG_FREE_IF_COPY(geom2, 1);
PG_RETURN_BOOL(result);
-#endif
+#endif /* PREPARED_GEOM */
}
PG_FUNCTION_INFO_V1(containsProperlyPrepared);
PG_RETURN_NULL(); /* never get here */
#else
- Size arg1_length;
PG_LWGEOM * geom1;
PG_LWGEOM * geom2;
GEOSGeom g1, g2;
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));
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);
PG_FREE_IF_COPY(geom2, 1);
PG_RETURN_BOOL(result);
-#endif
+#endif /* PREPARED_GEOM */
}
PG_FUNCTION_INFO_V1(coversPrepared);
PG_RETURN_NULL(); /* never get here */
#else
- Size arg1_length;
PG_LWGEOM * geom1;
PG_LWGEOM * geom2;
GEOSGeom g1, g2;
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));
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);
PG_FREE_IF_COPY(geom2, 1);
PG_RETURN_BOOL(result);
-#endif
+#endif /* PREPARED_GEOM */
}
PG_FUNCTION_INFO_V1(intersectsPrepared);
PG_RETURN_NULL(); /* never get here */
#else
- Size arg1_length;
PG_LWGEOM * geom1;
PG_LWGEOM * geom2;
GEOSGeom g1, g2;
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));
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);
PG_FREE_IF_COPY(geom2, 1);
PG_RETURN_BOOL(result);
-#endif
+#endif /* PREPARED_GEOM */
}
---
---
-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);