Changeset: eaf9444138b4 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=eaf9444138b4
Added Files:
        geom/sql/Tests/functions/Tests/ST_MakePoint.sql
        geom/sql/Tests/functions/Tests/ST_MakePoint.stable.err
        geom/sql/Tests/functions/Tests/ST_MakePoint.stable.out
Removed Files:
        geom/sql/Tests/functions/Tests/makePoint.sql
        geom/sql/Tests/functions/Tests/makePoint.stable.err
        geom/sql/Tests/functions/Tests/makePoint.stable.out
Modified Files:
        geom/monetdb5/geom.c
        geom/monetdb5/geom.h
        geom/monetdb5/geom.mal
        geom/monetdb5/geomBulk.c
        geom/sql/40_geom.sql
        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_PointFromText.stable.err
        geom/sql/Tests/functions/Tests/ST_PolygonFromText.stable.err
Branch: geo
Log Message:

ST_MakePoint : mTest + bulk


diffs (truncated from 1675 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
@@ -2433,22 +2433,8 @@ str wkbMLineStringToPolygon(wkb** geomWK
        return MAL_SUCCEED;
 }
 
-static str geomMakePoint(wkb **geomWKB, GEOSGeom geosGeometry) {
-       
-       *geomWKB = geos2wkb(geosGeometry);
-       
-       if(wkb_isnil(*geomWKB)) {
-               *geomWKB = wkb_nil;
-               throw(MAL, "geom.MakePoint", "Failed to crete WKB from 
GEOSGeometry");
-       }
-
-       return MAL_SUCCEED;
-}
-
-/* creates a point using the x, y coordinates */
-str geomMakePoint2D(wkb** out, double* x, double* y) {
+str wkbMakePoint(wkb** out, double *x, double *y, double *z, double *m, int 
*zmFlag) {
        GEOSGeom geosGeometry = NULL;
-       str ret = MAL_SUCCEED;
        GEOSCoordSequence *seq = NULL;
 
        if (*x == dbl_nil || *y == dbl_nil) {
@@ -2457,109 +2443,48 @@ str geomMakePoint2D(wkb** out, double* x
        }
 
        //create the point from the coordinates
-       seq = GEOSCoordSeq_create(1, 2);
-       GEOSCoordSeq_setX(seq, 0, *x);
-       GEOSCoordSeq_setY(seq, 0, *y);
-       geosGeometry = GEOSGeom_createPoint(seq);
-       GEOSSetSRID(geosGeometry, 0);
-
-       if(geosGeometry == NULL){
-               *out = wkb_nil;
-               throw(MAL, "geom.MakePoint", "Failed to create GEOSGeometry 
from the coordiates");
-       }
-
-       ret = geomMakePoint(out, geosGeometry);
-       GEOSGeom_destroy(geosGeometry);
-
-       return ret;
-}
-
-/* creates a point using the x, y, z coordinates */
-str geomMakePoint3D(wkb** out, double* x, double* y, double* z) {
-       GEOSGeom geosGeometry = NULL;
-       str ret = MAL_SUCCEED;
-       GEOSCoordSequence *seq = NULL;
-
-       if (*x == dbl_nil || *y == dbl_nil || *z == dbl_nil) {
-               *out = wkb_nil;
-               return MAL_SUCCEED;
-       }
-
-       //create the point from the coordinates
-       seq = GEOSCoordSeq_create(1, 3);
-       GEOSCoordSeq_setX(seq, 0, *x);
-       GEOSCoordSeq_setY(seq, 0, *y);
-       GEOSCoordSeq_setZ(seq, 0, *z);
-       geosGeometry = GEOSGeom_createPoint(seq);
-
-       if(geosGeometry == NULL){
-               *out = wkb_nil;
-               throw(MAL, "geom.MakePoint", "Failed to create GEOSGeometry 
from the coordiates");
-       }
-
-       ret = geomMakePoint(out, geosGeometry);
-       GEOSGeom_destroy(geosGeometry);
-
-       return ret;
-}
-
-/* creates a point using the x, y, z, m coordinates */
-str geomMakePoint4D(wkb** out, double* x, double* y, double* z, double* m) {
-       GEOSGeom geosGeometry = NULL;
-       str ret = MAL_SUCCEED;
-       GEOSCoordSequence *seq = NULL;
-
-       if (*x == dbl_nil || *y == dbl_nil || *z == dbl_nil || *m == dbl_nil) {
-               *out = wkb_nil;
-               return MAL_SUCCEED;
-       }
-
-       //create the point from the coordinates
-       seq = GEOSCoordSeq_create(1, 4);
-       GEOSCoordSeq_setX(seq, 0, *x);
-       GEOSCoordSeq_setY(seq, 0, *y);
-       GEOSCoordSeq_setZ(seq, 0, *z);
-       GEOSCoordSeq_setOrdinate(seq, 0, 3, *m);
-       geosGeometry = GEOSGeom_createPoint(seq);
-
-       if(geosGeometry == NULL){
-               *out = wkb_nil;
-               throw(MAL, "geomMakePoint", "Failed to create GEOSGeometry from 
the coordiates");
-       }
-
-       ret = geomMakePoint(out, geosGeometry);
-       GEOSGeom_destroy(geosGeometry);
-
-       return ret;
-}
-
-/* creates a point using the x, y, m coordinates */
-str geomMakePointM(wkb** out, double* x, double* y, double* m) {
-       GEOSGeom geosGeometry = NULL;
-       str ret = MAL_SUCCEED;
-       GEOSCoordSequence *seq = NULL;
-
-       if (*x == dbl_nil || *y == dbl_nil || *m == dbl_nil) {
-               *out = wkb_nil;
-               return MAL_SUCCEED;
-       }
-
-       //create the point from the coordinates
-       seq = GEOSCoordSeq_create(1, 3);
+       if(*zmFlag == 0)
+               seq = GEOSCoordSeq_create(1, 2);
+       else if(*zmFlag == 10 || *zmFlag == 1)
+               seq = GEOSCoordSeq_create(1, 3);
+       else if(*zmFlag == 11)
+               throw(MAL, "geom.wkbMakePoint", "POINTZM is not supported");
+
        GEOSCoordSeq_setOrdinate(seq, 0, 0, *x);
        GEOSCoordSeq_setOrdinate(seq, 0, 1, *y);
-       GEOSCoordSeq_setOrdinate(seq, 0, 2, *m);
-       geosGeometry = GEOSGeom_createPoint(seq);
-
-       if(geosGeometry == NULL){
+
+       if(*zmFlag == 10) {
+               if(*z == dbl_nil) {
+                       *out = wkb_nil;
+                       GEOSCoordSeq_destroy(seq);
+                       return MAL_SUCCEED;
+               }
+
+               GEOSCoordSeq_setOrdinate(seq, 0, 2, *z);
+       } else if(*zmFlag == 1) {
+               if(*m == dbl_nil) {
+                       *out = wkb_nil;
+                       GEOSCoordSeq_destroy(seq);
+                       return MAL_SUCCEED;
+               }
+
+               GEOSCoordSeq_setOrdinate(seq, 0, 2, *m);
+       }
+
+       if(!(geosGeometry = GEOSGeom_createPoint(seq))){
                *out = wkb_nil;
-               throw(MAL, "geomMakePoint", "Failed to create GEOSGeometry from 
the coordiates");
-       }
-
-       ret = geomMakePoint(out, geosGeometry);
+               throw(MAL, "geom.wkbMakePoint", "Failed to create GEOSGeometry 
from the coordiates");
+       }
+
+       *out = geos2wkb(geosGeometry);
+       
+       if(wkb_isnil(*out)) {
+               GEOSGeom_destroy(geosGeometry);
+               throw(MAL, "geom.wkbMakePoint", "Failed to crete WKB from 
GEOSGeometry");
+       }
+
        GEOSGeom_destroy(geosGeometry);
-
-       return ret;
+       return MAL_SUCCEED;
 }
 
 /* common code for functions that return integer */
diff --git a/geom/monetdb5/geom.h b/geom/monetdb5/geom.h
--- a/geom/monetdb5/geom.h
+++ b/geom/monetdb5/geom.h
@@ -167,10 +167,8 @@ geom_export str wkbDWithin(bit*, wkb**, 
 
 //geom_export str wkbFromString(wkb**, str*); 
 
-geom_export str geomMakePoint2D(wkb**, double*, double*);
-geom_export str geomMakePoint3D(wkb**, double*, double*, double*);
-geom_export str geomMakePoint4D(wkb**, double*, double*, double*, double*);
-geom_export str geomMakePointM(wkb**, double*, double*, double*);
+geom_export str wkbMakePoint(wkb**, double*, double*, double*, double*, int*);
+geom_export str wkbMakePoint_bat(bat*, bat*, bat*, bat*, bat*, int*);
 
 geom_export str wkbCoordDim(int* , wkb**);
 geom_export str wkbSetSRID(wkb**, wkb**, int*);
@@ -281,11 +279,6 @@ geom_export str wkbContains_bat_geom(int
 geom_export str wkbFilter_geom_bat(int* BATfiltered_id, wkb** geomWKB, int* 
BAToriginal_id);
 geom_export str wkbFilter_bat_geom(int* BATfiltered_id, int* BAToriginal_id, 
wkb** geomWKB);
 
-geom_export str geomMakePoint2D_bat(int* outBAT_id, int* xBAT_id, int* 
yBAT_id);
-geom_export str geomMakePoint3D_bat(int* outBAT_id, int* xBAT_id, int* 
yBAT_id, int* zBAT_id);
-geom_export str geomMakePoint4D_bat(int* outBAT_id, int* xBAT_id, int* 
yBAT_id, int* zBAT_id, int* mBAT_id);
-geom_export str geomMakePointM_bat(int* outBAT_id, int* xBAT_id, int* yBAT_id, 
int* mBAT_id);
-
 geom_export str wkbMakeLine_bat(int* outBAT_id, int* aBAT_id, int* bBAT_id);
 geom_export str wkbUnion_bat(int* outBAT_id, int* aBAT_id, int* bBAT_id);
 
diff --git a/geom/monetdb5/geom.mal b/geom/monetdb5/geom.mal
--- a/geom/monetdb5/geom.mal
+++ b/geom/monetdb5/geom.mal
@@ -184,15 +184,37 @@ function BdMPolyFromText{unsafe}(wkt:str
        return x;
 end BdMPolyFromText;
 
-command MakePoint{unsafe}(x:dbl, y:dbl) :wkb address geomMakePoint2D
+
+command MakePointXYZM(x:dbl, y:dbl, z:dbl, m:dbl, zmFlag:int) :wkb address 
wkbMakePoint
 comment "creates a point using the coordinates";
-command MakePoint{unsafe}(x:dbl, y:dbl, z:dbl) :wkb address geomMakePoint3D
-comment "creates a point using the coordinates";
-#Gives error. I do not know how to create 4d point
-command MakePoint{unsafe}(x:dbl, y:dbl, z:dbl, m:dbl) :wkb address 
geomMakePoint4D
-comment "creates a point using the coordinates";
-command MakePointM{unsafe}(x:dbl, y:dbl, m:dbl) :wkb address geomMakePointM
-comment "creates a point using the coordinates";
+function MakePoint(x:dbl, y:dbl) :wkb;
+       p := MakePointXYZM(x, y, 0:dbl, 0:dbl, 0);
+       return p;
+end MakePoint;
+function MakePoint(x:dbl, y:dbl, z:dbl) :wkb;
+       p := MakePointXYZM(x, y, z, 0:dbl, 10);
+       return p;
+end MakePoint;
+function MakePointM(x:dbl, y:dbl, m:dbl) :wkb;
+       p := MakePointXYZM(x, y, 0:dbl, m, 1);
+       return p;
+end MakePointM;
+function MakePoint(x:dbl, y:dbl, z:dbl, m:dbl) :wkb;
+       p := MakePointXYZM(x, y, z, m, 11);
+       return p;
+end MakePoint;
+
+
+
+#command MakePoint{unsafe}(x:dbl, y:dbl) :wkb address geomMakePoint2D
+#comment "creates a point using the coordinates";
+#command MakePoint{unsafe}(x:dbl, y:dbl, z:dbl) :wkb address geomMakePoint3D
+#comment "creates a point using the coordinates";
+##Gives error. I do not know how to create 4d point
+#command MakePoint{unsafe}(x:dbl, y:dbl, z:dbl, m:dbl) :wkb address 
geomMakePoint4D
+#comment "creates a point using the coordinates";
+#command MakePointM{unsafe}(x:dbl, y:dbl, m:dbl) :wkb address geomMakePointM
+#comment "creates a point using the coordinates";
 
 #Geometry Accessors
 command GeometryType(w:wkb, flag:int) :str address wkbGeometryType;
@@ -580,6 +602,25 @@ function GeometryType2(w:bat[:oid,:wkb])
        return x;
 end GeometryType2;
 
+command MakePointXYZM(x:bat[:oid,:dbl], y:bat[:oid,:dbl], z:bat[:oid,:dbl], 
m:bat[:oid,:dbl], zmFlag:int) :bat[:oid,:wkb] address wkbMakePoint_bat
+comment "creates a point using the coordinates";
+function MakePoint(x:bat[:oid,:dbl], y:bat[:oid,:dbl]) :bat[:oid,:wkb];
+       p := MakePointXYZM(x, y, nil:bat, nil:bat, 0);
+       return p;
+end MakePoint;
+function MakePoint(x:bat[:oid,:dbl], y:bat[:oid,:dbl], z:bat[:oid,:dbl]) 
:bat[:oid,:wkb];
+       p := MakePointXYZM(x, y, z, nil:bat, 10);
+       return p;
+end MakePoint;
+function MakePointM(x:bat[:oid,:dbl], y:bat[:oid,:dbl], m:bat[:oid,:dbl]) 
:bat[:oid,:wkb];
+       p := MakePointXYZM(x, y, nil:bat, m, 1);
+       return p;
+end MakePointM;
+function MakePoint(x:bat[:oid,:dbl], y:bat[:oid,:dbl], z:bat[:oid,:dbl], 
m:bat[:oid,:dbl]) :bat[:oid,:wkb];
+       p := MakePointXYZM(x, y, z, m, 11);
+       return p;
+end MakePoint;
+
 
 command Boundary(w:bat[:oid,:wkb]) :bat[:oid,:wkb] address wkbBoundary_bat;
 
@@ -618,15 +659,7 @@ command Filter(a:bat[:oid,:wkb], b:wkb) 
 #command point(x:bat[:oid,:dbl],y:bat[:oid,:dbl]) :bat[:oid,:wkb]
 #address wkbcreatepoint_bat
 #comment "Construct a point-BAT from two geometry-BATs";
-command MakePoint{unsafe}(x:bat[:oid,:dbl], y:bat[:oid,:dbl]) :bat[:oid,:wkb] 
address geomMakePoint2D_bat
-comment "creates a 2D points BAT using two double BATs";
-command MakePoint{unsafe}(x:bat[:oid,:dbl], y:bat[:oid,:dbl], 
z:bat[:oid,:dbl]) :bat[:oid,:wkb] address geomMakePoint3D_bat
-comment "creates a 3D points BAT using three double BATs";
-#Gives error. I do not know how to create 4d point
-command MakePoint{unsafe}(x:bat[:oid,:dbl], y:bat[:oid,:dbl], 
z:bat[:oid,:dbl], m:bat[:oid,:dbl]) :bat[:oid,:wkb] address geomMakePoint4D_bat
-comment "creates a 4D points BAT using four double BATs";
-command MakePointM{unsafe}(x:bat[:oid,:dbl], y:bat[:oid,:dbl], 
m:bat[:oid,:dbl]) :bat[:oid,:wkb] address geomMakePointM_bat
-comment "creates a 2D with m attribute points BAT using three double BATs";
+
 command setSRID(w:bat[:oid,:wkb], srid:int) :bat[:oid,:wkb] address 
wkbSetSRID_bat
 comment "Sets the Reference System ID for this Geometry.";
 
diff --git a/geom/monetdb5/geomBulk.c b/geom/monetdb5/geomBulk.c
--- a/geom/monetdb5/geomBulk.c
+++ b/geom/monetdb5/geomBulk.c
@@ -677,32 +677,43 @@ str wkbFromWKB_bat(int* outBAT_id, int* 
 
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to