Changeset: 52ecc9154116 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=52ecc9154116
Added Files:
geom/sql/Tests/functions/Tests/XYZ.sql
geom/sql/Tests/functions/Tests/XYZ.stable.err
geom/sql/Tests/functions/Tests/XYZ.stable.out
Removed Files:
geom/sql/Tests/functions/Tests/coordinates.sql
geom/sql/Tests/functions/Tests/coordinates.stable.err
geom/sql/Tests/functions/Tests/coordinates.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_X + ST_Y + ST_Z : bulk + mtest
diffs (truncated from 1212 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
@@ -2563,36 +2563,42 @@ str wkbSetSRID(wkb** resultGeomWKB, wkb
}
/* depending on the specific function it returns the X,Y or Z coordinate of a
point */
-static str wkbGetCoord(double *out, wkb **geom, int dimNum, const char *name) {
- //int ret=MAL_SUCCEED;
+str wkbGetCoordinate(double *out, wkb **geom, int *dimNum) {
GEOSGeom geosGeometry = wkb2geos(*geom);
-#if GEOS_CAPI_VERSION_MAJOR >= 1 && GEOS_CAPI_VERSION_MINOR >= 3
- const GEOSCoordSequence *gcs;
-#else
- const GEOSCoordSeq gcs;
-#endif
+ const GEOSCoordSequence* gcs;
if (!geosGeometry) {
*out = dbl_nil;
- throw(MAL, name, "wkb2geos failed");
- }
-
- if((GEOSGeomTypeId(geosGeometry)+1) != wkbPoint)
- throw(MAL, name, "Geometry not a Point");
+ throw(MAL, "geom.wkbGetCoordinate", "wkb2geos failed");
+ }
+
+ if((GEOSGeomTypeId(geosGeometry)+1) != wkbPoint) {
+ str err;
+ char *geomSTR;
+ if((err = wkbAsText(&geomSTR, geom, NULL)) != MAL_SUCCEED) {
+ str msg = createException(MAL, "geom.wkbGetCoordinate",
"%s", err);
+ GDKfree(err);
+ GEOSGeom_destroy(geosGeometry);
+ return msg;
+ }
+
+ GEOSGeom_destroy(geosGeometry);
+ throw(MAL, "geom.wkbGetCoordinate", "Geometry %s not a Point",
geomSTR);
+ }
gcs = GEOSGeom_getCoordSeq(geosGeometry);
if (!gcs) {
- throw(MAL, name, "GEOSGeom_getCoordSeq failed");
+ throw(MAL, "geom.wkbGetCoordinate", "GEOSGeom_getCoordSeq
failed");
}
- GEOSCoordSeq_getOrdinate(gcs, 0, dimNum, out);
+ GEOSCoordSeq_getOrdinate(gcs, 0, *dimNum, out);
/* gcs shouldn't be freed, it's internal to the GEOSGeom */
GEOSGeom_destroy(geosGeometry);
return MAL_SUCCEED;
}
-
+/*
str wkbGetCoordX(double *out, wkb **geom) {
return wkbGetCoord(out, geom, 0, "geom.X");
}
@@ -2601,12 +2607,12 @@ 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 */
+// 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) {
diff --git a/geom/monetdb5/geom.h b/geom/monetdb5/geom.h
--- a/geom/monetdb5/geom.h
+++ b/geom/monetdb5/geom.h
@@ -172,9 +172,10 @@ geom_export str wkbMakePoint_bat(bat*, b
geom_export str wkbCoordDim(int* , wkb**);
geom_export str wkbSetSRID(wkb**, wkb**, int*);
-geom_export str wkbGetCoordX(double*, wkb**);
-geom_export str wkbGetCoordY(double*, wkb**);
-geom_export str wkbGetCoordZ(double*, wkb**);
+
+geom_export str wkbGetCoordinate(double *out, wkb **geom, int *dimNum);
+geom_export str wkbGetCoordinate_bat(bat *outBAT_id, bat *inBAT_id, int* flag);
+
geom_export str wkbStartPoint(wkb **out, wkb **geom);
geom_export str wkbEndPoint(wkb **out, wkb **geom);
diff --git a/geom/monetdb5/geom.mal b/geom/monetdb5/geom.mal
--- a/geom/monetdb5/geom.mal
+++ b/geom/monetdb5/geom.mal
@@ -227,6 +227,22 @@ function GeometryType2(w:wkb) :str;
return x;
end GeometryType2;
+command GetCoordinate(w:wkb, idx:int) :dbl address wkbGetCoordinate
+comment "Returns the coordinate at position idx of a point, or NULL if not
available. idx=0 -> X, idx=1 -> Y, idx=2 -> Z. Input must be point";
+function X(w:wkb) :dbl;
+ c := GetCoordinate(w, 0);
+ return c;
+end X;
+function Y(w:wkb) :dbl;
+ c := GetCoordinate(w, 1);
+ return c;
+end Y;
+function Z(w:wkb) :dbl;
+ c := GetCoordinate(w, 2);
+ return c;
+end Z;
+
+
command Boundary(w:wkb) :wkb address wkbBoundary
comment "Returns the closure of the combinatorial boundary of the Geometry.";
command CoordDim(w:wkb) :int address wkbCoordDim
@@ -237,12 +253,6 @@ command getSRID(w:wkb) :int address wkbG
comment "Returns the Spatial Reference System ID for this Geometry.";
command setSRID(w:wkb, srid:int) :wkb address wkbSetSRID
comment "Sets the Reference System ID for this Geometry.";
-command X(g:wkb) :dbl address wkbGetCoordX
-comment "Return the X coordinate of the point, or NULL if not available.
Input must be a point.";
-command Y(g:wkb) :dbl address wkbGetCoordY
-comment "Return the Y coordinate of the point, or NULL if not available. Input
must be a point.";
-command Z(g:wkb) :dbl address wkbGetCoordZ
-comment "Return the Z coordinate of the point, or NULL if not available. Input
must be a point.";
command StartPoint(w:wkb) :wkb address wkbStartPoint
comment "Returns the first point of a LINESTRING geometry as a POINT or NULL
if the input parameter is not a LINESTRING";
command EndPoint(w:wkb) :wkb address wkbEndPoint
@@ -632,6 +642,21 @@ function NPoints(w:bat[:oid,:wkb]) :bat[
return x;
end NPoints;
+command GetCoordinate(w:bat[:oid,:wkb], idx:int) :bat[:oid,:dbl] address
wkbGetCoordinate_bat
+comment "Returns the coordinate at position idx of a point, or NULL if not
available. idx=0 -> X, idx=1 -> Y, idx=2 -> Z. Input must be point";
+function X(w:bat[:oid,:wkb]) :bat[:oid,:dbl];
+ c := GetCoordinate(w, 0);
+ return c;
+end X;
+function Y(w:bat[:oid,:wkb]) :bat[:oid,:dbl];
+ c := GetCoordinate(w, 1);
+ return c;
+end Y;
+function Z(w:bat[:oid,:wkb]) :bat[:oid,:dbl];
+ c := GetCoordinate(w, 2);
+ return c;
+end Z;
+
command GeometryN(w:bat[:oid,:wkb], n:int) :bat[:oid,:wkb] address
wkbGeometryN_bat
diff --git a/geom/monetdb5/geomBulk.c b/geom/monetdb5/geomBulk.c
--- a/geom/monetdb5/geomBulk.c
+++ b/geom/monetdb5/geomBulk.c
@@ -522,6 +522,63 @@ str wkbNumPoints_bat(bat *outBAT_id, bat
}
+/******************************************************************************************/
+/*************************** IN: wkb - OUT: double - FLAG: int
****************************/
+/******************************************************************************************/
+
+str wkbGetCoordinate_bat(bat *outBAT_id, bat *inBAT_id, int* flag) {
+ 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, "batgeom.wkbGetCoordinate", RUNTIME_OBJECT_MISSING);
+ }
+
+ if ( inBAT->htype != TYPE_void ) { //header type of BAT not void
+ BBPreleaseref(inBAT->batCacheid);
+ throw(MAL, "batgeom.wkbGetCoordinate", "The arguments must have
dense and aligned heads");
+ }
+
+ //create a new for the output BAT
+ if ((outBAT = BATnew(TYPE_void, ATOMindex("dbl"), BATcount(inBAT),
TRANSIENT)) == NULL) {
+ BBPreleaseref(inBAT->batCacheid);
+ throw(MAL, "batgeom.wkbGetCoordinate", 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;
+ double outSingle;
+
+ inWKB = (wkb*) BUNtail(inBAT_iter, p);
+ if ((err = wkbGetCoordinate(&outSingle, &inWKB, flag)) !=
MAL_SUCCEED) {
+ str msg = createException(MAL,
"batgeom.wkbGetCoordinate", "%s", err);
+ GDKfree(err);
+
+ BBPreleaseref(inBAT->batCacheid);
+ BBPreleaseref(outBAT->batCacheid);
+
+ return msg;
+ }
+ BUNappend(outBAT,&outSingle,TRUE); //add the result to the new
BAT
+ }
+
+ //set the number of elements in the outBAT
+ BATsetcount(outBAT, BATcount(inBAT));
+
+ BBPreleaseref(inBAT->batCacheid);
+ BBPkeepref(*outBAT_id = outBAT->batCacheid);
+
+ return MAL_SUCCEED;
+
+}
+
/*******************************/
/********* Two inputs **********/
/*******************************/
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
@@ -24,7 +24,7 @@ ST_IsSimple #ignores Z coordinate
ST_IsValid #ignores Z coordinate
ST_IsRing #ignores Z coordinate
-#coordinates
+XYZ
#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
# 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-10872/.s.monetdb.32276
+MAPI = (monetdb) /var/tmp/mtest-25417/.s.monetdb.37599
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-10872/.s.monetdb.32276
+MAPI = (monetdb) /var/tmp/mtest-25417/.s.monetdb.37599
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)
-MAPI = (monetdb) /var/tmp/mtest-10872/.s.monetdb.32276
+MAPI = (monetdb) /var/tmp/mtest-25417/.s.monetdb.37599
QUERY = insert into points_tbl values (st_geomfromtext('point(0 20)'));
ERROR = !column needs geometry(4, 4326) and value is geometry(4, 0)
-MAPI = (monetdb) /var/tmp/mtest-10872/.s.monetdb.32276
+MAPI = (monetdb) /var/tmp/mtest-25417/.s.monetdb.37599
QUERY = insert into points_tbl values (st_geomfromtext('point(0 20)', 0));
ERROR = !column needs geometry(4, 4326) and value is geometry(4, 0)
-MAPI = (monetdb) /var/tmp/mtest-10872/.s.monetdb.32276
+MAPI = (monetdb) /var/tmp/mtest-25417/.s.monetdb.37599
QUERY = insert into points_tbl values (st_geomfromtext('linestring(10 10, 20
20, 30 40)', 4329));
ERROR = !column needs geometry(4, 4326) and value is geometry(8, 4329)
-MAPI = (monetdb) /var/tmp/mtest-10872/.s.monetdb.32276
+MAPI = (monetdb) /var/tmp/mtest-25417/.s.monetdb.37599
QUERY = insert into points_tbl values (st_geomfromtext('point(0 20 20)',
4326));
ERROR = !column needs geometry(6, 0) and value is geometry(6, 4326)
-MAPI = (monetdb) /var/tmp/mtest-10872/.s.monetdb.32276
+MAPI = (monetdb) /var/tmp/mtest-25417/.s.monetdb.37599
QUERY = insert into points_tbl values (st_geomfromtext('linestring(10 10, 20
20, 30 40)'));
ERROR = !column needs geometry(6, 0) and value is geometry(8, 0)
-MAPI = (monetdb) /var/tmp/mtest-10872/.s.monetdb.32276
+MAPI = (monetdb) /var/tmp/mtest-25417/.s.monetdb.37599
QUERY = insert into points_tbl values (st_geomfromtext('point(0 20 20)'));
ERROR = !column needs geometry(6, 4326) and value is geometry(6, 0)
-MAPI = (monetdb) /var/tmp/mtest-10872/.s.monetdb.32276
+MAPI = (monetdb) /var/tmp/mtest-25417/.s.monetdb.37599
QUERY = insert into points_tbl values (st_geomfromtext('point(0 20 20)', 0));
ERROR = !column needs geometry(6, 4326) and value is geometry(6, 0)
-MAPI = (monetdb) /var/tmp/mtest-10872/.s.monetdb.32276
+MAPI = (monetdb) /var/tmp/mtest-25417/.s.monetdb.37599
QUERY = insert into points_tbl values (st_geomfromtext('linestring(10 10, 20
20, 30 40)', 4326));
ERROR = !column needs geometry(6, 4326) and value is geometry(8, 4326)
-MAPI = (monetdb) /var/tmp/mtest-10872/.s.monetdb.32276
+MAPI = (monetdb) /var/tmp/mtest-25417/.s.monetdb.37599
QUERY = insert into lines_tbl values (st_geomfromtext('linestring(20 20, 30
30, 40 40)', 4326));
ERROR = !column needs geometry(8, 0) and value is geometry(8, 4326)
-MAPI = (monetdb) /var/tmp/mtest-10872/.s.monetdb.32276
+MAPI = (monetdb) /var/tmp/mtest-25417/.s.monetdb.37599
QUERY = insert into lines_tbl values (st_geomfromtext('point(0 0)'));
ERROR = !column needs geometry(8, 0) and value is geometry(4, 0)
-MAPI = (monetdb) /var/tmp/mtest-10872/.s.monetdb.32276
+MAPI = (monetdb) /var/tmp/mtest-25417/.s.monetdb.37599
QUERY = insert into lines_tbl values (st_geomfromtext('linestring(10 10, 20
20, 30 30)'));
ERROR = !column needs geometry(8, 4326) and value is geometry(8, 0)
-MAPI = (monetdb) /var/tmp/mtest-10872/.s.monetdb.32276
+MAPI = (monetdb) /var/tmp/mtest-25417/.s.monetdb.37599
QUERY = insert into lines_tbl values (st_geomfromtext('linestring(30 30, 40
40, 50 50)', 0));
ERROR = !column needs geometry(8, 4326) and value is geometry(8, 0)
-MAPI = (monetdb) /var/tmp/mtest-10872/.s.monetdb.32276
+MAPI = (monetdb) /var/tmp/mtest-25417/.s.monetdb.37599
QUERY = insert into lines_tbl values (st_geomfromtext('point(0 0)', 4326));
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list