Changeset: 645ad60c4cfb for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=645ad60c4cfb Modified Files: geom/lib/libgeom.h geom/monetdb5/geom.c Branch: geo Log Message:
updated how wkb nil values are created diffs (truncated from 685 to 300 lines): diff --git a/geom/lib/libgeom.h b/geom/lib/libgeom.h --- a/geom/lib/libgeom.h +++ b/geom/lib/libgeom.h @@ -134,7 +134,7 @@ libgeom_export void libgeom_exit(void); * On failure, returns NULL. */ //#define wkb2geos( geom ) wkb_isnil((geom))? NULL: GEOSGeomFromWKB_buf((unsigned char *)((geom)->data), (geom)->len) -#define wkb_nil geos2wkb(NULL); +//#define wkb_nil geos2wkb(NULL); #define mbr_nil mbrFromGeos(NULL); libgeom_export int wkb_isnil(wkb *wkbp); diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c --- a/geom/monetdb5/geom.c +++ b/geom/monetdb5/geom.c @@ -18,6 +18,7 @@ int TYPE_mbr; static inline int geometryHasZ(int info){return (info & 0x02);} static inline int geometryHasM(int info){return (info & 0x01);} const double pi=3.14159265358979323846; +static wkb wkb_nil = {0, ~0}; /* the first argument in the functions is the return variable */ @@ -343,7 +344,7 @@ str wkbTransform(wkb** transformedWKB, w if(*geomWKB == NULL) { - *transformedWKB = wkb_nil; + *transformedWKB = wkbNULL(); pj_free(proj4_src); pj_free(proj4_dst); throw(MAL, "geom.Transform", "wkb is null"); @@ -385,7 +386,7 @@ str wkbTransform(wkb** transformedWKB, w /* destroy the geos geometries */ GEOSGeom_destroy(transformedGeosGeometry); } else - *transformedWKB = wkb_nil; + *transformedWKB = wkbNULL(); pj_free(proj4_src); pj_free(proj4_dst); @@ -645,20 +646,20 @@ str wkbForceDim(wkb** outWKB, wkb** geom str err; if(wkb_isnil(*geomWKB)){ - *outWKB = wkb_nil; + *outWKB = wkbNULL(); return MAL_SUCCEED; } geosGeometry = wkb2geos(*geomWKB); if(!geosGeometry) { - *outWKB = wkb_nil; + *outWKB = wkbNULL(); return createException(MAL, "geom.ForceDim", "wkb2geos failed"); } if((err = forceDimGeometry(&outGeometry, geosGeometry, *dim)) != MAL_SUCCEED) { str msg = createException(MAL, "geom.ForceDim", "%s", err); GEOSGeom_destroy(geosGeometry); - *outWKB = wkb_nil; + *outWKB = wkbNULL(); GDKfree(err); return msg; @@ -978,20 +979,20 @@ str wkbSegmentize(wkb** outWKB, wkb** ge str err; if(wkb_isnil(*geomWKB)){ - *outWKB = wkb_nil; + *outWKB = wkbNULL(); return MAL_SUCCEED; } geosGeometry = wkb2geos(*geomWKB); if(!geosGeometry) { - *outWKB = wkb_nil; + *outWKB = wkbNULL(); return createException(MAL, "geom.Segmentize", "wkb2geos failed"); } if((err = segmentizeGeometry(&outGeometry, geosGeometry, *sz)) != MAL_SUCCEED) { str msg = createException(MAL, "geom.Segmentize", "%s", err); GEOSGeom_destroy(geosGeometry); - *outWKB = wkb_nil; + *outWKB = wkbNULL(); GDKfree(err); return msg; @@ -1268,20 +1269,20 @@ str wkbTranslate(wkb** outWKB, wkb** geo str err; if(wkb_isnil(*geomWKB)){ - *outWKB = wkb_nil; + *outWKB = wkbNULL(); return MAL_SUCCEED; } geosGeometry = wkb2geos(*geomWKB); if(!geosGeometry) { - *outWKB = wkb_nil; + *outWKB = wkbNULL(); return createException(MAL, "geom.Translate", "wkb2geos failed"); } if((err = translateGeometry(&outGeometry, geosGeometry, *dx, *dy, *dz)) != MAL_SUCCEED) { str msg = createException(MAL, "geom.Translate", "%s", err); GEOSGeom_destroy(geosGeometry); - *outWKB = wkb_nil; + *outWKB = wkbNULL(); GDKfree(err); return msg; @@ -1306,7 +1307,7 @@ str wkbDelaunayTriangles(wkb** outWKB, w geosGeometry = wkb2geos(*geomWKB); if(!(outGeometry = GEOSDelaunayTriangulation(geosGeometry, *tolerance, *flag))) { - *outWKB = wkb_nil; + *outWKB = wkbNULL(); GEOSGeom_destroy(geosGeometry); return createException(MAL, "geom.DelaunayTriangles", "GEOSDelaunayTriangulation failed"); } @@ -1324,19 +1325,19 @@ str wkbPointOnSurface(wkb** resWKB, wkb* GEOSGeom geosGeometry, resGeosGeometry; if(wkb_isnil(*geomWKB)){ - *resWKB = wkb_nil; + *resWKB = wkbNULL(); return MAL_SUCCEED; } geosGeometry = wkb2geos(*geomWKB); if(!geosGeometry) { - *resWKB = wkb_nil; + *resWKB = wkbNULL(); throw(MAL, "geom.PointOnSurface", "wkb2geos failed"); } resGeosGeometry = GEOSPointOnSurface(geosGeometry); if(!resGeosGeometry) { - *resWKB = wkb_nil; + *resWKB = wkbNULL(); throw(MAL, "geom.PointOnSurface", "GEOSPointOnSurface failed"); } @@ -1906,7 +1907,7 @@ static int wkbFROMSTR_withSRID(char* geo size_t parsedCharacters = 0; if (strcmp(geomWKT, str_nil) == 0) { - *geomWKB = wkb_nil; + *geomWKB = wkbNULL(); return 0; } //check whether the represenattion is binary (hex) @@ -1943,13 +1944,13 @@ static int wkbFROMSTR_withSRID(char* geo GEOSWKTReader_destroy(WKT_reader); if(geosGeometry == NULL){ - *geomWKB = wkb_nil; + *geomWKB = wkbNULL(); return 0; } if (GEOSGeomTypeId(geosGeometry) == -1) { GEOSGeom_destroy(geosGeometry); - *geomWKB = wkb_nil; + *geomWKB = wkbNULL(); return 0; } @@ -2253,7 +2254,7 @@ str wkbFromText(wkb **geomWKB, str *geom *geomWKB = NULL; if (strcmp(*geomWKT, str_nil) == 0) { - *geomWKB = wkb_nil; + *geomWKB = wkbNULL(); return MAL_SUCCEED; } if (wkbFROMSTR_withSRID(*geomWKT, &len, geomWKB, *srid) && @@ -2262,7 +2263,7 @@ str wkbFromText(wkb **geomWKB, str *geom } if (*geomWKB == NULL) { - *geomWKB = wkb_nil; + *geomWKB = wkbNULL(); } te += (te>2); @@ -2350,7 +2351,7 @@ str wkbMLineStringToPolygon(wkb** geomWK if(ret != MAL_SUCCEED) { str msg = createException(MAL, "geom.MLineStringToPolygon: ", "%s", ret); - *geomWKB = wkb_nil; + *geomWKB = wkbNULL(); GDKfree(ret); if(inputWKB) @@ -2363,7 +2364,7 @@ str wkbMLineStringToPolygon(wkb** geomWK if(ret != MAL_SUCCEED) { str msg = createException(MAL, "geom.MLineStringToPolygon: ", "%s", ret); - *geomWKB = wkb_nil; + *geomWKB = wkbNULL(); GDKfree(ret); return msg; @@ -2380,7 +2381,7 @@ str wkbMLineStringToPolygon(wkb** geomWK if(ret != MAL_SUCCEED || !linestringsWKB[i-1]) { str msg = createException(MAL, "geom.MLineStringToPolygon: ", "%s", ret); - *geomWKB = wkb_nil; + *geomWKB = wkbNULL(); GDKfree(ret); GDKfree(inputWKB); @@ -2396,7 +2397,7 @@ str wkbMLineStringToPolygon(wkb** geomWK if(ret != MAL_SUCCEED) { str msg = createException(MAL, "geom.MLineStringToPolygon: ", "%s", ret); - *geomWKB = wkb_nil; + *geomWKB = wkbNULL(); GDKfree(ret); GDKfree(inputWKB); @@ -2413,7 +2414,7 @@ str wkbMLineStringToPolygon(wkb** geomWK if(ret != MAL_SUCCEED) { str msg = createException(MAL, "geom.MLineStringToPolygon: ", "%s", ret); - *geomWKB = wkb_nil; + *geomWKB = wkbNULL(); GDKfree(ret); GDKfree(inputWKB); @@ -2466,7 +2467,7 @@ str wkbMLineStringToPolygon(wkb** geomWK externalGeometry = wkb2geos(linestringsWKB[0]); if(!externalGeometry) { - *geomWKB = wkb_nil; + *geomWKB = wkbNULL(); throw(MAL, "geom.MLineStringToPolygon", "Error in wkb2geos"); } @@ -2481,7 +2482,7 @@ str wkbMLineStringToPolygon(wkb** geomWK internalGeometry = wkb2geos(linestringsWKB[i]); if(!internalGeometry) { - *geomWKB = wkb_nil; + *geomWKB = wkbNULL(); throw(MAL, "geom.MLineStringToPolygon", "Error in wkb2geos"); } @@ -2495,7 +2496,7 @@ str wkbMLineStringToPolygon(wkb** geomWK for(i=0; i<itemsNum; i++) GEOSGeom_destroy(internalGeometries[i]); GDKfree(internalGeometries); - *geomWKB = wkb_nil; + *geomWKB = wkbNULL(); throw(MAL, "geom.MLineStringToPolygon", "Error creating Polygon from LinearRing"); } @@ -2508,7 +2509,7 @@ str wkbMLineStringToPolygon(wkb** geomWK GEOSGeom_destroy(finalGeometry); GDKfree(internalGeometries); - *geomWKB = wkb_nil; + *geomWKB = wkbNULL(); throw(MAL, "geom.MLineStringToPolygon", "The provided MultiLineString does not create a valid Polygon"); } @@ -2519,10 +2520,10 @@ str wkbMLineStringToPolygon(wkb** geomWK GEOSGeom_destroy(finalGeometry); GDKfree(internalGeometries); } else if(*flag == 1) { - *geomWKB = wkb_nil; + *geomWKB = wkbNULL(); throw(MAL, "geom.MLineStringToPolygon", "Multipolygon from string has not been defined"); } else { - *geomWKB = wkb_nil; + *geomWKB = wkbNULL(); throw(MAL, "geom.MLineStringToPolygon", "Uknown flag"); } @@ -2538,7 +2539,7 @@ str wkbMakePoint(wkb** out, dbl *x, dbl GEOSCoordSequence *seq = NULL; if (*x == dbl_nil || *y == dbl_nil) { - *out = wkb_nil; + *out = wkbNULL(); return MAL_SUCCEED; } @@ -2555,7 +2556,7 @@ str wkbMakePoint(wkb** out, dbl *x, dbl if(*zmFlag == 10) { if(*z == dbl_nil) { - *out = wkb_nil; + *out = wkbNULL(); GEOSCoordSeq_destroy(seq); return MAL_SUCCEED; } _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list