From 4c8edd69cf8c68e41e9eddd130b45445abed0832 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Fri, 26 Nov 2004 15:06:08 +0000 Subject: [PATCH] lwcollection_same allows different components ordering to reflect older behaviour. git-svn-id: http://svn.osgeo.org/postgis/trunk@1114 b70326c6-7e19-0410-871a-916f4a2858ee --- lwgeom/lwcollection.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/lwgeom/lwcollection.c b/lwgeom/lwcollection.c index 70739df64..6d03974fc 100644 --- a/lwgeom/lwcollection.c +++ b/lwgeom/lwcollection.c @@ -295,7 +295,8 @@ lwcollection_segmentize2d(LWCOLLECTION *col, double dist) char lwcollection_same(const LWCOLLECTION *c1, const LWCOLLECTION *c2) { - unsigned int i; + unsigned int i, j; + char *hit; #if DEBUG_CALLS lwnotice("lwcollection_same called"); @@ -304,10 +305,23 @@ lwcollection_same(const LWCOLLECTION *c1, const LWCOLLECTION *c2) if ( TYPE_GETTYPE(c1->type) != TYPE_GETTYPE(c2->type) ) return 0; if ( c1->ngeoms != c2->ngeoms ) return 0; + hit = (char *)lwalloc(sizeof(char)*c1->ngeoms); + memset(hit, 0, sizeof(char)*c1->ngeoms); + for (i=0; ingeoms; i++) { - if ( ! lwgeom_same(c1->geoms[i], c2->geoms[i]) ) - return 0; + char found=0; + for (j=0; jngeoms; j++) + { + if ( hit[j] ) continue; + if ( lwgeom_same(c1->geoms[i], c2->geoms[j]) ) + { + hit[j] = 1; + found=1; + break; + } + } + if ( ! found ) return 0; } return 1; } -- 2.40.0