Changeset: 16768f8da2f9 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=16768f8da2f9 Modified Files: geom/monetdb5/geom.c geom/monetdb5/geom.h geom/monetdb5/geom.mal geom/monetdb5/geomBulk.c Branch: sfcgal Log Message:
Add bulk version for AsX3D diffs (116 lines): diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c --- a/geom/monetdb5/geom.c +++ b/geom/monetdb5/geom.c @@ -3813,7 +3813,7 @@ wkbNumRings(int *out, wkb **geom, int *e //check if the geometry is empty if ((ret = wkbIsEmpty(&empty, geom)) != MAL_SUCCEED) { - return ret; + return ret; } if (empty) { //the geometry is empty @@ -6396,10 +6396,22 @@ wkbContains_point(bit *out, wkb **a, dbl str wkbAsX3D(str *res, wkb **geomWKB, int *maxDecDigits, int *option) { + str ret = MAL_SUCCEED; static const char* default_defid = "x3d:"; /* default defid */ const char* defid = default_defid; GEOSGeom geom = wkb2geos(*geomWKB); int srid = (*geomWKB)->srid; + bit empty; + + //check if the geometry is empty + if ((ret = wkbIsEmpty(&empty, geomWKB)) != MAL_SUCCEED) { + return ret; + } + if (empty) { + //the geometry is empty + (*res) = NULL; + return MAL_SUCCEED; + } if (*option & GEOM_X3D_USE_GEOCOORDS) { if (srid != 4326) { diff --git a/geom/monetdb5/geom.h b/geom/monetdb5/geom.h --- a/geom/monetdb5/geom.h +++ b/geom/monetdb5/geom.h @@ -325,6 +325,7 @@ geom_export str bbox3DFromGeos(bbox3D ** geom_export char *geom_to_geojson(GEOSGeom geom, char *srs, int precision, int has_bbox); geom_export char *geom_to_x3d_3(GEOSGeom geom, int precision, int opts, const char *defid); geom_export str wkbAsX3D(str *res, wkb **geom, int *maxDecDigits, int *options); +geom_export str wkbAsX3D_bat(bat *outBAT_id, bat *inBAT_id, int *maxDecDigits, int *options); geom_export str wkbAsGeoJson(str *res, wkb **geom, int *maxDecDigits, int *options); geom_export str wkbPatchToGeom(wkb **res, wkb **geom, dbl* px, dbl*py, dbl*pz); geom_export str wkbPatchToGeom_bat(wkb **res, wkb **geom, bat* px, bat* py, bat* pz); diff --git a/geom/monetdb5/geom.mal b/geom/monetdb5/geom.mal --- a/geom/monetdb5/geom.mal +++ b/geom/monetdb5/geom.mal @@ -814,3 +814,7 @@ command PatchToGeom(geom:wkb, x:bat[:oid address wkbPachToGeom_bat comment "Return the geometry with the z values rounded to the closest value at the vertexes."; +module batgeom; +command asX3D(geom:bat[:oid,:wkb], maxDecDigits:int, options:int) :bat[:oid,:str] address wkbAsX3D_bat +comment "Returns a Geometry in X3D xml node element format: ISO-IEC-19776-1.2-X3DEncodings-XML"; + diff --git a/geom/monetdb5/geomBulk.c b/geom/monetdb5/geomBulk.c --- a/geom/monetdb5/geomBulk.c +++ b/geom/monetdb5/geomBulk.c @@ -1526,3 +1526,55 @@ wkbUnion_bat(bat *outBAT_id, bat *aBAT_i return MAL_SUCCEED; } + +/* sets the srid of the geometry - BULK version*/ +str +wkbAsX3D_bat(bat *outBAT_id, bat *inBAT_id, int *maxDecDigits, int *options) +{ + BAT *outBAT = NULL, *inBAT = NULL; + BUN p = 0, q = 0; + BATiter inBAT_iter; + + //get the descriptor of the BAT + if ((inBAT = BATdescriptor(*inBAT_id)) == NULL) { + throw(MAL, "batgeom.SetSRID", "Problem retrieving BAT"); + } + + if (!BAThdense(inBAT)) { + BBPunfix(inBAT->batCacheid); + throw(MAL, "batgeom.SetSRID", "The BAT must have dense head"); + } + //create a new BAT for the output + if ((outBAT = BATnew(TYPE_void, ATOMindex("str"), BATcount(inBAT), TRANSIENT)) == NULL) { + BBPunfix(inBAT->batCacheid); + throw(MAL, "batgeom.SetSRID", "Error creating new BAT"); + } + //set the first idx of the output BAT equal to that of the input BAT + BATseqbase(outBAT, inBAT->hseqbase); + + //iterator over the BATs + inBAT_iter = bat_iterator(inBAT); + BATloop(inBAT, p, q) { + str err = NULL; + str outWKB = NULL; + + wkb *inWKB = (wkb *) BUNtail(inBAT_iter, p); + + if ((err = wkbAsX3D(&outWKB, &inWKB, maxDecDigits, options)) != MAL_SUCCEED) { //set SRID + BBPunfix(inBAT->batCacheid); + BBPunfix(outBAT->batCacheid); + return err; + } + if (outWKB) { + BUNappend(outBAT, outWKB, TRUE); //add the point to the new BAT + GDKfree(outWKB); + outWKB = NULL; + } + } + + BBPunfix(inBAT->batCacheid); + BBPkeepref(*outBAT_id = outBAT->batCacheid); + + return MAL_SUCCEED; +} + _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list