- #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
*/
#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)
/*
/** 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);
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)
{