[postgis-commits] svn - r3279 - in trunk: lwgeom regress

postgis-commits at postgis.refractions.net postgis-commits at postgis.refractions.net
Fri Nov 7 09:07:12 PST 2008


Author: pramsey
Date: 2008-11-07 09:07:12 -0800 (Fri, 07 Nov 2008)
New Revision: 3279

Modified:
   trunk/lwgeom/lwgeom_geos_prepared.c
   trunk/lwgeom/lwgeom_geos_prepared.h
   trunk/lwgeom/lwgeom_rtree.c
   trunk/lwgeom/lwgeom_rtree.h
   trunk/regress/regress_ogc_prep.sql
   trunk/regress/regress_ogc_prep_expected
Log:
Prepared geometry mixed-types bug fix ported forward from 1.3.


Modified: trunk/lwgeom/lwgeom_geos_prepared.c
===================================================================
--- trunk/lwgeom/lwgeom_geos_prepared.c	2008-11-07 14:23:59 UTC (rev 3278)
+++ trunk/lwgeom/lwgeom_geos_prepared.c	2008-11-07 17:07:12 UTC (rev 3279)
@@ -280,6 +280,9 @@
 	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();
 
@@ -303,6 +306,7 @@
 		cache = palloc(sizeof(PrepGeomCache));		
 		MemoryContextSwitchTo(old_context);
 	
+        cache->type = 2;
 		cache->prepared_geom = 0;
 		cache->geom = 0;
 		cache->argnum = 0;

Modified: trunk/lwgeom/lwgeom_geos_prepared.h
===================================================================
--- trunk/lwgeom/lwgeom_geos_prepared.h	2008-11-07 14:23:59 UTC (rev 3278)
+++ trunk/lwgeom/lwgeom_geos_prepared.h	2008-11-07 17:07:12 UTC (rev 3279)
@@ -50,6 +50,7 @@
 #ifdef PREPARED_GEOM
 typedef struct
 {
+	char*                         type;
 	PG_LWGEOM*                    pg_geom1;
 	PG_LWGEOM*                    pg_geom2;
 	size_t                        pg_geom1_size;

Modified: trunk/lwgeom/lwgeom_rtree.c
===================================================================
--- trunk/lwgeom/lwgeom_rtree.c	2008-11-07 14:23:59 UTC (rev 3278)
+++ trunk/lwgeom/lwgeom_rtree.c	2008-11-07 17:07:12 UTC (rev 3279)
@@ -398,6 +398,7 @@
 	result->ringCount = 0;
 	result->ringIndices = 0;
 	result->poly = 0;
+	result->type = 1;
 	return result;
 }
 
@@ -488,6 +489,9 @@
 
 	LWDEBUGF(2, "retrieveCache called with %p %p %p", lwgeom, serializedPoly, currentCache);
 
+    /* Make sure this isn't someone else's cache object. */
+    if( currentCache && currentCache->type != 1 ) currentCache = NULL;
+
 	if(!currentCache)
 	{
 		LWDEBUG(3, "No existing cache, create one.");

Modified: trunk/lwgeom/lwgeom_rtree.h
===================================================================
--- trunk/lwgeom/lwgeom_rtree.h	2008-11-07 14:23:59 UTC (rev 3278)
+++ trunk/lwgeom/lwgeom_rtree.h	2008-11-07 17:07:12 UTC (rev 3279)
@@ -45,6 +45,7 @@
 
 typedef struct
 {
+	char *type;
         RTREE_NODE **ringIndices;
         int ringCount;
         int polyCount;

Modified: trunk/regress/regress_ogc_prep.sql
===================================================================
--- trunk/regress/regress_ogc_prep.sql	2008-11-07 14:23:59 UTC (rev 3278)
+++ trunk/regress/regress_ogc_prep.sql	2008-11-07 17:07:12 UTC (rev 3279)
@@ -242,6 +242,32 @@
 ('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);

Modified: trunk/regress/regress_ogc_prep_expected
===================================================================
--- trunk/regress/regress_ogc_prep_expected	2008-11-07 14:23:59 UTC (rev 3278)
+++ trunk/regress/regress_ogc_prep_expected	2008-11-07 17:07:12 UTC (rev 3279)
@@ -110,6 +110,21 @@
 covers207|t|f
 covers208|f|f
 covers209|f|f
+types100|t|f|t|f|t|t|t|f
+types101|t|f|t|f|t|t|t|f
+types102|t|f|t|f|t|t|t|f
+types103|f|f|f|f|f|f|f|f
+types104|f|f|f|f|f|f|f|f
+types105|f|f|f|f|f|f|f|f
+types106|t|t|t|t|t|t|t|t
+types107|t|t|t|t|t|t|t|t
+types108|t|t|t|t|t|t|t|t
+types109|t|t|t|t|t|t|f|f
+types110|t|t|t|t|t|t|f|f
+types111|t|t|t|t|t|t|f|f
+types112|f|f|t|f|t|t|f|f
+types113|f|f|t|f|t|t|f|f
+types114|f|f|t|f|t|t|f|f
 intersects310|t
 intersects310|t
 intersects310|t



More information about the postgis-commits mailing list