Changeset: 88c68d6b5848 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=88c68d6b5848
Added Files:
        geom/sql/Tests/functions/Tests/ST_IsClosed.sql
        geom/sql/Tests/functions/Tests/ST_IsClosed.stable.err
        geom/sql/Tests/functions/Tests/ST_IsClosed.stable.out
Removed Files:
        geom/sql/Tests/functions/Tests/isClosed.sql
        geom/sql/Tests/functions/Tests/isClosed.stable.err
        geom/sql/Tests/functions/Tests/isClosed.stable.out
Modified Files:
        geom/monetdb5/geom.h
        geom/monetdb5/geom.mal
        geom/monetdb5/geomBulk.c
        geom/sql/Tests/functions/Tests/All
Branch: geo
Log Message:

ST_IsClosed: bulk+mtest


diffs (truncated from 458 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
@@ -180,7 +180,10 @@ geom_export str wkbExteriorRing(wkb**, w
 geom_export str wkbInteriorRingN(wkb**, wkb**, short*);
 geom_export str wkbNumRings(int*, wkb**, int*);
 geom_export str wkbInteriorRings(wkba**, wkb**);
+
 geom_export str wkbIsClosed(bit *out, wkb **geom);
+geom_export str wkbIsClosed_bat(bat *inBAT_id, bat *outBAT_id);
+
 geom_export str wkbIsRing(bit *out, wkb **geom);
 geom_export str wkbIsValid(bit *out, wkb **geom);
 geom_export str wkbIsValidReason(char** 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
@@ -504,8 +504,8 @@ function AsEWKT(w:bat[:oid,:wkb]) :bat[:
        return x;
 end AsEWKT;
 
-command Boundary(w:bat[:oid,:wkb]) :bat[:oid,:wkb] address wkbBoundary_bat
-comment "Returns the closure of the combinatorial boundary of the input 
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;
 
 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;
diff --git a/geom/monetdb5/geomBulk.c b/geom/monetdb5/geomBulk.c
--- a/geom/monetdb5/geomBulk.c
+++ b/geom/monetdb5/geomBulk.c
@@ -177,7 +177,7 @@ str wkbBoundary_bat(bat *outBAT_id, bat 
                        
                        return msg;
                }
-               BUNappend(outBAT,outSingle,TRUE); //add the point to the new BAT
+               BUNappend(outBAT,outSingle,TRUE); //add the result to the new 
BAT
                GDKfree(outSingle);
                outSingle = NULL;
        }
@@ -191,6 +191,58 @@ str wkbBoundary_bat(bat *outBAT_id, bat 
        return MAL_SUCCEED;
 }
 
+str wkbIsClosed_bat(bat *outBAT_id, bat *inBAT_id) {
+       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.wkbIsClosed", RUNTIME_OBJECT_MISSING);
+       }
+       
+       if ( inBAT->htype != TYPE_void ) { //header type of  BAT not void
+               BBPreleaseref(inBAT->batCacheid);
+               throw(MAL, "batgeom.wkbIsClosed", "The arguments must have 
dense and aligned heads");
+       }
+
+       //create a new for the output BAT
+       if ((outBAT = BATnew(TYPE_void, ATOMindex("bit"), BATcount(inBAT), 
TRANSIENT)) == NULL) {
+               BBPreleaseref(inBAT->batCacheid);
+               throw(MAL, "batgeom.wkbIsClosed", 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;
+               bit outSingle;
+
+               inWKB = (wkb*) BUNtail(inBAT_iter, p);
+               if ((err = wkbIsClosed(&outSingle, &inWKB)) != MAL_SUCCEED) {
+                       str msg = createException(MAL, "batgeom.wkbIsClosed", 
"%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;
+}
+
 
 
 /*******************************/
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
@@ -13,7 +13,7 @@ loadTestGeometries
 
 ST_AsText
 
-#isClosed
+ST_IsClosed
 #isSimple
 #isValid
 #isRing
diff --git a/geom/sql/Tests/functions/Tests/ST_IsClosed.sql 
b/geom/sql/Tests/functions/Tests/ST_IsClosed.sql
new file mode 100644
--- /dev/null
+++ b/geom/sql/Tests/functions/Tests/ST_IsClosed.sql
@@ -0,0 +1,20 @@
+SELECT ST_IsClosed(st_linefromtext('LINESTRING(10 10, 20 20)'));
+SELECT ST_IsClosed(st_linefromtext('LINESTRING(10 10, 20 20, 10 10)'));
+SELECT ST_IsClosed(st_mlinefromtext('MULTILINESTRING((10 10, 20 20, 10 10),(10 
10, 20 20))'));
+SELECT ST_IsClosed(st_pointfromtext('POINT(10 10)'));
+SELECT ST_IsClosed(st_mpointfromtext('MULTIPOINT((10 10), (20 20))'));
+SELECT ST_IsClosed(st_polygonfromtext('POLYGON((10 10 10, 20 20 20, 30 30 30, 
10 10 10))'));
+SELECT ST_IsClosed(st_linefromtext('LINESTRING(10 10 10, 20 20 20, 10 10 
10)'));
+
+create table geo (g geometry(linestring, 4326));
+insert into geo values (st_linefromtext('LINESTRING(10 10, 20 20)', 4326));
+insert into geo values (st_linefromtext('LINESTRING(10 10, 20 20, 10 10)', 
4326));
+select st_isclosed(g) from geo;
+drop table geo;
+
+create table geo (g geometry(polygonz, 4326));
+insert into geo values (st_polygonfromtext('polygon((10 10 10, 20 20 20, 30 30 
30, 10 10 10))', 4326));
+select st_isclosed(g) from geo;
+drop table geo;
+
+SELECT geom AS "GEOMETRY", ST_IsClosed(geom) FROM geometries;
diff --git a/geom/sql/Tests/functions/Tests/ST_IsClosed.stable.err 
b/geom/sql/Tests/functions/Tests/ST_IsClosed.stable.err
new file mode 100644
--- /dev/null
+++ b/geom/sql/Tests/functions/Tests/ST_IsClosed.stable.err
@@ -0,0 +1,36 @@
+stderr of test 'ST_IsClosed` in directory 'geom/sql/Tests/functions` itself:
+
+
+# 12:51:38 >  
+# 12:51:38 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=37696" "--set" 
"mapi_usock=/var/tmp/mtest-27361/.s.monetdb.37696" "--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"
+# 12:51:38 >  
+
+# 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 = 37696
+# cmdline opt  mapi_usock = /var/tmp/mtest-27361/.s.monetdb.37696
+# 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
+
+# 12:51:38 >  
+# 12:51:38 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-27361" "--port=37696"
+# 12:51:38 >  
+
+
+# 12:51:38 >  
+# 12:51:38 >  "Done."
+# 12:51:38 >  
+
diff --git a/geom/sql/Tests/functions/Tests/ST_IsClosed.stable.out 
b/geom/sql/Tests/functions/Tests/ST_IsClosed.stable.out
new file mode 100644
--- /dev/null
+++ b/geom/sql/Tests/functions/Tests/ST_IsClosed.stable.out
@@ -0,0 +1,111 @@
+stdout of test 'ST_IsClosed` in directory 'geom/sql/Tests/functions` itself:
+
+
+# 12:51:38 >  
+# 12:51:38 >  "mserver5" "--debug=10" "--set" "gdk_nr_threads=0" "--set" 
"mapi_open=true" "--set" "mapi_port=37696" "--set" 
"mapi_usock=/var/tmp/mtest-27361/.s.monetdb.37696" "--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"
+# 12:51:38 >  
+
+# 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:37696/
+# Listening for UNIX domain connection requests on 
mapi:monetdb:///var/tmp/mtest-27361/.s.monetdb.37696
+# MonetDB/GIS module loaded
+# MonetDB/SQL module loaded
+
+Ready.
+
+# 12:51:38 >  
+# 12:51:38 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-27361" "--port=37696"
+# 12:51:38 >  
+
+#SELECT ST_IsClosed(st_linefromtext('LINESTRING(10 10, 20 20)'));
+% .L # table_name
+% st_linefromtext_single_value # name
+% boolean # type
+% 5 # length
+[ false        ]
+#SELECT ST_IsClosed(st_linefromtext('LINESTRING(10 10, 20 20, 10 10)'));
+% .L # table_name
+% st_linefromtext_single_value # name
+% boolean # type
+% 5 # length
+[ true ]
+#SELECT ST_IsClosed(st_mlinefromtext('MULTILINESTRING((10 10, 20 20, 10 
10),(10 10, 20 20))'));
+% .L # table_name
+% st_mlinefromtext_single_value # name
+% boolean # type
+% 5 # length
+[ false        ]
+#SELECT ST_IsClosed(st_pointfromtext('POINT(10 10)'));
+% .L # table_name
+% st_pointfromtext_single_value # name
+% boolean # type
+% 5 # length
+[ true ]
+#SELECT ST_IsClosed(st_mpointfromtext('MULTIPOINT((10 10), (20 20))'));
+% .L # table_name
+% st_mpointfromtext_single_value # name
+% boolean # type
+% 5 # length
+[ true ]
+#SELECT ST_IsClosed(st_polygonfromtext('POLYGON((10 10 10, 20 20 20, 30 30 30, 
10 10 10))'));
+% .L # table_name
+% st_polygonfromtext_single_value # name
+% boolean # type
+% 5 # length
+[ true ]
+#SELECT ST_IsClosed(st_linefromtext('LINESTRING(10 10 10, 20 20 20, 10 10 
10)'));
+% .L # table_name
+% st_linefromtext_single_value # name
+% boolean # type
+% 5 # length
+[ true ]
+#create table geo (g geometry(linestring, 4326));
+#insert into geo values (st_linefromtext('LINESTRING(10 10, 20 20)', 4326));
+[ 1    ]
+#insert into geo values (st_linefromtext('LINESTRING(10 10, 20 20, 10 10)', 
4326));
+[ 1    ]
+#select st_isclosed(g) from geo;
+% sys.L # table_name
+% st_isclosed_g # name
+% boolean # type
+% 5 # length
+[ false        ]
+[ true ]
+#drop table geo;
+#create table geo (g geometry(polygonz, 4326));
+#insert into geo values (st_polygonfromtext('polygon((10 10 10, 20 20 20, 30 
30 30, 10 10 10))', 4326));
+[ 1    ]
+#select st_isclosed(g) from geo;
+% sys.L # table_name
+% st_isclosed_g # name
+% boolean # type
+% 5 # length
+[ true ]
+#drop table geo;
+#SELECT geom AS "GEOMETRY", ST_IsClosed(geom) FROM geometries;
+% sys.L,       sys.L # table_name
+% GEOMETRY,    st_isclosed_geom # name
+% geometry,    boolean # type
+% 0,   5 # length
+[ "POINT (10 20)",     true    ]
+[ "LINESTRING (10 20, 30 40, 50 60)",  false   ]
+[ "POLYGON ((10 10, 10 20, 20 20, 20 10, 10 10))",     true    ]
+[ "MULTIPOINT (10 20, 30 40)", true    ]
+[ "MULTILINESTRING ((30 40, 40 50), (50 60, 60 70))",  false   ]
+[ "MULTILINESTRING ((30 40, 40 50, 30 40), (50 60, 60 70))",   false   ]
+[ "MULTILINESTRING ((30 40, 40 50, 30 40), (50 60, 40 50, 20 30, 50 60))",     
true    ]
+[ "MULTIPOLYGON (((10 10, 10 20, 20 20, 20 10, 10 10), (30 30, 30 40, 40 40, 
40 30, 30 30)))", true    ]
+[ "GEOMETRYCOLLECTION (POINT (10 20), LINESTRING (10 20, 30 40), POLYGON ((10 
10, 10 20, 20 20, 20 10, 10 10)))",      false   ]
+[ "GEOMETRYCOLLECTION (POINT (10 20), LINESTRING (10 20, 30 40, 10 20), 
POLYGON ((10 10, 10 20, 20 20, 20 10, 10 10)))",       true    ]
+
+# 12:51:38 >  
+# 12:51:38 >  "Done."
+# 12:51:38 >  
+
diff --git a/geom/sql/Tests/functions/Tests/isClosed.sql 
b/geom/sql/Tests/functions/Tests/isClosed.sql
deleted file mode 100644
--- a/geom/sql/Tests/functions/Tests/isClosed.sql
+++ /dev/null
@@ -1,18 +0,0 @@
-SELECT ST_IsClosed(st_linefromtext('LINESTRING(10 10, 20 20)'));
-SELECT ST_IsClosed(st_linefromtext('LINESTRING(10 10, 20 20, 10 10)'));
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to