#ifdef PREPARED_GEOM
typedef struct
{
+ char type;
PG_LWGEOM* pg_geom1;
PG_LWGEOM* pg_geom2;
size_t pg_geom1_size;
errorIfGeometryCollection(geom1,geom2);
errorIfSRIDMismatch(pglwgeom_getSRID(geom1), pglwgeom_getSRID(geom2));
+#ifdef PGIS_DEBUG
+ lwnotice("Contains: entered", type1, type2);
+#endif
+
/*
* short-circuit 1: if geom2 bounding box is not completely inside
* geom1 bounding box we can prematurely return FALSE.
if ( ( box2.xmin < box1.xmin ) || ( box2.xmax > box1.xmax ) ||
( box2.ymin < box1.ymin ) || ( box2.ymax > box1.ymax ) )
{
+#ifdef PGIS_DEBUG
+ lwnotice("Contains: bbox short circuit", type1, type2);
+#endif
PG_RETURN_BOOL(FALSE);
}
}
*/
type1 = lwgeom_getType((uchar)SERIALIZED_FORM(geom1)[0]);
type2 = lwgeom_getType((uchar)SERIALIZED_FORM(geom2)[0]);
+#ifdef PGIS_DEBUG
+ lwnotice("Contains: type1: %d, type2: %d", type1, type2);
+#endif
if((type1 == POLYGONTYPE || type1 == MULTIPOLYGONTYPE) && type2 == POINTTYPE)
{
#ifdef PGIS_DEBUG
lwgeom = lwgeom_deserialize(SERIALIZED_FORM(geom1));
point = lwpoint_deserialize(SERIALIZED_FORM(geom2));
-#ifdef PGIS_DEBUG
- lwnotice("Precall point_in_polygon %p, %p", lwgeom, point);
-#endif
/*
* Switch the context to the function-scope context,
if( poly_cache->ringIndices )
{
+#ifdef PGIS_DEBUG
+ lwnotice("R-Tree Point in Polygon test.");
+#endif
+
result = point_in_multipolygon_rtree(poly_cache->ringIndices, poly_cache->polyCount, poly_cache->ringCount, point);
}
else if ( type1 == POLYGONTYPE )
{
+#ifdef PGIS_DEBUG
+ lwnotice("Brute force Point in Polygon test.");
+#endif
result = point_in_polygon((LWPOLY*)lwgeom, point);
}
else if ( type1 == MULTIPOLYGONTYPE )
{
+#ifdef PGIS_DEBUG
+ lwnotice("Brute force Point in Polygon test.");
+#endif
result = point_in_multipolygon((LWMPOLY*)lwgeom, point);
}
else {
}
else
{
-#ifdef PGIS_DEBUG
- lwnotice("Contains: type1: %d, type2: %d", type1, type2);
-#endif
}
initGEOS(lwnotice, lwnotice);
size_t pg_geom1_size = 0;
size_t pg_geom2_size = 0;
+ /* Make sure this isn't someone else's cache object. */
+ if( cache && cache->type != 2 ) cache = NULL;
+
if (!PrepGeomHash)
CreatePrepGeomHash();
cache = palloc(sizeof(PrepGeomCache));
MemoryContextSwitchTo(old_context);
+ cache->type = 2;
cache->prepared_geom = 0;
cache->geom = 0;
cache->argnum = 0;
('covers209', 'POLYGON((0 0, 0 10, 10 10, 11 0, 0 0))', 'POLYGON((-2 -2, -2 -3, -3 -3, -3 -2, -2 -2))')
) AS v(c,p1,p2);
+-- UNEXPECTED GEOMETRY TYPES --
+
+SELECT c, ST_Contains(p1, p2) AS contains_p1p2, ST_Contains(p2, p1) AS contains_p2p1,
+ ST_Covers(p1, p2) AS covers_p1p2, ST_Covers(p2, p1) AS covers_p2p1,
+ ST_Intersects(p1, p2) AS intersects_p1p2, ST_Intersects(p2, p1) AS intersects_p2p1,
+ ST_ContainsProperly(p1, p2) AS containsproper_p1p2, ST_ContainsProperly(p2, p1) AS containsproper_p2p1
+ FROM
+( VALUES
+('types100', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', 'POINT(5 5)'),
+('types101', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', 'POINT(5 5)'),
+('types102', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', 'POINT(5 5)'),
+('types103', 'LINESTRING(0 0, 0 10, 10 10, 10 0)', 'POINT(5 5)'),
+('types104', 'LINESTRING(0 0, 0 10, 10 10, 10 0)', 'POINT(5 5)'),
+('types105', 'LINESTRING(0 0, 0 10, 10 10, 10 0)', 'POINT(5 5)'),
+('types106', 'POINT(5 5)', 'POINT(5 5)'),
+('types107', 'POINT(5 5)', 'POINT(5 5)'),
+('types108', 'POINT(5 5)', 'POINT(5 5)'),
+('types109', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'),
+('types110', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'),
+('types111', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'),
+('types112', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', 'LINESTRING(0 0, 0 10, 10 10, 10 0)'),
+('types113', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', 'LINESTRING(0 0, 0 10, 10 10, 10 0)'),
+('types114', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', 'LINESTRING(0 0, 0 10, 10 10, 10 0)')
+) AS v(c,p1,p2);
+
+
SELECT 'intersects310', ST_intersects('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p) 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);