Changeset: 05f16de5c263 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=05f16de5c263
Added Files:
geom/sql/Tests/functions/Tests/ST_GeomFromText.sql
geom/sql/Tests/functions/Tests/ST_GeomFromText.stable.err
geom/sql/Tests/functions/Tests/ST_GeomFromText.stable.out
geom/sql/Tests/functions/Tests/ST_LineFromText.sql
geom/sql/Tests/functions/Tests/ST_LineFromText.stable.err
geom/sql/Tests/functions/Tests/ST_LineFromText.stable.out
geom/sql/Tests/functions/Tests/ST_MLineFromText.sql
geom/sql/Tests/functions/Tests/ST_MLineFromText.stable.err
geom/sql/Tests/functions/Tests/ST_MLineFromText.stable.out
geom/sql/Tests/functions/Tests/ST_MPointFromText.sql
geom/sql/Tests/functions/Tests/ST_MPointFromText.stable.err
geom/sql/Tests/functions/Tests/ST_MPointFromText.stable.out
geom/sql/Tests/functions/Tests/ST_MPolygonFromText.sql
geom/sql/Tests/functions/Tests/ST_MPolygonFromText.stable.err
geom/sql/Tests/functions/Tests/ST_MPolygonFromText.stable.out
geom/sql/Tests/functions/Tests/ST_PointFromText.sql
geom/sql/Tests/functions/Tests/ST_PointFromText.stable.err
geom/sql/Tests/functions/Tests/ST_PointFromText.stable.out
geom/sql/Tests/functions/Tests/ST_PolygonFromText.sql
geom/sql/Tests/functions/Tests/ST_PolygonFromText.stable.err
geom/sql/Tests/functions/Tests/ST_PolygonFromText.stable.out
geom/sql/Tests/functions/Tests/dropTestWKT.sql
geom/sql/Tests/functions/Tests/dropTestWKT.stable.err
geom/sql/Tests/functions/Tests/dropTestWKT.stable.out
geom/sql/Tests/functions/Tests/loadTestWKT.sql
geom/sql/Tests/functions/Tests/loadTestWKT.stable.err
geom/sql/Tests/functions/Tests/loadTestWKT.stable.out
Removed Files:
geom/sql/Tests/functions/Tests/geomFromText.sql
geom/sql/Tests/functions/Tests/geomFromText.stable.err
geom/sql/Tests/functions/Tests/geomFromText.stable.out
geom/sql/Tests/functions/Tests/lineFromText.sql
geom/sql/Tests/functions/Tests/lineFromText.stable.err
geom/sql/Tests/functions/Tests/lineFromText.stable.out
geom/sql/Tests/functions/Tests/mlineFromText.sql
geom/sql/Tests/functions/Tests/mlineFromText.stable.err
geom/sql/Tests/functions/Tests/mlineFromText.stable.out
geom/sql/Tests/functions/Tests/mpointFromText.sql
geom/sql/Tests/functions/Tests/mpointFromText.stable.err
geom/sql/Tests/functions/Tests/mpointFromText.stable.out
geom/sql/Tests/functions/Tests/mpolygonFromText.sql
geom/sql/Tests/functions/Tests/mpolygonFromText.stable.err
geom/sql/Tests/functions/Tests/mpolygonFromText.stable.out
geom/sql/Tests/functions/Tests/pointFromText.sql
geom/sql/Tests/functions/Tests/pointFromText.stable.err
geom/sql/Tests/functions/Tests/pointFromText.stable.out
geom/sql/Tests/functions/Tests/polygonFromText.sql
geom/sql/Tests/functions/Tests/polygonFromText.stable.err
geom/sql/Tests/functions/Tests/polygonFromText.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
Branch: geo
Log Message:
ST_*FromText : mTests + bulk
diffs (truncated from 4560 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
@@ -2154,7 +2154,7 @@ str wkbFromText(wkb **geomWKB, str *geom
*geomWKB = NULL;
if (wkbFROMSTR(*geomWKT, &len, geomWKB, *srid) &&
- (wkb_isnil(*geomWKB) || *tpe==0 || *tpe ==
wkbGeometryCollection || (te = ((*((*geomWKB)->data + 1) & 0x0f)+(*tpe>2))) ==
*tpe)) {
+ (wkb_isnil(*geomWKB) || *tpe==0 || *tpe ==
wkbGeometryCollection || ((te = ((*((*geomWKB)->data + 1) & 0x0f)))+(*tpe>2))
== *tpe)) {
return MAL_SUCCEED;
}
@@ -2162,11 +2162,9 @@ str wkbFromText(wkb **geomWKB, str *geom
*geomWKB = wkb_nil;
}
- //get back the correct value for geos
- te-= (te<4);
-
+ te += (te>2);
if (*tpe > 0 && te != *tpe)
- throw(MAL, "wkb.FromText", "Geometry not type '%d: %s' but '%d:
%s' instead", *tpe, geom_type2str(*tpe,0), te, geom_type2str(te,0));
+ throw(SQL, "wkb.FromText", "Geometry not type '%d: %s' but '%d:
%s' instead", *tpe, geom_type2str(*tpe,0), te, geom_type2str(te,0));
errbuf = GDKerrbuf;
if (errbuf) {
if (strncmp(errbuf, "!ERROR: ", 8) == 0)
diff --git a/geom/monetdb5/geom.h b/geom/monetdb5/geom.h
--- a/geom/monetdb5/geom.h
+++ b/geom/monetdb5/geom.h
@@ -117,6 +117,8 @@ geom_export mbr* mbrFromGeos(const GEOSG
geom_export str wkbFromText(wkb **geomWKB, str *geomWKT, int* srid, int *tpe);
+geom_export str wkbFromText_bat(bat *inBAT_id, bat *outBAT_id, int *srid, int
*tpe);
+
geom_export str wkbMLineStringToPolygon(wkb** geomWKB, str* geomWKT, int*
srid, int* flag);
diff --git a/geom/monetdb5/geom.mal b/geom/monetdb5/geom.mal
--- a/geom/monetdb5/geom.mal
+++ b/geom/monetdb5/geom.mal
@@ -43,7 +43,6 @@ command length() :int address wkbLENGTH
command heap() :int address wkbHEAP; #create heap
#command wkb{unsafe}(v:str) :wkb address wkbFromString;
-command FromText{unsafe}(wkt:str, srid:int, type:int) :wkb address
wkbFromText;
atom wkba;
command tostr() :str address wkbaTOSTR;
@@ -96,70 +95,70 @@ function AsEWKT(w:wkb) :str;
return x;
end AsEWKT;
-
-function GeomFromText{unsafe}(wkt:str, srid:int) :wkb;
- x := wkb.FromText(wkt,srid,0);
+command FromText(wkt:str, srid:int, type:int) :wkb address wkbFromText;
+function GeomFromText(wkt:str, srid:int) :wkb;
+ x := FromText(wkt,srid,0);
return x;
end GeomFromText;
-function PointFromText{unsafe}(wkt:str, srid:int) :wkb;
- x := wkb.FromText(wkt,srid,1);
+function PointFromText(wkt:str, srid:int) :wkb;
+ x := FromText(wkt,srid,1);
return x;
end PointFromText;
-function LineFromText{unsafe}(wkt:str, srid:int) :wkb;
- x := wkb.FromText(wkt,srid,2);
+function LineFromText(wkt:str, srid:int) :wkb;
+ x := FromText(wkt,srid,2);
return x;
end LineFromText;
-function PolygonFromText{unsafe}(wkt:str, srid:int) :wkb;
- x := wkb.FromText(wkt,srid,4);
+function PolygonFromText(wkt:str, srid:int) :wkb;
+ x := FromText(wkt,srid,4);
return x;
end PolygonFromText;
-function MPointFromText{unsafe}(wkt:str, srid:int) :wkb;
- x := wkb.FromText(wkt,srid,5);
+function MPointFromText(wkt:str, srid:int) :wkb;
+ x := FromText(wkt,srid,5);
return x;
end MPointFromText;
-function MLineFromText{unsafe}(wkt:str, srid:int) :wkb;
- x := wkb.FromText(wkt,srid,6);
+function MLineFromText(wkt:str, srid:int) :wkb;
+ x := FromText(wkt,srid,6);
return x;
end MLineFromText;
-function MPolyFromText{unsafe}(wkt:str, srid:int) :wkb;
- x := wkb.FromText(wkt,srid,7);
+function MPolyFromText(wkt:str, srid:int) :wkb;
+ x := FromText(wkt,srid,7);
return x;
end MPolyFromText;
-function GeomCollFromText{unsafe}(wkt:str, srid:int) :wkb;
- x := wkb.FromText(wkt,srid,8);
+function GeomCollFromText(wkt:str, srid:int) :wkb;
+ x := FromText(wkt,srid,8);
return x;
end GeomCollFromText;
-function GeomFromText{unsafe}(wkt:str) :wkb;
- x := wkb.FromText(wkt,0,0);
+function GeomFromText(wkt:str) :wkb;
+ x := FromText(wkt,0,0);
return x;
end GeomFromText;
-function PointFromText{unsafe}(wkt:str) :wkb;
- x := wkb.FromText(wkt,0,1);
+function PointFromText(wkt:str) :wkb;
+ x := FromText(wkt,0,1);
return x;
end PointFromText;
-function LineFromText{unsafe}(wkt:str) :wkb;
- x := wkb.FromText(wkt,0,2);
+function LineFromText(wkt:str) :wkb;
+ x := FromText(wkt,0,2);
return x;
end LineFromText;
-function PolygonFromText{unsafe}(wkt:str) :wkb;
- x := wkb.FromText(wkt,0,4);
+function PolygonFromText(wkt:str) :wkb;
+ x := FromText(wkt,0,4);
return x;
end PolygonFromText;
-function MPointFromText{unsafe}(wkt:str) :wkb;
- x := wkb.FromText(wkt,0,5);
+function MPointFromText(wkt:str) :wkb;
+ x := FromText(wkt,0,5);
return x;
end MPointFromText;
-function MLineFromText{unsafe}(wkt:str) :wkb;
- x := wkb.FromText(wkt,0,6);
+function MLineFromText(wkt:str) :wkb;
+ x := FromText(wkt,0,6);
return x;
end MLineFromText;
-function MPolyFromText{unsafe}(wkt:str) :wkb;
- x := wkb.FromText(wkt,0,7);
+function MPolyFromText(wkt:str) :wkb;
+ x := FromText(wkt,0,7);
return x;
end MPolyFromText;
-function GeomCollFromText{unsafe}(wkt:str) :wkb;
- x := wkb.FromText(wkt,0,8);
+function GeomCollFromText(wkt:str) :wkb;
+ x := FromText(wkt,0,8);
return x;
end GeomCollFromText;
@@ -494,6 +493,75 @@ geom.prelude();
module batgeom;
+command FromText(wkt:bat[:oid,:str], srid:int, type:int) :bat[:oid, :wkb]
address wkbFromText_bat;
+function GeomFromText(wkt:bat[:oid,:str], srid:int) :bat[:oid,:wkb];
+ x := FromText(wkt,srid,0);
+ return x;
+end GeomFromText;
+function PointFromText(wkt:bat[:oid,:str], srid:int) :bat[:oid, :wkb];
+ x := FromText(wkt,srid,1);
+ return x;
+end PointFromText;
+function LineFromText(wkt:bat[:oid,:str], srid:int) :bat[:oid, :wkb];
+ x := FromText(wkt,srid,2);
+ return x;
+end LineFromText;
+function PolygonFromText(wkt:bat[:oid,:str], srid:int) :bat[:oid, :wkb];
+ x := FromText(wkt,srid,4);
+ return x;
+end PolygonFromText;
+function MPointFromText(wkt:bat[:oid,:str], srid:int) :bat[:oid, :wkb];
+ x := FromText(wkt,srid,5);
+ return x;
+end MPointFromText;
+function MLineFromText(wkt:bat[:oid,:str], srid:int) :bat[:oid, :wkb];
+ x := FromText(wkt,srid,6);
+ return x;
+end MLineFromText;
+function MPolyFromText(wkt:bat[:oid,:str], srid:int) :bat[:oid, :wkb];
+ x := FromText(wkt,srid,7);
+ return x;
+end MPolyFromText;
+function GeomCollFromText(wkt:bat[:oid,:str], srid:int) :bat[:oid, :wkb];
+ x := FromText(wkt,srid,8);
+ return x;
+end GeomCollFromText;
+
+function GeomFromText(wkt:bat[:oid,:str]) :bat[:oid,:wkb];
+ x := FromText(wkt,0,0);
+ return x;
+end GeomFromText;
+function PointFromText(wkt:bat[:oid,:str]) :bat[:oid, :wkb];
+ x := FromText(wkt,0,1);
+ return x;
+end PointFromText;
+function LineFromText(wkt:bat[:oid,:str]) :bat[:oid, :wkb];
+ x := FromText(wkt,0,2);
+ return x;
+end LineFromText;
+function PolygonFromText(wkt:bat[:oid,:str]) :bat[:oid, :wkb];
+ x := FromText(wkt,0,4);
+ return x;
+end PolygonFromText;
+function MPointFromText(wkt:bat[:oid,:str]) :bat[:oid, :wkb];
+ x := FromText(wkt,0,5);
+ return x;
+end MPointFromText;
+function MLineFromText(wkt:bat[:oid,:str]) :bat[:oid, :wkb];
+ x := FromText(wkt,0,6);
+ return x;
+end MLineFromText;
+function MPolyFromText(wkt:bat[:oid,:str]) :bat[:oid, :wkb];
+ x := FromText(wkt,0,7);
+ return x;
+end MPolyFromText;
+function GeomCollFromText(wkt:bat[:oid,:str]) :bat[:oid, :wkb];
+ x := FromText(wkt,0,8);
+ return x;
+end GeomCollFromText;
+
+
+
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);
@@ -624,6 +692,6 @@ comment "Nil test for wkb value";
#loading string without the need to use st_wkbtosql OR st_wkttosql
function calc.wkb{unsafe}( wkt:str, srid:int, type:int ) :wkb;
- x := wkb.FromText(wkt,0,0);
+ x := geom.FromText(wkt,0,0);
return x;
end wkb;
diff --git a/geom/monetdb5/geomBulk.c b/geom/monetdb5/geomBulk.c
--- a/geom/monetdb5/geomBulk.c
+++ b/geom/monetdb5/geomBulk.c
@@ -82,6 +82,61 @@ str geom_2_geom_bat(int* outBAT_id, int*
}
+/*create WKB from WKT */
+str wkbFromText_bat(bat *outBAT_id, bat *inBAT_id, int *srid, int *tpe) {
+ BAT *outBAT = NULL, *inBAT = NULL;
+ char *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.wkbFromText", RUNTIME_OBJECT_MISSING);
+ }
+
+ if ( inBAT->htype != TYPE_void ) { //header type of BAT not void
+ BBPreleaseref(inBAT->batCacheid);
+ throw(MAL, "batgeom.wkbFromText", "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.wkbFromText", 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 = (char*) BUNtail(inBAT_iter, p);
+ if ((err = wkbFromText(&outSingle, &inWKB, srid, tpe)) !=
MAL_SUCCEED) {
+ str msg = createException(MAL, "batgeom.wkbFromText",
"%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;
+}
+
/*create textual representation of the wkb */
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list