From: Paul Ramsey Date: Wed, 11 Nov 2009 19:57:24 +0000 (+0000) Subject: Update behavior of lwgeom_same to match "orderingequals" semantics (#289) X-Git-Tag: 1.5.0b1~257 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=43a8513e27b24b6c5f3719957ab72f85367c07fe;p=postgis Update behavior of lwgeom_same to match "orderingequals" semantics (#289) git-svn-id: http://svn.osgeo.org/postgis/trunk@4789 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/liblwgeom/lwcollection.c b/liblwgeom/lwcollection.c index 8f5420f37..78d185dd9 100644 --- a/liblwgeom/lwcollection.c +++ b/liblwgeom/lwcollection.c @@ -336,13 +336,21 @@ lwcollection_segmentize2d(LWCOLLECTION *col, double dist) char lwcollection_same(const LWCOLLECTION *c1, const LWCOLLECTION *c2) { - unsigned int i, j; - unsigned int *hit; + unsigned int i; +// unsigned int *hit; LWDEBUG(2, "lwcollection_same called"); - if ( TYPE_GETTYPE(c1->type) != TYPE_GETTYPE(c2->type) ) return 0; - if ( c1->ngeoms != c2->ngeoms ) return 0; + if ( TYPE_GETTYPE(c1->type) != TYPE_GETTYPE(c2->type) ) return LW_FALSE; + if ( c1->ngeoms != c2->ngeoms ) return LW_FALSE; + + for( i = 0; i < c1->ngeoms; i++ ) + { + if ( ! lwgeom_same(c1->geoms[i], c2->geoms[i]) ) + return LW_FALSE; + } + +/* Former method allowed out-of-order equality between collections hit = lwalloc(sizeof(unsigned int)*c1->ngeoms); memset(hit, 0, sizeof(unsigned int)*c1->ngeoms); @@ -360,9 +368,11 @@ lwcollection_same(const LWCOLLECTION *c1, const LWCOLLECTION *c2) break; } } - if ( ! found ) return 0; + if ( ! found ) return LW_FALSE; } - return 1; +*/ + + return LW_TRUE; } int lwcollection_ngeoms(const LWCOLLECTION *col) diff --git a/liblwgeom/lwgeom.c b/liblwgeom/lwgeom.c index c65749268..4e2431d74 100644 --- a/liblwgeom/lwgeom.c +++ b/liblwgeom/lwgeom.c @@ -781,14 +781,14 @@ lwgeom_same(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2) { LWDEBUG(3, " type differ"); - return 0; + return LW_FALSE; } if ( TYPE_GETZM(lwgeom1->type) != TYPE_GETZM(lwgeom2->type) ) { LWDEBUG(3, " ZM flags differ"); - return 0; + return LW_FALSE; } /* Check boxes if both already computed */ @@ -799,7 +799,7 @@ lwgeom_same(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2) { LWDEBUG(3, " bounding boxes differ"); - return 0; + return LW_FALSE; } } @@ -824,7 +824,7 @@ lwgeom_same(const LWGEOM *lwgeom1, const LWGEOM *lwgeom2) default: lwerror("lwgeom_same: unsupported geometry type: %s", lwgeom_typename(TYPE_GETTYPE(lwgeom1->type))); - return 0; + return LW_FALSE; } } diff --git a/regress/regress_expected b/regress/regress_expected index 33204a870..f2a830952 100644 --- a/regress/regress_expected +++ b/regress/regress_expected @@ -84,9 +84,9 @@ HINT: "MULTIPOINT(1 1, 2 2" <-- parse error at position 19 within geometry 68|t 68a|t 69|t -69a|t +69a|f 70|t -70a|t +70a|f 71|t 71a|f 72|t