[prev in list] [next in list] [prev in thread] [next in thread]
List: monetdb-checkins
Subject: MonetDB: geo - ST_NumGeometries + ST_GeometryN : bulk + mtest
From: Foteini Alvanaki <commits () monetdb ! org>
Date: 2015-01-29 12:36:54
Message-ID: hg.349d7ab151d0.1422535014.6315528441665844383 () monetdb2 ! cwi-incubator ! nl
[Download RAW message or body]
Changeset: 349d7ab151d0 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=349d7ab151d0
Added Files:
geom/sql/Tests/functions/Tests/ST_GeometryN.sql
geom/sql/Tests/functions/Tests/ST_GeometryN.stable.err
geom/sql/Tests/functions/Tests/ST_GeometryN.stable.out
geom/sql/Tests/functions/Tests/ST_NumGeometries.sql
geom/sql/Tests/functions/Tests/ST_NumGeometries.stable.err
geom/sql/Tests/functions/Tests/ST_NumGeometries.stable.out
Removed Files:
geom/sql/Tests/functions/Tests/geometryN.sql
geom/sql/Tests/functions/Tests/geometryN.stable.err
geom/sql/Tests/functions/Tests/geometryN.stable.out
geom/sql/Tests/functions/Tests/numGeometries.sql
geom/sql/Tests/functions/Tests/numGeometries.stable.err
geom/sql/Tests/functions/Tests/numGeometries.stable.out
Modified Files:
geom/monetdb5/geom.c
geom/monetdb5/geom.h
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
Branch: geo
Log Message:
ST_NumGeometries + ST_GeometryN : bulk + mtest
diffs (truncated from 1538 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
@@ -4800,7 +4800,7 @@ size_t wkbFROMSTR(char* geomWKT, size_t*
//check whether the geometry type is polyhedral surface
//geos cannot handle this type of geometry but since it is
- //a special type of multipolygon I jsu change the type before
+ //a special type of multipolygon I just change the type before
//continuing. Of course this means that isValid for example does
//not work correctly.
typeSize = strlen(polyhedralSurface);
diff --git a/geom/monetdb5/geom.h b/geom/monetdb5/geom.h
--- a/geom/monetdb5/geom.h
+++ b/geom/monetdb5/geom.h
@@ -217,7 +217,10 @@ geom_export str wkbSymDifference(wkb **o
geom_export str wkbBuffer(wkb **out, wkb **geom, dbl *distance);
geom_export str wkbGeometryN(wkb** out, wkb** geom, int* geometryNum);
+geom_export str wkbGeometryN_bat(bat *outBAT_id, bat *inBAT_id, int* flag);
+
geom_export str wkbNumGeometries(int* out, wkb** geom);
+geom_export str wkbNumGeometries_bat(bat *outBAT_id, bat *inBAT_id);
geom_export str wkbTransform(wkb**, wkb**, int*, int*, char**, char**);
geom_export str wkbTranslate(wkb**, wkb**, double*, double*, double*);
diff --git a/geom/monetdb5/geom.mal b/geom/monetdb5/geom.mal
--- a/geom/monetdb5/geom.mal
+++ b/geom/monetdb5/geom.mal
@@ -633,6 +633,13 @@ function NPoints(w:bat[:oid,:wkb]) :bat[
end NPoints;
+
+command GeometryN(w:bat[:oid,:wkb], n:int) :bat[:oid,:wkb] address wkbGeometryN_bat
+comment "Returns the 1-based Nth geometry if the geometry is a GEOMETRYCOLLECTION, \
(MULTI)POINT, (MULTI)LINESTRING, MULTICURVE or (MULTI)POLYGON. Otherwise, return \
NULL"; +command NumGeometries(w:bat[:oid,:wkb]) :bat[:oid,:int] address \
wkbNumGeometries_bat +comment "Returns the number of geometries";
+
+
command Boundary(w:bat[:oid,:wkb]) :bat[:oid,:wkb] address wkbBoundary_bat;
command IsClosed(w:bat[:oid,:wkb]) :bat[:oid,:bit] address wkbIsClosed_bat;
diff --git a/geom/monetdb5/geomBulk.c b/geom/monetdb5/geomBulk.c
--- a/geom/monetdb5/geomBulk.c
+++ b/geom/monetdb5/geomBulk.c
@@ -140,7 +140,7 @@ str wkbFromText_bat(bat *outBAT_id, bat
/**************************************************************************/
/********************* IN: wkb - OUT: str - FLAG :int *********************/
/**************************************************************************/
-static str wkbStrOutWithFlag_bat(bat *outBAT_id, bat *inBAT_id, int* flag, str \
(*func)(char**, wkb**, int*), const char *name) { +static str WKBtoSTRflagINT_bat(bat \
*outBAT_id, bat *inBAT_id, int* flag, str (*func)(char**, wkb**, int*), const char \
*name) { BAT *outBAT = NULL, *inBAT = NULL;
wkb *inWKB = NULL;
BUN p =0, q =0;
@@ -196,17 +196,17 @@ static str wkbStrOutWithFlag_bat(bat *ou
/*create textual representation of the wkb */
str wkbAsText_bat(bat *outBAT_id, bat *inBAT_id, int* withSRID) {
- return wkbStrOutWithFlag_bat(outBAT_id, inBAT_id, withSRID, wkbAsText, \
"batgeom.wkbAsText"); + return WKBtoSTRflagINT_bat(outBAT_id, inBAT_id, withSRID, \
wkbAsText, "batgeom.wkbAsText"); }
str wkbGeometryType_bat(bat *outBAT_id, bat *inBAT_id, int* flag) {
- return wkbStrOutWithFlag_bat(outBAT_id, inBAT_id, flag, wkbGeometryType, \
"batgeom.wkbGeometryType"); + return WKBtoSTRflagINT_bat(outBAT_id, inBAT_id, flag, \
wkbGeometryType, "batgeom.wkbGeometryType"); }
/***************************************************************************/
/*************************** IN: wkb - OUT: wkb ****************************/
/***************************************************************************/
-str wkbBoundary_bat(bat *outBAT_id, bat *inBAT_id) {
+static str WKBtoWKB_bat(bat *outBAT_id, bat *inBAT_id, str (*func)(wkb**, wkb**), \
const char *name) { BAT *outBAT = NULL, *inBAT = NULL;
wkb *inWKB = NULL;
BUN p =0, q =0;
@@ -214,18 +214,18 @@ str wkbBoundary_bat(bat *outBAT_id, bat
//get the descriptor of the BAT
if ((inBAT = BATdescriptor(*inBAT_id)) == NULL) {
- throw(MAL, "batgeom.wkbBoundary", RUNTIME_OBJECT_MISSING);
+ throw(MAL, name, RUNTIME_OBJECT_MISSING);
}
if ( inBAT->htype != TYPE_void ) { //header type of BAT not void
BBPreleaseref(inBAT->batCacheid);
- throw(MAL, "batgeom.wkbBoundary", "The arguments must have dense and aligned \
heads"); + throw(MAL, name, "The arguments must have dense and aligned heads");
}
//create a new for the output BAT
if ((outBAT = BATnew(TYPE_void, ATOMindex("wkb"), BATcount(inBAT), TRANSIENT)) == \
NULL) { BBPreleaseref(inBAT->batCacheid);
- throw(MAL, "batgeom.wkbBoundary", MAL_MALLOC_FAIL);
+ throw(MAL, name, MAL_MALLOC_FAIL);
}
//set the first idx of the new BAT equal to that of the input BAT
BATseqbase(outBAT, inBAT->hseqbase);
@@ -237,8 +237,8 @@ str wkbBoundary_bat(bat *outBAT_id, bat
wkb* outSingle;
inWKB = (wkb*) BUNtail(inBAT_iter, p);
- if ((err = wkbBoundary(&outSingle, &inWKB)) != MAL_SUCCEED) {
- str msg = createException(MAL, "batgeom.wkbBoundary", "%s", err);
+ if ((err = (*func)(&outSingle, &inWKB)) != MAL_SUCCEED) {
+ str msg = createException(MAL, name, "%s", err);
GDKfree(err);
BBPreleaseref(inBAT->batCacheid);
@@ -260,11 +260,78 @@ str wkbBoundary_bat(bat *outBAT_id, bat
return MAL_SUCCEED;
}
+str wkbBoundary_bat(bat *outBAT_id, bat *inBAT_id) {
+ return WKBtoWKB_bat(outBAT_id, inBAT_id, wkbBoundary, "batgeom.wkbBoundary");
+}
+
+
+/**************************************************************************************/
+/*************************** IN: wkb - OUT: wkb - FLAG:int \
****************************/ \
+/**************************************************************************************/
+
+static str WKBtoWKBflagINT_bat(bat *outBAT_id, bat *inBAT_id, int* flag, str \
(*func)(wkb**, wkb**, int*), const char *name) { + BAT *outBAT = NULL, *inBAT = NULL;
+ wkb *inWKB = NULL;
+ BUN p =0, q =0;
+ BATiter inBAT_iter;
+
+ //get the descriptor of the BAT
+ if ((inBAT = BATdescriptor(*inBAT_id)) == NULL) {
+ throw(MAL, name, RUNTIME_OBJECT_MISSING);
+ }
+
+ if ( inBAT->htype != TYPE_void ) { //header type of BAT not void
+ BBPreleaseref(inBAT->batCacheid);
+ throw(MAL, name, "The arguments must have dense and aligned heads");
+ }
+
+ //create a new for the output BAT
+ if ((outBAT = BATnew(TYPE_void, ATOMindex("wkb"), BATcount(inBAT), TRANSIENT)) == \
NULL) { + BBPreleaseref(inBAT->batCacheid);
+ throw(MAL, name, 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 input BAT
+ inBAT_iter = bat_iterator(inBAT);
+ BATloop(inBAT, p, q) { //iterate over all valid elements
+ str err = NULL;
+ wkb* outSingle;
+
+ inWKB = (wkb*) BUNtail(inBAT_iter, p);
+ if ((err = (*func)(&outSingle, &inWKB, flag)) != MAL_SUCCEED) {
+ str msg = createException(MAL, name, "%s", err);
+ GDKfree(err);
+
+ BBPreleaseref(inBAT->batCacheid);
+ BBPreleaseref(outBAT->batCacheid);
+
+ return msg;
+ }
+ BUNappend(outBAT,outSingle,TRUE); //add the result to the new BAT
+ GDKfree(outSingle);
+ outSingle = NULL;
+ }
+
+ //set the number of elements in the outBAT
+ BATsetcount(outBAT, BATcount(inBAT));
+
+ BBPreleaseref(inBAT->batCacheid);
+ BBPkeepref(*outBAT_id = outBAT->batCacheid);
+
+ return MAL_SUCCEED;
+}
+
+str wkbGeometryN_bat(bat *outBAT_id, bat *inBAT_id, int* flag) {
+ return WKBtoWKBflagINT_bat(outBAT_id, inBAT_id, flag, wkbGeometryN, \
"batgeom.wkbGeometryN"); +}
+
/***************************************************************************/
/*************************** IN: wkb - OUT: bit ****************************/
/***************************************************************************/
-static str wkbBitOut_bat(bat *outBAT_id, bat *inBAT_id, str (*func)(bit*, wkb**), \
const char *name) { +static str WKBtoBIT_bat(bat *outBAT_id, bat *inBAT_id, str \
(*func)(bit*, wkb**), const char *name) { BAT *outBAT = NULL, *inBAT = NULL;
wkb *inWKB = NULL;
BUN p =0, q =0;
@@ -318,19 +385,19 @@ static str wkbBitOut_bat(bat *outBAT_id,
}
str wkbIsClosed_bat(bat *outBAT_id, bat *inBAT_id) {
- return wkbBitOut_bat(outBAT_id, inBAT_id, wkbIsClosed, "batgeom.wkbIsClosed");
+ return WKBtoBIT_bat(outBAT_id, inBAT_id, wkbIsClosed, "batgeom.wkbIsClosed");
}
str wkbIsEmpty_bat(bat *outBAT_id, bat *inBAT_id) {
- return wkbBitOut_bat(outBAT_id, inBAT_id, wkbIsEmpty, "batgeom.wkbIsEmpty");
+ return WKBtoBIT_bat(outBAT_id, inBAT_id, wkbIsEmpty, "batgeom.wkbIsEmpty");
}
str wkbIsSimple_bat(bat *outBAT_id, bat *inBAT_id) {
- return wkbBitOut_bat(outBAT_id, inBAT_id, wkbIsSimple, "batgeom.wkbIsSimple");
+ return WKBtoBIT_bat(outBAT_id, inBAT_id, wkbIsSimple, "batgeom.wkbIsSimple");
}
str wkbIsRing_bat(bat *outBAT_id, bat *inBAT_id) {
- return wkbBitOut_bat(outBAT_id, inBAT_id, wkbIsRing, "batgeom.wkbIsRing");
+ return WKBtoBIT_bat(outBAT_id, inBAT_id, wkbIsRing, "batgeom.wkbIsRing");
}
str wkbIsValid_bat(bat *outBAT_id, bat *inBAT_id) {
- return wkbBitOut_bat(outBAT_id, inBAT_id, wkbIsValid, "batgeom.wkbIsValid");
+ return WKBtoBIT_bat(outBAT_id, inBAT_id, wkbIsValid, "batgeom.wkbIsValid");
}
@@ -338,7 +405,7 @@ str wkbIsValid_bat(bat *outBAT_id, bat *
/*************************** IN: wkb - OUT: int ****************************/
/***************************************************************************/
-str wkbDimension_bat(bat *outBAT_id, bat *inBAT_id) {
+static str WKBtoINT_bat(bat *outBAT_id, bat *inBAT_id, str (*func)(int*, wkb**), \
const char *name) { BAT *outBAT = NULL, *inBAT = NULL;
wkb *inWKB = NULL;
BUN p =0, q =0;
@@ -346,18 +413,18 @@ str wkbDimension_bat(bat *outBAT_id, bat
//get the descriptor of the BAT
if ((inBAT = BATdescriptor(*inBAT_id)) == NULL) {
- throw(MAL, "batgeom.wkbDimension", RUNTIME_OBJECT_MISSING);
+ throw(MAL, name, RUNTIME_OBJECT_MISSING);
}
if ( inBAT->htype != TYPE_void ) { //header type of BAT not void
BBPreleaseref(inBAT->batCacheid);
- throw(MAL, "batgeom.wkbDimension", "The arguments must have dense and aligned \
heads"); + throw(MAL, name, "The arguments must have dense and aligned heads");
}
//create a new for the output BAT
if ((outBAT = BATnew(TYPE_void, ATOMindex("int"), BATcount(inBAT), TRANSIENT)) == \
NULL) { BBPreleaseref(inBAT->batCacheid);
- throw(MAL, "batgeom.wkbDimension", MAL_MALLOC_FAIL);
+ throw(MAL, name, MAL_MALLOC_FAIL);
}
//set the first idx of the new BAT equal to that of the input BAT
BATseqbase(outBAT, inBAT->hseqbase);
@@ -369,8 +436,8 @@ str wkbDimension_bat(bat *outBAT_id, bat
int outSingle;
inWKB = (wkb*) BUNtail(inBAT_iter, p);
- if ((err = wkbDimension(&outSingle, &inWKB)) != MAL_SUCCEED) {
- str msg = createException(MAL, "batgeom.wkbDimension", "%s", err);
+ if ((err = (*func)(&outSingle, &inWKB)) != MAL_SUCCEED) {
+ str msg = createException(MAL, name, "%s", err);
GDKfree(err);
BBPreleaseref(inBAT->batCacheid);
@@ -391,6 +458,13 @@ str wkbDimension_bat(bat *outBAT_id, bat
}
+str wkbDimension_bat(bat *outBAT_id, bat *inBAT_id) {
+ return WKBtoINT_bat(outBAT_id, inBAT_id, wkbDimension, "batgeom.wkbDimension");
+}
+str wkbNumGeometries_bat(bat *outBAT_id, bat *inBAT_id) {
+ return WKBtoINT_bat(outBAT_id, inBAT_id, wkbNumGeometries, \
"batgeom.wkbNumGeometries"); +}
+
/***************************************************************************************/
/*************************** IN: wkb - OUT: int - FLAG: int \
****************************/ \
/***************************************************************************************/
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
@@ -26,9 +26,8 @@ ST_IsRing #ignores Z coordinate
#coordinates
#srid
-#geometryN
-#numGeometries
-
+ST_GeometryN
+ST_NumGeometries
ST_NumPoints
ST_NPoints
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
# 15:46:20 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" \
"--host=/var/tmp/mtest-9662" "--port=32350" # 15:46:20 >
-MAPI = (monetdb) /var/tmp/mtest-1038/.s.monetdb.38496
+MAPI = (monetdb) /var/tmp/mtest-10872/.s.monetdb.32276
QUERY = insert into points_tbl values (st_geomfromtext('point(0 20)', 4326));
ERROR = !column needs geometry(4, 0) and value is geometry(4, 4326)
-MAPI = (monetdb) /var/tmp/mtest-1038/.s.monetdb.38496
+MAPI = (monetdb) /var/tmp/mtest-10872/.s.monetdb.32276
QUERY = insert into points_tbl values (st_geomfromtext('linestring(10 10, 20 20, 30 \
40)')); ERROR = !column needs geometry(4, 0) and value is geometry(8, 0)
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic