Changeset: f69cead268c2 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f69cead268c2
Added Files:
geom/sql/Tests/geomFromText.sql
geom/sql/Tests/geomFromText.stable.err
geom/sql/Tests/geomFromText.stable.out
geom/sql/Tests/geometryType.sql
geom/sql/Tests/geometryType.stable.err
geom/sql/Tests/geometryType.stable.out
geom/sql/Tests/makePoint.sql
geom/sql/Tests/makePoint.stable.err
geom/sql/Tests/makePoint.stable.out
Modified Files:
geom/lib/libgeom.h
geom/monetdb5/geom.c
geom/sql/Tests/All
Branch: geo
Log Message:
mTests for makePoint, geomFromText and geometryType
diffs (truncated from 1528 to 300 lines):
diff --git a/geom/lib/libgeom.h b/geom/lib/libgeom.h
--- a/geom/lib/libgeom.h
+++ b/geom/lib/libgeom.h
@@ -100,7 +100,7 @@ typedef enum wkb_type {
//wkbGeometry = 0,
wkbPoint = 1,
wkbLineString = 2,
- wkbPolygon = 3,
+ wkbPolygon = 4,
wkbMultiPoint = 5,
wkbMultiLineString = 6,
wkbMultiPolygon = 7,
diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -160,7 +160,7 @@ void geoHasM(int* res, int* info) {
void geoGetType(char** res, int* info, int flag) {
int type = (*info >> 2);
const char* typeStr=geom_type2str(type, flag) ;
-
+
*res=GDKmalloc(strlen(typeStr));
strcpy(*res, typeStr);
}
@@ -345,6 +345,7 @@ int wkbFROMSTR(char* geomWKT, wkb **geom
GEOSWKTReader *WKT_reader;
if (strcmp(geomWKT, str_nil) == 0) {
+ *geomWKB = GDKmalloc(sizeof(wkb));
**geomWKB = *wkbNULL();
return 0;
}
@@ -356,6 +357,7 @@ int wkbFROMSTR(char* geomWKT, wkb **geom
GEOSWKTReader_destroy(WKT_reader);
if(geosGeometry == NULL){
+ *geomWKB = GDKmalloc(sizeof(wkb));
**geomWKB = *wkbNULL();
return 0;
}
@@ -367,6 +369,7 @@ int wkbFROMSTR(char* geomWKT, wkb **geom
if (GEOSGeomTypeId(geosGeometry) == -1) {
GEOSGeom_destroy(geosGeometry);
+ *geomWKB = GDKmalloc(sizeof(wkb));
**geomWKB = *wkbNULL();
return 0;
}
@@ -498,31 +501,14 @@ str wkbAsText(str *r, wkb **w) {
throw(MAL, "geom.AsText", "Failed to create Text from Well Known
Format");
}
-static str geomMakePoint(wkb **out, GEOSGeom geosGeometry) {
- unsigned char* wkbSer = NULL;
- size_t wkbLen = 0;
-
- //creates the wkbSer from the GeosGeometry structure
- wkbSer = GEOSGeomToWKB_buf(geosGeometry, &wkbLen);
- GEOSGeom_destroy(geosGeometry);
-
- if(!wkbSer) {
- *out = wkb_nil;
- throw(MAL, "geomMakePoint", "Failed to create wkb from
GEOSGeometry");
+static str geomMakePoint(wkb **geomWKB, GEOSGeom geosGeometry) {
+
+ *geomWKB = geos2wkb(geosGeometry);
+
+ if(wkb_isnil(*geomWKB)) {
+ *geomWKB = wkb_nil;
+ throw(MAL, "geomMakePoint", "Failed to crete WKB from
GEOSGeometry");
}
-
- assert(wkbLen <= GDK_int_max);
- *out = GDKmalloc((int) wkb_size(wkbLen));
-
- if(*out == NULL) {
- *out = wkb_nil;
- throw(MAL, "geomMakePoint", "Failed to reserve memory for
*wkb");
- }
-
- (*out)->len = (int) wkbLen;
- memcpy(&(*out)->data, wkbSer, wkbLen);
- GEOSFree(wkbSer);
-
return MAL_SUCCEED;
}
@@ -535,6 +521,7 @@ str geomMakePoint2D(wkb** out, double* x
GEOSCoordSeq_setX(seq, 0, *x);
GEOSCoordSeq_setY(seq, 0, *y);
geosGeometry = GEOSGeom_createPoint(seq);
+ GEOSSetSRID(geosGeometry, 0);
if(geosGeometry == NULL){
*out = wkb_nil;
diff --git a/geom/sql/Tests/All b/geom/sql/Tests/All
--- a/geom/sql/Tests/All
+++ b/geom/sql/Tests/All
@@ -4,4 +4,8 @@ polygonFromText
mpointFromText
mlineFromText
mpolygonFromText
+makePoint
+geomFromText
+geometryType
+
diff --git a/geom/sql/Tests/geomFromText.sql b/geom/sql/Tests/geomFromText.sql
new file mode 100644
--- /dev/null
+++ b/geom/sql/Tests/geomFromText.sql
@@ -0,0 +1,191 @@
+create table points_tbl(g geometry(point));
+insert into points_tbl values (st_geomfromtext('point(0 10)'));
+insert into points_tbl values (st_geomfromtext('point(0 20)', 4326));
+insert into points_tbl values (st_geomfromtext('point(0 20)', 0));
+insert into points_tbl values (st_geomfromtext('linestring(10 10, 20 20, 30
40)'));
+select * from points_tbl;
+drop table points_tbl;
+
+create table points_tbl(g geometry(point, 4326));
+insert into points_tbl values (st_geomfromtext('point(0 10)', 4326));
+insert into points_tbl values (st_geomfromtext('point(0 20)'));
+insert into points_tbl values (st_geomfromtext('point(0 20)', 0));
+insert into points_tbl values (st_geomfromtext('linestring(10 10, 20 20, 30
40)', 4329));
+select * from points_tbl;
+drop table points_tbl;
+
+create table points_tbl(g geometry(pointz));
+insert into points_tbl values (st_geomfromtext('point(0 10 20)'));
+insert into points_tbl values (st_geomfromtext('point(0 20 20)', 4326));
+insert into points_tbl values (st_geomfromtext('point(0 20 20)', 0));
+insert into points_tbl values (st_geomfromtext('linestring(10 10, 20 20, 30
40)'));
+select * from points_tbl;
+drop table points_tbl;
+
+create table points_tbl(g geometry(pointz, 4326));
+insert into points_tbl values (st_geomfromtext('point(0 10 20)', 4326));
+insert into points_tbl values (st_geomfromtext('point(0 20 20)'));
+insert into points_tbl values (st_geomfromtext('point(0 20 20)', 0));
+insert into points_tbl values (st_geomfromtext('linestring(10 10, 20 20, 30
40)', 4326));
+select * from points_tbl;
+drop table points_tbl;
+
+create table lines_tbl(g geometry(linestring));
+insert into lines_tbl values (st_geomfromtext('linestring(10 10, 20 20, 30
30)'));
+insert into lines_tbl values (st_geomfromtext('linestring(20 20, 30 30, 40
40)', 4326));
+insert into lines_tbl values (st_geomfromtext('linestring(30 30, 40 40, 50
50)', 0));
+insert into lines_tbl values (st_geomfromtext('point(0 0)'));
+select * from lines_tbl;
+drop table lines_tbl;
+
+create table lines_tbl(g geometry(linestring, 4326));
+insert into lines_tbl values (st_geomfromtext('linestring(10 10, 20 20, 30
30)'));
+insert into lines_tbl values (st_geomfromtext('linestring(20 20, 30 30, 40
40)', 4326));
+insert into lines_tbl values (st_geomfromtext('linestring(30 30, 40 40, 50
50)', 0));
+insert into lines_tbl values (st_geomfromtext('point(0 0)', 4326));
+select * from lines_tbl;
+drop table lines_tbl;
+
+create table lines_tbl(g geometry(linestringz));
+insert into lines_tbl values (st_geomfromtext('linestring(10 10 10, 20 20 20,
30 30 30)'));
+insert into lines_tbl values (st_geomfromtext('linestring(20 20 20, 30 30 30,
40 40 40)', 4326));
+insert into lines_tbl values (st_geomfromtext('linestring(30 30 30, 40 40 40,
50 50 50)', 0));
+insert into lines_tbl values (st_geomfromtext('point(0 0 0)'));
+select * from lines_tbl;
+drop table lines_tbl;
+
+create table lines_tbl(g geometry(linestringz, 4326));
+insert into lines_tbl values (st_geomfromtext('linestring(10 10 10, 20 20 20,
30 30 30)'));
+insert into lines_tbl values (st_geomfromtext('linestring(20 20 20, 30 30 30,
40 40 40)', 4326));
+insert into lines_tbl values (st_geomfromtext('linestring(30 30 30, 40 40 40,
50 50 50)', 0));
+insert into lines_tbl values (st_geomfromtext('point(0 0 0)', 4326));
+select * from lines_tbl;
+drop table lines_tbl;
+
+create table polygons_tbl(g geometry(polygon));
+insert into polygons_tbl values (st_geomfromtext('polygon((10 10, 20 20, 30
30, 10 10))'));
+insert into polygons_tbl values (st_geomfromtext('polygon((20 20, 30 30, 40
40, 20 20))', 4326));
+insert into polygons_tbl values (st_geomfromtext('polygon((30 30, 40 40, 50
50, 30 30))', 0));
+insert into polygons_tbl values (st_geomfromtext('linestring(10 10, 20 20, 30
40)'));
+select * from polygons_tbl;
+drop table polygons_tbl;
+
+create table polygons_tbl(g geometry(polygon, 4326));
+insert into polygons_tbl values (st_geomfromtext('polygon((10 10, 20 20, 30
30, 10 10))'));
+insert into polygons_tbl values (st_geomfromtext('polygon((20 20, 30 30, 40
40, 20 20))', 4326));
+insert into polygons_tbl values (st_geomfromtext('polygon((30 30, 40 40, 50
50, 30 30))', 0));
+insert into polygons_tbl values (st_geomfromtext('linestring(10 10, 20 20, 30
40)', 4326));
+select * from polygons_tbl;
+drop table polygons_tbl;
+
+create table polygons_tbl(g geometry(polygonz));
+insert into polygons_tbl values (st_geomfromtext('polygon((10 10 10, 20 20 20,
30 30 30, 10 10 10))'));
+insert into polygons_tbl values (st_geomfromtext('polygon((20 20 20, 30 30 30,
40 40 40, 20 20 20))', 4326));
+insert into polygons_tbl values (st_geomfromtext('polygon((30 30 30, 40 40 40,
50 50 50, 30 30 30))', 0));
+insert into polygons_tbl values (st_geomfromtext('linestring(10 10 10, 20 20
20, 30 30 30)'));
+select * from polygons_tbl;
+drop table polygons_tbl;
+
+create table polygons_tbl(g geometry(polygonz, 4326));
+insert into polygons_tbl values (st_geomfromtext('polygon((10 10 10, 20 20 20,
30 30 30, 10 10 10))'));
+insert into polygons_tbl values (st_geomfromtext('polygon((20 20 20, 30 30 30,
40 40 40, 20 20 20))', 4326));
+insert into polygons_tbl values (st_geomfromtext('polygon((30 30 30, 40 40 40,
50 50 50, 30 30 30))', 0));
+insert into polygons_tbl values (st_geomfromtext('linestring(10 10 10, 20 20
20, 30 30 30)', 4326));
+select * from polygons_tbl;
+drop table polygons_tbl;
+
+create table points_tbl(g geometry(multipoint));
+insert into points_tbl values (st_geomfromtext('multipoint(10 10, 20 20)'));
+insert into points_tbl values (st_geomfromtext('multipoint(20 20, 30 30)',
4326));
+insert into points_tbl values (st_geomfromtext('multipoint(30 30, 40 40)', 0));
+insert into points_tbl values (st_geomfromtext('linestring(10 10, 20 20, 30
40)'));
+select * from points_tbl;
+drop table points_tbl;
+
+create table points_tbl(g geometry(multipoint, 4326));
+insert into points_tbl values (st_geomfromtext('multipoint(10 10, 20 20)'));
+insert into points_tbl values (st_geomfromtext('multipoint(20 20, 30 30)',
4326));
+insert into points_tbl values (st_geomfromtext('multipoint(30 30, 40 40)', 0));
+insert into points_tbl values (st_geomfromtext('linestring(10 10, 20 20, 30
40)', 4326));
+select * from points_tbl;
+drop table points_tbl;
+
+create table points_tbl(g geometry(multipointz));
+insert into points_tbl values (st_geomfromtext('multipoint(10 10 10, 20 20
20)'));
+insert into points_tbl values (st_geomfromtext('multipoint(20 20 20, 30 30
30)', 4326));
+insert into points_tbl values (st_geomfromtext('multipoint(30 30 30, 40 40
40)', 0));
+insert into points_tbl values (st_geomfromtext('linestring(10 10 10, 20 20 20,
30 30 40)'));
+select * from points_tbl;
+drop table points_tbl;
+
+create table points_tbl(g geometry(multipointz, 4326));
+insert into points_tbl values (st_geomfromtext('multipoint(10 10 10, 20 20
20)'));
+insert into points_tbl values (st_geomfromtext('multipoint(20 20 20, 30 30
30)', 4326));
+insert into points_tbl values (st_geomfromtext('multipoint(30 30 30, 40 40
40)', 0));
+insert into points_tbl values (st_geomfromtext('linestring(10 10 10, 20 20 20,
30 30 30)', 4326));
+select * from points_tbl;
+drop table points_tbl;
+
+create table lines_tbl(g geometry(multilinestring));
+insert into lines_tbl values (st_geomfromtext('multilinestring((10 10, 20 20,
30 30), (40 40, 50 50, 60 60))'));
+insert into lines_tbl values (st_geomfromtext('multilinestring((20 20, 30 30,
40 40), (50 50, 60 60, 70 70))', 4326));
+insert into lines_tbl values (st_geomfromtext('multilinestring((30 30, 40 40,
50 50), (60 60, 70 70, 80 80))', 0));
+insert into lines_tbl values (st_geomfromtext('point(0 0)'));
+select * from lines_tbl;
+drop table lines_tbl;
+
+create table lines_tbl(g geometry(multilinestring, 4326));
+insert into lines_tbl values (st_geomfromtext('multilinestring((10 10, 20 20,
30 30), (40 40, 50 50, 60 60))'));
+insert into lines_tbl values (st_geomfromtext('multilinestring((20 20, 30 30,
40 40), (50 50, 60 60, 70 70))', 4326));
+insert into lines_tbl values (st_geomfromtext('multilinestring((30 30, 40 40,
50 50), (60 60, 70 70, 80 80))', 0));
+insert into lines_tbl values (st_geomfromtext('point(0 0)', 4326));
+select * from lines_tbl;
+drop table lines_tbl;
+
+create table lines_tbl(g geometry(multilinestringz));
+insert into lines_tbl values (st_geomfromtext('multilinestring((10 10 10, 20
20 20, 30 30 30), (40 40 40, 50 50 50, 60 60 60))'));
+insert into lines_tbl values (st_geomfromtext('multilinestring((20 20 20, 30
30 30, 40 40 40), (50 50 50, 60 60 60, 70 70 70))', 4326));
+insert into lines_tbl values (st_geomfromtext('multilinestring((30 30 30, 40
40 40, 50 50 50), (60 60 60, 70 70 70, 80 80 80))', 0));
+insert into lines_tbl values (st_geomfromtext('point(0 0)'));
+select * from lines_tbl;
+drop table lines_tbl;
+
+create table lines_tbl(g geometry(multilinestringz, 4326));
+insert into lines_tbl values (st_geomfromtext('multilinestring((10 10 10, 20
20 20, 30 30 30), (40 40 40, 50 50 50, 60 60 60))'));
+insert into lines_tbl values (st_geomfromtext('multilinestring((20 20 20, 30
30 30, 40 40 40), (50 50 50, 60 60 60, 70 70 70))', 4326));
+insert into lines_tbl values (st_geomfromtext('multilinestring((30 30 30, 40
40 40, 50 50 50), (60 60 60, 70 70 70, 80 80 80))', 0));
+insert into lines_tbl values (st_geomfromtext('point(0 0)', 4326));
+select * from lines_tbl;
+drop table lines_tbl;
+
+create table polygons_tbl(g geometry(multipolygon));
+insert into polygons_tbl values (st_geomfromtext('multipolygon(((10 10, 20 20,
30 30, 10 10),(100 100, 200 200, 300 300, 100 100)))'));
+insert into polygons_tbl values (st_geomfromtext('multipolygon(((20 20, 30 30,
40 40, 20 20),(200 200, 300 300, 400 400, 200 200)))', 4326));
+insert into polygons_tbl values (st_geomfromtext('multipolygon(((30 30, 40 40,
50 50, 30 30),(300 300, 400 400, 500 500, 300 300)))', 0));
+insert into polygons_tbl values (st_geomfromtext('linestring(10 10, 20 20, 30
40)'));
+select * from polygons_tbl;
+drop table polygons_tbl;
+
+create table polygons_tbl(g geometry(multipolygon, 4326));
+insert into polygons_tbl values (st_geomfromtext('multipolygon(((10 10, 20 20,
30 30, 10 10),(100 100, 200 200, 300 300, 100 100)))'));
+insert into polygons_tbl values (st_geomfromtext('multipolygon(((20 20, 30 30,
40 40, 20 20),(200 200, 300 300, 400 400, 200 200)))', 4326));
+insert into polygons_tbl values (st_geomfromtext('multipolygon(((30 30, 40 40,
50 50, 30 30),(300 300, 400 400, 500 500, 300 300)))', 0));
+insert into polygons_tbl values (st_geomfromtext('linestring(10 10, 20 20, 30
40)', 4326));
+select * from polygons_tbl;
+drop table polygons_tbl;
+
+create table polygons_tbl(g geometry(multipolygonz));
+insert into polygons_tbl values (st_geomfromtext('multipolygon(((10 10 10, 20
20 20, 30 30 30, 10 10 10),(100 100 100, 200 200 200, 300 300 300, 100 100
100)))'));
+insert into polygons_tbl values (st_geomfromtext('multipolygon(((20 20 20, 30
30 30, 40 40 40, 20 20 20),(200 200 200, 300 300 300, 400 400 400, 200 200
200)))', 4326));
+insert into polygons_tbl values (st_geomfromtext('multipolygon(((30 30 30, 40
40 40, 50 50 50, 30 30 30),(300 300 300, 400 400 400, 500 500 500, 300 300
300)))', 0));
+insert into polygons_tbl values (st_geomfromtext('linestring(10 10, 20 20, 30
40)'));
+select * from polygons_tbl;
+drop table polygons_tbl;
+
+create table polygons_tbl(g geometry(multipolygonz, 4326));
+insert into polygons_tbl values (st_geomfromtext('multipolygon(((10 10 10, 20
20 20, 30 30 30, 10 10 10),(100 100 100, 200 200 200, 300 300 300, 100 100
100)))'));
+insert into polygons_tbl values (st_geomfromtext('multipolygon(((20 20 20, 30
30 30, 40 40 40, 20 20 20),(200 200 200, 300 300 300, 400 400 400, 200 200
200)))', 4326));
+insert into polygons_tbl values (st_geomfromtext('multipolygon(((30 30 30, 40
40 40, 50 50 50, 30 30 30),(300 300 300, 400 400 400, 500 500 500, 300 300
300)))', 0));
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list