Add lwgeom_normalize in LIBLWGEOM, use in cu_buildarea tester

git-svn-id: http://svn.osgeo.org/postgis/trunk@9742 b70326c6-7e19-0410-871a-916f4a2858ee
This commit is contained in:
Sandro Santilli 2012-05-17 11:45:26 +00:00
parent 0ab4b2b096
commit a9ec4df52a
4 changed files with 53 additions and 4 deletions

1
NEWS
View file

@ -26,6 +26,7 @@ PostGIS 2.0.1
- #1786, improved build dependencies
- #1802, improved function interruptibility.
- #1806, speedup of ST_BuildArea, ST_MakeValid and ST_GetFaceGeometry.
- Add lwgeom_normalize in LIBLWGEOM
PostGIS 2.0.0
2012/04/03

View file

@ -22,15 +22,22 @@
*/
#define check_geom_equal(gobt, gexp) do { \
char *obt, *exp; \
if ( ! lwgeom_same((gobt), (gexp)) ) { \
obt = lwgeom_to_wkt((gobt), WKT_ISO, 8, NULL); \
exp = lwgeom_to_wkt((gexp), WKT_ISO, 8, NULL); \
LWGEOM *ngobt, *ngexp; \
ngobt = lwgeom_normalize(gobt); \
ngexp = lwgeom_normalize(gexp); \
if ( ! lwgeom_same((ngobt), (ngexp)) ) { \
obt = lwgeom_to_wkt((ngobt), WKT_ISO, 8, NULL); \
exp = lwgeom_to_wkt((ngexp), WKT_ISO, 8, NULL); \
printf(" Failure at %s:%d\n", __FILE__, __LINE__); \
printf(" Exp: %s\n", exp); \
printf(" Obt: %s\n", obt); \
free(obt); free(exp); \
lwgeom_free(ngobt); lwgeom_free(ngexp); \
CU_ASSERT(0); \
} else CU_ASSERT(1); \
} else { \
lwgeom_free(ngobt); lwgeom_free(ngexp); \
CU_ASSERT(1); \
} \
} while (0)
/*

View file

@ -1808,6 +1808,7 @@ const char* lwgeom_geos_version(void);
/** Convert an LWGEOM to a GEOS Geometry and convert back -- for debug only */
LWGEOM* lwgeom_geos_noop(const LWGEOM *geom) ;
LWGEOM *lwgeom_normalize(const LWGEOM *geom);
LWGEOM *lwgeom_intersection(const LWGEOM *geom1, const LWGEOM *geom2);
LWGEOM *lwgeom_difference(const LWGEOM *geom1, const LWGEOM *geom2);
LWGEOM *lwgeom_symdifference(const LWGEOM* geom1, const LWGEOM* geom2);

View file

@ -416,6 +416,46 @@ lwgeom_geos_version()
return ver;
}
LWGEOM *
lwgeom_normalize(const LWGEOM *geom1)
{
LWGEOM *result ;
GEOSGeometry *g1;
int is3d ;
int srid ;
srid = (int)(geom1->srid);
is3d = FLAGS_GET_Z(geom1->flags);
initGEOS(lwnotice, lwgeom_geos_error);
g1 = LWGEOM2GEOS(geom1);
if ( 0 == g1 ) /* exception thrown at construction */
{
lwerror("First argument geometry could not be converted to GEOS.");
return NULL ;
}
if ( -1 == GEOSNormalize(g1) )
{
lwerror("Error in GEOSNormalize: %s", lwgeom_geos_errmsg);
return NULL; /* never get here */
}
GEOSSetSRID(g1, srid); /* needed ? */
result = GEOS2LWGEOM(g1, is3d);
GEOSGeom_destroy(g1);
if (result == NULL)
{
lwerror("Error performing intersection: GEOS2LWGEOM: %s",
lwgeom_geos_errmsg);
return NULL ; /* never get here */
}
return result ;
}
LWGEOM *
lwgeom_intersection(const LWGEOM *geom1, const LWGEOM *geom2)
{