Changeset: ba40f61f06f2 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ba40f61f06f2
Added Files:
geom/sql/Tests/functions/Tests/ST_AsEWKT.sql
geom/sql/Tests/functions/Tests/ST_AsEWKT.stable.err
geom/sql/Tests/functions/Tests/ST_AsEWKT.stable.out
Removed Files:
geom/sql/Tests/functions/Tests/asEWKT.sql
geom/sql/Tests/functions/Tests/asEWKT.stable.err
geom/sql/Tests/functions/Tests/asEWKT.stable.out
Modified Files:
geom/monetdb5/geom.h
geom/monetdb5/geom.mal
geom/monetdb5/geomBulk.c
Branch: geo
Log Message:
ST_AsEWKT : bulk + mtest
diffs (truncated from 759 to 300 lines):
diff --git a/geom/monetdb5/geom.h b/geom/monetdb5/geom.h
--- a/geom/monetdb5/geom.h
+++ b/geom/monetdb5/geom.h
@@ -125,7 +125,9 @@ geom_export str wkbDimension(int*, wkb**
geom_export str wkbGeometryType(char**, wkb**, int*);
geom_export str wkbGetSRID(int*, wkb**);
//Envelope
-geom_export str wkbAsText(char**, wkb**, int*);
+geom_export str wkbAsText(char **outTXT, wkb **inWKB, int *withSRID);
+geom_export str wkbAsText_bat(bat *inBAT_id, bat *outBAT_id, int *withSRID);
+
geom_export str wkbAsBinary(char**, wkb**);
geom_export str wkbFromBinary(wkb**, char**);
geom_export str wkbIsEmpty(bit*, wkb**);
diff --git a/geom/monetdb5/geom.mal b/geom/monetdb5/geom.mal
--- a/geom/monetdb5/geom.mal
+++ b/geom/monetdb5/geom.mal
@@ -15,8 +15,6 @@
# Copyright August 2008-2014 MonetDB B.V.
# All Rights Reserved.
-module geom;
-
# @' overwrite lng needed for fixed size! Sizes are fixed in geom.prelude
atom mbr:lng;
@@ -46,7 +44,6 @@ command heap() :int address wkbHEAP; #c
#command wkb{unsafe}(v:str) :wkb address wkbFromString;
command FromText{unsafe}(wkt:str, srid:int, type:int) :wkb address
wkbFromText;
-command ToText(w:wkb, withSRID:int) :str address wkbAsText;
atom wkba;
command tostr() :str address wkbaTOSTR;
@@ -89,12 +86,13 @@ comment "Creates a wkb using the HEX rep
#command AsEWKT(w:wkb) :str address wkbAsEWKT
#comment "Returns the text representation of the geometry including the srid";
+command ToText(w:wkb, withSRID:int) :str address wkbAsText;
function AsText(w:wkb) :str;
- x := wkb.ToText(w,0);
+ x := ToText(w,0);
return x;
end AsText;
function AsEWKT(w:wkb) :str;
- x := wkb.ToText(w,1);
+ x := ToText(w,1);
return x;
end AsEWKT;
@@ -496,6 +494,17 @@ geom.prelude();
module batgeom;
+command ToText(w:bat[:oid,:wkb], withSRID:int) :bat[:oid,:str] address
wkbAsText_bat;
+function AsText(w:bat[:oid,:wkb]) :bat[:oid,:str];
+ x := ToText(w,0);
+ return x;
+end AsText;
+function AsEWKT(w:bat[:oid,:wkb]) :bat[:oid,:str];
+ x := ToText(w,1);
+ return x;
+end AsEWKT;
+
+
command pbsmIndexCreate(x:bat[:oid,:dbl], y:bat[:oid,:dbl], xmin:dbl,
ymin:dbl, xmax:dbl, ymax:dbl) :bat[:oid,:int] address pbsmIndexCreate_bat;
command geom.pbsmIndexLoad() address pbsmIndexLoad_bat;
@@ -611,11 +620,3 @@ function calc.wkb{unsafe}( wkt:str, srid
x := wkb.FromText(wkt,0,0);
return x;
end wkb;
-
-# wkbPoint := 1;
-# wkbLineString := 2;
-# wkbPolygon := 3;
-# wkbMultiPoint := 4;
-# wkbMultiLineString := 5;
-# wkbMultiPolygon := 6;
-# wkbGeometryCollection := 7;
diff --git a/geom/monetdb5/geomBulk.c b/geom/monetdb5/geomBulk.c
--- a/geom/monetdb5/geomBulk.c
+++ b/geom/monetdb5/geomBulk.c
@@ -23,6 +23,62 @@
#include "geom.h"
+/*create textual representation of the wkb */
+str wkbAsText_bat(bat *outBAT_id, bat *inBAT_id, int* withSRID) {
+ 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.wkbAsText", RUNTIME_OBJECT_MISSING);
+ }
+
+ if ( inBAT->htype != TYPE_void ) { //header type of BAT not void
+ BBPreleaseref(inBAT->batCacheid);
+ throw(MAL, "batgeom.wkbAsText", "the arguments must have dense
and aligned heads");
+ }
+
+ //create a new for the output BAT
+ if ((outBAT = BATnew(TYPE_void, ATOMindex("str"), BATcount(inBAT),
TRANSIENT)) == NULL) {
+ BBPreleaseref(inBAT->batCacheid);
+ throw(MAL, "batgeom.wkbAsText", 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;
+ char* outSingle;
+
+ inWKB = (wkb*) BUNtail(inBAT_iter, p);
+ if ((err = wkbAsText(&outSingle, &inWKB, withSRID)) !=
MAL_SUCCEED) {
+ str msg = createException(MAL, "batgeom.wkbAsText",
"%s", err);
+ GDKfree(err);
+
+ BBPreleaseref(inBAT->batCacheid);
+ BBPreleaseref(outBAT->batCacheid);
+
+ return msg;
+ }
+ BUNappend(outBAT,outSingle,TRUE); //add the point 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 geom_2_geom_bat(int* outBAT_id, int* inBAT_id, int* columnType, int*
columnSRID) {
BAT *outBAT = NULL, *inBAT = NULL;
wkb *inWKB = NULL, *outWKB = NULL;
diff --git a/geom/sql/Tests/functions/Tests/asEWKT.sql
b/geom/sql/Tests/functions/Tests/ST_AsEWKT.sql
rename from geom/sql/Tests/functions/Tests/asEWKT.sql
rename to geom/sql/Tests/functions/Tests/ST_AsEWKT.sql
diff --git a/geom/sql/Tests/functions/Tests/ST_AsEWKT.stable.err
b/geom/sql/Tests/functions/Tests/ST_AsEWKT.stable.err
new file mode 100644
--- /dev/null
+++ b/geom/sql/Tests/functions/Tests/ST_AsEWKT.stable.err
@@ -0,0 +1,36 @@
+stderr of test 'ST_AsEWKT` in directory 'geom/sql/Tests/functions` itself:
+
+
+# 13:33:45 >
+# 13:33:45 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=38644" "--set"
"mapi_usock=/var/tmp/mtest-14230/.s.monetdb.38644" "--set" "monet_prompt="
"--forcemito" "--set" "mal_listing=2"
"--dbpath=/export/scratch1/alvanaki/INSTALL/MonetDB-public/var/MonetDB/mTests_geom_sql_Tests_functions"
"--set" "mal_listing=0"
+# 13:33:45 >
+
+# builtin opt gdk_dbpath =
/export/scratch1/alvanaki/INSTALL/MonetDB-public/var/monetdb5/dbfarm/demo
+# builtin opt gdk_debug = 0
+# builtin opt gdk_vmtrim = no
+# builtin opt monet_prompt = >
+# builtin opt monet_daemon = no
+# builtin opt mapi_port = 50000
+# builtin opt mapi_open = false
+# builtin opt mapi_autosense = false
+# builtin opt sql_optimizer = default_pipe
+# builtin opt sql_debug = 0
+# cmdline opt gdk_nr_threads = 0
+# cmdline opt mapi_open = true
+# cmdline opt mapi_port = 38644
+# cmdline opt mapi_usock = /var/tmp/mtest-14230/.s.monetdb.38644
+# cmdline opt monet_prompt =
+# cmdline opt mal_listing = 2
+# cmdline opt gdk_dbpath =
/export/scratch1/alvanaki/INSTALL/MonetDB-public/var/MonetDB/mTests_geom_sql_Tests_functions
+# cmdline opt mal_listing = 0
+# cmdline opt gdk_debug = 536870922
+
+# 13:33:45 >
+# 13:33:45 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-14230" "--port=38644"
+# 13:33:45 >
+
+
+# 13:33:45 >
+# 13:33:45 > "Done."
+# 13:33:45 >
+
diff --git a/geom/sql/Tests/functions/Tests/ST_AsEWKT.stable.out
b/geom/sql/Tests/functions/Tests/ST_AsEWKT.stable.out
new file mode 100644
--- /dev/null
+++ b/geom/sql/Tests/functions/Tests/ST_AsEWKT.stable.out
@@ -0,0 +1,259 @@
+stdout of test 'ST_AsEWKT` in directory 'geom/sql/Tests/functions` itself:
+
+
+# 13:33:45 >
+# 13:33:45 > "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set"
"mapi_open=true" "--set" "mapi_port=38644" "--set"
"mapi_usock=/var/tmp/mtest-14230/.s.monetdb.38644" "--set" "monet_prompt="
"--forcemito" "--set" "mal_listing=2"
"--dbpath=/export/scratch1/alvanaki/INSTALL/MonetDB-public/var/MonetDB/mTests_geom_sql_Tests_functions"
"--set" "mal_listing=0"
+# 13:33:45 >
+
+# MonetDB 5 server v11.20.0
+# This is an unreleased version
+# Serving database 'mTests_geom_sql_Tests_functions', using 8 threads
+# Compiled for x86_64-unknown-linux-gnu/64bit with 64bit OIDs and 128bit
integers dynamically linked
+# Found 15.356 GiB available main-memory.
+# Copyright (c) 1993-July 2008 CWI.
+# Copyright (c) August 2008-2014 MonetDB B.V., all rights reserved
+# Visit http://www.monetdb.org/ for further information
+# Listening for connection requests on mapi:monetdb://sibuyan.da.cwi.nl:38644/
+# Listening for UNIX domain connection requests on
mapi:monetdb:///var/tmp/mtest-14230/.s.monetdb.38644
+# MonetDB/GIS module loaded
+# MonetDB/SQL module loaded
+
+Ready.
+#WARNING To speedup geom.AsEWKT a bulk operator implementation is needed
+#WARNING To speedup geom.AsEWKT a bulk operator implementation is needed
+#WARNING To speedup geom.AsEWKT a bulk operator implementation is needed
+#WARNING To speedup geom.AsEWKT a bulk operator implementation is needed
+#WARNING To speedup geom.AsEWKT a bulk operator implementation is needed
+#WARNING To speedup geom.AsEWKT a bulk operator implementation is needed
+
+# 13:33:45 >
+# 13:33:45 > "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e"
"--host=/var/tmp/mtest-14230" "--port=38644"
+# 13:33:45 >
+
+#select st_asEWKT(st_pointfromtext('point(10 10)'));
+% .L # table_name
+% st_pointfromtext_single_value # name
+% clob # type
+% 56 # length
+[ "SRID:0;\"POINT (10.0000000000000000 10.0000000000000000)\"" ]
+#select st_asEWKT(st_pointfromtext('point(20 20)', 4326));
+% .L # table_name
+% st_pointfromtext_single_value # name
+% clob # type
+% 59 # length
+[ "SRID:4326;\"POINT (20.0000000000000000 20.0000000000000000)\"" ]
+#select st_asEWKT(st_pointfromtext('point(10 10 10)'));
+% .L # table_name
+% st_pointfromtext_single_value # name
+% clob # type
+% 78 # length
+[ "SRID:0;\"POINT Z (10.0000000000000000 10.0000000000000000
10.0000000000000000)\"" ]
+#select st_asEWKT(st_makepoint(10, 10));
+% .L # table_name
+% st_makepoint_single_value # name
+% clob # type
+% 56 # length
+[ "SRID:0;\"POINT (10.0000000000000000 10.0000000000000000)\"" ]
+#select st_asEWKT(st_point(20, 20));
+% .L # table_name
+% st_point_single_value # name
+% clob # type
+% 56 # length
+[ "SRID:0;\"POINT (20.0000000000000000 20.0000000000000000)\"" ]
+#select st_asEWKT(st_makepoint(10, 10, 10));
+% .L # table_name
+% st_makepoint_single_value # name
+% clob # type
+% 78 # length
+[ "SRID:0;\"POINT Z (10.0000000000000000 10.0000000000000000
10.0000000000000000)\"" ]
+#select st_asEWKT(st_linefromtext('linestring(10 10, 20 20, 30 30)'));
+% .L # table_name
+% st_linefromtext_single_value # name
+% clob # type
+% 143 # length
+[ "SRID:0;\"LINESTRING (10.0000000000000000 10.0000000000000000,
20.0000000000000000 20.0000000000000000, 30.0000000000000000
30.0000000000000000)\"" ]
+#select st_asEWKT(st_linefromtext('linestring(20 20, 30 30, 40 40)', 4326));
+% .L # table_name
+% st_linefromtext_single_value # name
+% clob # type
+% 146 # length
+[ "SRID:4326;\"LINESTRING (20.0000000000000000 20.0000000000000000,
30.0000000000000000 30.0000000000000000, 40.0000000000000000
40.0000000000000000)\"" ]
+#select st_asEWKT(st_linefromtext('linestring(20 20 20, 30 30 30, 40 40 40)',
4326));
+% .L # table_name
+% st_linefromtext_single_value # name
+% clob # type
+% 208 # length
+[ "SRID:4326;\"LINESTRING Z (20.0000000000000000 20.0000000000000000
20.0000000000000000, 30.0000000000000000 30.0000000000000000
30.0000000000000000, 40.0000000000000000 40.0000000000000000
40.0000000000000000)\"" ]
+#select st_asEWKT(st_polygonfromtext('polygon((10 10, 20 20, 30 30, 10 10))'));
+% .L # table_name
+% st_polygonfromtext_single_value # name
+% clob # type
+% 183 # length
+[ "SRID:0;\"POLYGON ((10.0000000000000000 10.0000000000000000,
20.0000000000000000 20.0000000000000000, 30.0000000000000000
30.0000000000000000, 10.0000000000000000 10.0000000000000000))\"" ]
+#select st_asEWKT(st_polygonfromtext('polygon((20 20, 30 30, 40 40, 20 20))',
4326));
+% .L # table_name
+% st_polygonfromtext_single_value # name
+% clob # type
+% 186 # length
+[ "SRID:4326;\"POLYGON ((20.0000000000000000 20.0000000000000000,
30.0000000000000000 30.0000000000000000, 40.0000000000000000
40.0000000000000000, 20.0000000000000000 20.0000000000000000))\"" ]
+#select st_asEWKT(st_polygonfromtext('polygon((10 10 10, 20 20 20, 30 30 30,
10 10 10))'));
+% .L # table_name
+% st_polygonfromtext_single_value # name
+% clob # type
+% 265 # length
+[ "SRID:0;\"POLYGON Z ((10.0000000000000000 10.0000000000000000
10.0000000000000000, 20.0000000000000000 20.0000000000000000
20.0000000000000000, 30.0000000000000000 30.0000000000000000
30.0000000000000000, 10.0000000000000000 10.0000000000000000
10.0000000000000000))\"" ]
+#select st_asEWKT(st_mpointfromtext('multipoint(10 10, 20 20)'));
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list