Changeset: 9da6f9e3063d for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9da6f9e3063d
Added Files:
geom/sql/Tests/functions/Tests/XYZMinMax.sql
geom/sql/Tests/functions/Tests/XYZMinMax.stable.err
geom/sql/Tests/functions/Tests/XYZMinMax.stable.out
Modified Files:
geom/monetdb5/geom.c
geom/monetdb5/geom.mal
geom/monetdb5/geomBulk.c
geom/sql/Tests/functions/Tests/All
geom/sql/Tests/functions/Tests/ST_GeomFromText.stable.err
geom/sql/Tests/functions/Tests/ST_LineFromText.stable.err
geom/sql/Tests/functions/Tests/ST_MLineFromText.stable.err
geom/sql/Tests/functions/Tests/ST_MPointFromText.stable.err
geom/sql/Tests/functions/Tests/ST_MPolygonFromText.stable.err
geom/sql/Tests/functions/Tests/ST_MakeBox2D.stable.err
geom/sql/Tests/functions/Tests/ST_MakePoint.stable.err
geom/sql/Tests/functions/Tests/ST_NumPoints.stable.err
geom/sql/Tests/functions/Tests/ST_PointFromText.stable.err
geom/sql/Tests/functions/Tests/ST_PolygonFromText.stable.err
geom/sql/Tests/functions/Tests/XYZ.stable.err
Branch: geo
Log Message:
ST_XMin + ST_XMax + ST_YMin + ST_YMax : bulk + mtest
diffs (truncated from 1192 to 300 lines):
diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -2598,21 +2598,6 @@ str wkbGetCoordinate(double *out, wkb **
return MAL_SUCCEED;
}
-/*
-str wkbGetCoordX(double *out, wkb **geom) {
- return wkbGetCoord(out, geom, 0, "geom.X");
-}
-
-str wkbGetCoordY(double *out, wkb **geom) {
- return wkbGetCoord(out, geom, 1, "geom.Y");
-}
-
-// geos does not store more than 3 dimensions in wkb so this function
-// will never work unless we change geos
-str wkbGetCoordZ(double *out, wkb **geom) {
- return wkbGetCoord(out, geom, 2, "geom.Z");
-}
-*/
/*common code for functions that return geometry */
static str wkbBasic(wkb **out, wkb **geom, GEOSGeometry* (*func)(const
GEOSGeometry *), const char *name) {
@@ -4150,13 +4135,32 @@ str wkbNumGeometries(int* out, wkb** geo
/* Creates the mbr for the given geom_geometry. */
str wkbMBR(mbr **geomMBR, wkb **geomWKB) {
GEOSGeom geosGeometry = wkb2geos(*geomWKB);
+ str ret = MAL_SUCCEED;
+ bit out;
+
+ //check if the geometry is empty
+ if((ret = wkbIsEmpty(&out, geomWKB)) != MAL_SUCCEED) {
+ str msg = createException(MAL, "geom.wkbMBR", "%s", ret);
+ GDKfree(ret);
+
+ GEOSGeom_destroy(geosGeometry);
+
+ return msg;
+ }
+
+ if(out) {
+ GEOSGeom_destroy(geosGeometry);
+ *geomMBR = mbr_nil;
+ return MAL_SUCCEED;
+ }
+
*geomMBR = mbrFromGeos(geosGeometry);
- if(geosGeometry)
- GEOSGeom_destroy(geosGeometry);
- else if(mbr_isnil(*geomMBR))
+ GEOSGeom_destroy(geosGeometry);
+
+ if (mbr_isnil(*geomMBR))
throw(MAL, "wkb.mbr", "Failed to create mbr");
-
+
return MAL_SUCCEED;
}
@@ -4650,6 +4654,12 @@ str mbrDistance_wkb(double *out, wkb **g
/* get Xmin, Ymin, Xmax, Ymax coordinates of mbr */
str wkbCoordinateFromMBR(dbl* coordinateValue, mbr** geomMBR, int*
coordinateIdx) {
+ //check if the MBR is null
+ if(mbr_isnil(*geomMBR)) {
+ *coordinateValue = dbl_nil;
+ return MAL_SUCCEED;
+ }
+
switch(*coordinateIdx) {
case 1:
*coordinateValue = (*geomMBR)->xmin;
@@ -4673,9 +4683,30 @@ str wkbCoordinateFromMBR(dbl* coordinate
str wkbCoordinateFromWKB(dbl* coordinateValue, wkb** geomWKB, int*
coordinateIdx) {
mbr* geomMBR;
str ret = MAL_SUCCEED ;
+ bit out;
+
+ //check if the geometry is empty
+ if((ret = wkbIsEmpty(&out, geomWKB)) != MAL_SUCCEED) {
+ str msg = createException(MAL, "geom.wkbCoordinateFromWKB",
"%s", ret);
+ GDKfree(ret);
+ return msg;
+ }
+
+ if(out) {
+ *coordinateValue = dbl_nil;
+ return MAL_SUCCEED;
+ }
wkbMBR(&geomMBR, geomWKB);
- ret = wkbCoordinateFromMBR(coordinateValue, &geomMBR, coordinateIdx);
+ if((ret = wkbCoordinateFromMBR(coordinateValue, &geomMBR,
coordinateIdx)) != MAL_SUCCEED) {
+ str msg = createException(MAL, "geom.wkbCoordinateFromWKB",
"%s", ret);
+ GDKfree(ret);
+
+ if(geomMBR)
+ GDKfree(geomMBR);
+
+ return msg;
+ }
if(geomMBR)
GDKfree(geomMBR);
diff --git a/geom/monetdb5/geom.mal b/geom/monetdb5/geom.mal
--- a/geom/monetdb5/geom.mal
+++ b/geom/monetdb5/geom.mal
@@ -475,11 +475,9 @@ command mbrDistance(geom1:wkb, geom2:wkb
comment "Returns the distance of the centroids of the mbrs of the two
geometries";
command mbrDistance(box1:mbr, box2:mbr) :dbl address mbrDistance
comment "Returns the distance of the centroids of the two boxes";
+
command coordinateFromWKB(:wkb, :int) :dbl address wkbCoordinateFromWKB
comment "returns xmin (=1), ymin (=2), xmax (=3) or ymax(=4) of the provided
geometry";
-command coordinateFromMBR(:mbr, :int) :dbl address wkbCoordinateFromMBR
-comment "returns xmin (=1), ymin (=2), xmax (=3) or ymax(=4) of the provided
mbr";
-
function XMinFromWKB(g:wkb) :dbl;
x := coordinateFromWKB(g, 1);
return x;
@@ -496,6 +494,9 @@ function YMaxFromWKB(g:wkb) :dbl;
x := coordinateFromWKB(g, 4);
return x;
end YMaxFromWKB;
+
+command coordinateFromMBR(:mbr, :int) :dbl address wkbCoordinateFromMBR
+comment "returns xmin (=1), ymin (=2), xmax (=3) or ymax(=4) of the provided
mbr";
function XMinFromMBR(b:mbr) :dbl;
x := coordinateFromMBR(b, 1);
return x;
@@ -717,9 +718,6 @@ comment "Creates the mbr for the given w
command coordinateFromWKB(:bat[:oid,:wkb], :int) :bat[:oid,:dbl] address
wkbCoordinateFromWKB_bat
comment "returns xmin (=1), ymin (=2), xmax (=3) or ymax(=4) of the provided
geometry";
-command coordinateFromMBR(:bat[:oid,:mbr], :int) :bat[:oid,:dbl] address
wkbCoordinateFromMBR_bat
-comment "returns xmin (=1), ymin (=2), xmax (=3) or ymax(=4) of the provided
mbr";
-
function XMinFromWKB(g:bat[:oid,:wkb]) :bat[:oid,:dbl];
x := coordinateFromWKB(g, 1);
return x;
@@ -736,6 +734,9 @@ function YMaxFromWKB(g:bat[:oid,:wkb]) :
x := coordinateFromWKB(g, 4);
return x;
end YMaxFromWKB;
+
+command coordinateFromMBR(:bat[:oid,:mbr], :int) :bat[:oid,:dbl] address
wkbCoordinateFromMBR_bat
+comment "returns xmin (=1), ymin (=2), xmax (=3) or ymax(=4) of the provided
mbr";
function XMinFromMBR(b:bat[:oid,:mbr]) :bat[:oid,:dbl];
x := coordinateFromMBR(b, 1);
return x;
diff --git a/geom/monetdb5/geomBulk.c b/geom/monetdb5/geomBulk.c
--- a/geom/monetdb5/geomBulk.c
+++ b/geom/monetdb5/geomBulk.c
@@ -137,6 +137,61 @@ str wkbFromText_bat(bat *outBAT_id, bat
return MAL_SUCCEED;
}
+/*****************************************************************************/
+/********************* IN: mbr - OUT: double - FLAG :int *********************/
+/*****************************************************************************/
+str wkbCoordinateFromMBR_bat(int *outBAT_id, int *inBAT_id, int*
coordinateIdx) {
+ BAT *outBAT = NULL, *inBAT = NULL;
+ mbr *inMBR = NULL;
+ double outDbl = 0.0;
+ BUN p =0, q =0;
+ BATiter inBAT_iter;
+
+ //get the descriptor of the BAT
+ if ((inBAT = BATdescriptor(*inBAT_id)) == NULL) {
+ throw(MAL, "batgeom.coordinateFromMBR", RUNTIME_OBJECT_MISSING);
+ }
+
+ if ( inBAT->htype != TYPE_void ) { //header type of BAT not void
+ BBPreleaseref(inBAT->batCacheid);
+ throw(MAL, "batgeom.coordinateFromMBR", "the arguments must
have dense and aligned heads");
+ }
+
+ //create a new BAT for the output
+ if ((outBAT = BATnew(TYPE_void, ATOMindex("dbl"), BATcount(inBAT),
TRANSIENT)) == NULL) {
+ BBPreleaseref(inBAT->batCacheid);
+ throw(MAL, "batgeom.coordinateFromMBR", MAL_MALLOC_FAIL);
+ }
+ //set the first idx of the new BAT equal to that of the input BAT
+ BATseqbase(outBAT, inBAT->hseqbase);
+
+ //iterator over the BAT
+ inBAT_iter = bat_iterator(inBAT);
+ BATloop(inBAT, p, q) { //iterate over all valid elements
+ str err = NULL;
+
+ inMBR = (mbr*) BUNtail(inBAT_iter, p);
+ if ((err = wkbCoordinateFromMBR(&outDbl, &inMBR,
coordinateIdx)) != MAL_SUCCEED) {
+ str msg;
+ BBPreleaseref(inBAT->batCacheid);
+ BBPreleaseref(outBAT->batCacheid);
+ msg = createException(MAL, "batgeom.coordinateFromMBR",
"%s", err);
+ GDKfree(err);
+ return msg;
+ }
+ BUNappend(outBAT,&outDbl,TRUE);
+ }
+
+ //set some properties of the new BAT
+ BATsetcount(outBAT, BATcount(inBAT));
+ BATsettrivprop(outBAT);
+ BATderiveProps(outBAT,FALSE);
+ BBPreleaseref(inBAT->batCacheid);
+ BBPkeepref(*outBAT_id = outBAT->batCacheid);
+ return MAL_SUCCEED;
+
+}
+
/**************************************************************************/
/********************* IN: wkb - OUT: str - FLAG :int *********************/
/**************************************************************************/
@@ -1366,64 +1421,13 @@ str wkbMBR_bat(int* outBAT_id, int* inBA
//set some properties of the new BAT
BATsetcount(outBAT, BATcount(inBAT));
- BATsettrivprop(outBAT);
- BATderiveProps(outBAT,FALSE);
+ BATsettrivprop(outBAT);
+ BATderiveProps(outBAT,FALSE);
BBPreleaseref(inBAT->batCacheid);
BBPkeepref(*outBAT_id = outBAT->batCacheid);
return MAL_SUCCEED;
}
-str wkbCoordinateFromMBR_bat(int *outBAT_id, int *inBAT_id, int*
coordinateIdx) {
- BAT *outBAT = NULL, *inBAT = NULL;
- mbr *inMBR = NULL;
- double outDbl = 0.0;
- BUN p =0, q =0;
- BATiter inBAT_iter;
-
- //get the descriptor of the BAT
- if ((inBAT = BATdescriptor(*inBAT_id)) == NULL) {
- throw(MAL, "batgeom.coordinateFromMBR", RUNTIME_OBJECT_MISSING);
- }
-
- if ( inBAT->htype != TYPE_void ) { //header type of BAT not void
- BBPreleaseref(inBAT->batCacheid);
- throw(MAL, "batgeom.coordinateFromMBR", "the arguments must
have dense and aligned heads");
- }
-
- //create a new BAT for the output
- if ((outBAT = BATnew(TYPE_void, ATOMindex("dbl"), BATcount(inBAT),
TRANSIENT)) == NULL) {
- BBPreleaseref(inBAT->batCacheid);
- throw(MAL, "batgeom.coordinateFromMBR", MAL_MALLOC_FAIL);
- }
- //set the first idx of the new BAT equal to that of the input BAT
- BATseqbase(outBAT, inBAT->hseqbase);
-
- //iterator over the BAT
- inBAT_iter = bat_iterator(inBAT);
- BATloop(inBAT, p, q) { //iterate over all valid elements
- str err = NULL;
-
- inMBR = (mbr*) BUNtail(inBAT_iter, p);
- if ((err = wkbCoordinateFromMBR(&outDbl, &inMBR,
coordinateIdx)) != MAL_SUCCEED) {
- str msg;
- BBPreleaseref(inBAT->batCacheid);
- BBPreleaseref(outBAT->batCacheid);
- msg = createException(MAL, "batgeom.coordinateFromMBR",
"%s", err);
- GDKfree(err);
- return msg;
- }
- BUNappend(outBAT,&outDbl,TRUE);
- }
-
- //set some properties of the new BAT
- BATsetcount(outBAT, BATcount(inBAT));
- BATsettrivprop(outBAT);
- BATderiveProps(outBAT,FALSE);
- BBPreleaseref(inBAT->batCacheid);
- BBPkeepref(*outBAT_id = outBAT->batCacheid);
- return MAL_SUCCEED;
-
-}
str wkbCoordinateFromWKB_bat(int *outBAT_id, int *inBAT_id, int*
coordinateIdx) {
str err = NULL;
diff --git a/geom/sql/Tests/functions/Tests/All
b/geom/sql/Tests/functions/Tests/All
--- a/geom/sql/Tests/functions/Tests/All
+++ b/geom/sql/Tests/functions/Tests/All
@@ -25,6 +25,7 @@ ST_IsValid #ignores Z coordinate
ST_IsRing #ignores Z coordinate
XYZ
+XYZMinMax
#srid
ST_GeometryN
ST_NumGeometries
diff --git a/geom/sql/Tests/functions/Tests/ST_GeomFromText.stable.err
b/geom/sql/Tests/functions/Tests/ST_GeomFromText.stable.err
--- a/geom/sql/Tests/functions/Tests/ST_GeomFromText.stable.err
+++ b/geom/sql/Tests/functions/Tests/ST_GeomFromText.stable.err
@@ -29,184 +29,184 @@ stderr of test 'ST_GeomFromText` in dire
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list