Changeset: 96d679f48abe for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=96d679f48abe
Modified Files:
        geom/monetdb5/geom.c
        geom/monetdb5/geom.h
        geom/monetdb5/geom.mal
        geom/monetdb5/geomBulk.c
Branch: sfcgal
Log Message:

MakePolygon should not accept a BAT as input and then not do anything with it. 
It will clash with bulk version. MakePoint should not take SRID as arguments, 
it does not align with the standards


diffs (250 lines):

diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -2916,7 +2916,7 @@ wkbMLineStringToPolygon(wkb **geomWKB, s
                        goto bailout;
                }
 
-               ret = wkbMakePolygon(&polygonWKB, &linestringsWKB[i - 1], NULL, 
srid);
+               ret = wkbMakePolygon(&polygonWKB, &linestringsWKB[i - 1], srid);
                if (ret != MAL_SUCCEED) {
                        itemsNum = i;
                        goto bailout;
@@ -3072,7 +3072,7 @@ wkbMLineStringToPolygon(wkb **geomWKB, s
 }
 
 str
-wkbMakePoint(wkb **out, dbl *x, dbl *y, dbl *z, dbl *m, int *zmFlag, int *srid)
+wkbMakePoint(wkb **out, dbl *x, dbl *y, dbl *z, dbl *m, int *zmFlag)
 {
        GEOSGeom geosGeometry;
        GEOSCoordSeq seq;
@@ -3114,9 +3114,6 @@ wkbMakePoint(wkb **out, dbl *x, dbl *y, 
                throw(MAL, "geom.MakePoint", "Failed to create GEOSGeometry 
from the coordinates");
        }
 
-    if (*srid)
-       GEOSSetSRID(geosGeometry, *srid);
-
        *out = geos2wkb(geosGeometry);
        GEOSGeom_destroy(geosGeometry);
 
@@ -3362,7 +3359,7 @@ wkbEnvelopeFromCoordinates(wkb **out, db
 }
 
 str
-wkbMakePolygon(wkb **out, wkb **external, bat *internalBAT_id, int *srid)
+wkbMakePolygon(wkb **out, wkb **external, int *srid)
 {
        GEOSGeom geosGeometry, externalGeometry, linearRingGeometry;
        bit closed = 0;
@@ -3404,19 +3401,13 @@ wkbMakePolygon(wkb **out, wkb **external
                throw(MAL, "geom.Polygon", "GEOSGeom_createLinearRing failed");
        }
 
-       //create a polygon using the linearRing
-       if (internalBAT_id == NULL) {
-               geosGeometry = GEOSGeom_createPolygon(linearRingGeometry, NULL, 
0);
-               if (geosGeometry == NULL) {
-                       *out = NULL;
-                       GEOSGeom_destroy(linearRingGeometry);
-                       throw(MAL, "geom.Polygon", "Error creating Polygon from 
LinearRing");
-               }
-       } else {
-               /* TODO: Looks like incomplete code: what should be
-                * done with internalBAT_id? --sjoerd */
-               geosGeometry = NULL;
-       }
+    //create a polygon using the linearRing
+    geosGeometry = GEOSGeom_createPolygon(linearRingGeometry, NULL, 0);
+    if (geosGeometry == NULL) {
+        *out = NULL;
+        GEOSGeom_destroy(linearRingGeometry);
+        throw(MAL, "geom.Polygon", "Error creating Polygon from LinearRing");
+    }
 
        GEOSSetSRID(geosGeometry, *srid);
 
diff --git a/geom/monetdb5/geom.h b/geom/monetdb5/geom.h
--- a/geom/monetdb5/geom.h
+++ b/geom/monetdb5/geom.h
@@ -159,8 +159,8 @@ geom_export str wkbDWithin(bit*, wkb**, 
 
 //geom_export str wkbFromString(wkb**, str*); 
 
-geom_export str wkbMakePoint(wkb**, dbl*, dbl*, dbl*, dbl*, int*, int*);
-geom_export str wkbMakePoint_bat(bat*, bat*, bat*, bat*, bat*, int*, int*);
+geom_export str wkbMakePoint(wkb**, dbl*, dbl*, dbl*, dbl*, 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*);
@@ -178,7 +178,7 @@ geom_export str numPointsGeometry(unsign
 geom_export str wkbPointN(wkb **out, wkb **geom, int *n);
 geom_export str wkbEnvelope(wkb **out, wkb **geom);
 geom_export str wkbEnvelopeFromCoordinates(wkb** out, dbl* xmin, dbl* ymin, 
dbl* xmax, dbl* ymax, int* srid);
-geom_export str wkbMakePolygon(wkb** out, wkb** external, bat* internalBAT_id, 
int* srid);
+geom_export str wkbMakePolygon(wkb** out, wkb** external, int* srid); /*Only 
Polygons without holes*/
 geom_export str wkbMakeLine(wkb**, wkb**, wkb**);
 geom_export str wkbMakeLineAggr(wkb** outWKB, bat* inBAT_id);
 geom_export str wkbExteriorRing(wkb**, wkb**);
diff --git a/geom/monetdb5/geom.mal b/geom/monetdb5/geom.mal
--- a/geom/monetdb5/geom.mal
+++ b/geom/monetdb5/geom.mal
@@ -174,45 +174,24 @@ function BdMPolyFromText(wkt:str, srid:i
 end BdMPolyFromText;
 
 
-command MakePointXYZM(x:dbl, y:dbl, z:dbl, m:dbl, zmFlag:int, srid:int) :wkb 
address wkbMakePoint
+command MakePointXYZM(x:dbl, y:dbl, z:dbl, m:dbl, zmFlag:int) :wkb address 
wkbMakePoint
 comment "creates a point using the coordinates";
 function MakePoint(x:dbl, y:dbl) :wkb;
-       p := MakePointXYZM(x, y, 0:dbl, 0:dbl, 0, 0);
+       p := MakePointXYZM(x, y, 0:dbl, 0:dbl, 0);
        return p;
 end MakePoint;
-function MakePoint(x:dbl, y:dbl, srid:int) :wkb;
-       p := MakePointXYZM(x, y, 0:dbl, 0:dbl, 0, srid);
+function MakePoint(x:dbl, y:dbl, z:dbl) :wkb;
+       p := MakePointXYZM(x, y, z, 0:dbl, 10);
        return p;
 end MakePoint;
-
-function MakePoint(x:dbl, y:dbl, z:dbl) :wkb;
-       p := MakePointXYZM(x, y, z, 0:dbl, 10, 0);
+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;
-function MakePoint(x:dbl, y:dbl, z:dbl, srid:int) :wkb;
-       p := MakePointXYZM(x, y, z, 0:dbl, 10, srid);
-       return p;
-end MakePoint;
-
-function MakePointM(x:dbl, y:dbl, m:dbl) :wkb;
-       p := MakePointXYZM(x, y, 0:dbl, m, 1, 0);
-       return p;
-end MakePointM;
-function MakePointM(x:dbl, y:dbl, m:dbl, srid:int) :wkb;
-       p := MakePointXYZM(x, y, 0:dbl, m, 1, srid);
-       return p;
-end MakePointM;
-
-function MakePoint(x:dbl, y:dbl, z:dbl, m:dbl) :wkb;
-       p := MakePointXYZM(x, y, z, m, 11, 0);
-       return p;
-end MakePoint;
-function MakePoint(x:dbl, y:dbl, z:dbl, m:dbl, srid:int) :wkb;
-       p := MakePointXYZM(x, y, z, m, 11, srid);
-       return p;
-end MakePoint;
-
-
 
 #command MakePoint(x:dbl, y:dbl) :wkb address geomMakePoint2D
 #comment "creates a point using the coordinates";
@@ -271,7 +250,7 @@ command Envelope(w:wkb) :wkb address wkb
 comment "The minimum bounding box for this Geometry, returned as a Geometry. 
The polygon is defined by the corner points of the bounding box 
((MINX,MINY),(MAXX,MINY),(MAXX,MAXY),(MINX,MAXY)).";
 command EnvelopeFromCoordinates(:dbl, :dbl, :dbl, :dbl, :int) :wkb address 
wkbEnvelopeFromCoordinates
 comment "A polygon created by the provided coordinates";
-command Polygon(:wkb, :bat[:oid,:wkb], :int) :wkb address wkbMakePolygon
+command Polygon(:wkb, :int) :wkb address wkbMakePolygon
 comment "Returns a Polygon created from the provided LineStrings";
 command ExteriorRing(w:wkb) :wkb address wkbExteriorRing
 comment "Returns a line string representing the exterior ring of the POLYGON 
geometry. Return NULL if the geometry is not a polygon.";
@@ -425,11 +404,11 @@ function MakeEnvelope(xmin:dbl, ymin:dbl
 end MakeEnvelope;
 
 function MakePolygon(external:wkb) :wkb;
-       x := Polygon(external, nil:bat, 0);
+       x := Polygon(external, 0);
        return x;
 end MakePolygon;
 function MakePolygon(external:wkb, srid:int) :wkb;
-       x := Polygon(external, nil:bat, srid);
+       x := Polygon(external, srid);
        return x;
 end MakePolygon;
 #function MakePolygon(external:wkb, internal:bat[:oid,:wkb]) :wkb;
@@ -640,42 +619,23 @@ 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, srid:int) :bat[:oid,:wkb] address wkbMakePoint_bat
+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, 0);
+       p := MakePointXYZM(x, y, nil:bat, nil:bat, 0);
        return p;
 end MakePoint;
-function MakePoint(x:bat[:oid,:dbl], y:bat[:oid,:dbl], srid:int) 
:bat[:oid,:wkb];
-       p := MakePointXYZM(x, y, nil:bat, nil:bat, 0, srid);
+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 MakePoint(x:bat[:oid,:dbl], y:bat[:oid,:dbl], z:bat[:oid,:dbl]) 
:bat[:oid,:wkb];
-       p := MakePointXYZM(x, y, z, nil:bat, 10, 0);
-       return p;
-end MakePoint;
-function MakePoint(x:bat[:oid,:dbl], y:bat[:oid,:dbl], z:bat[:oid,:dbl], 
srid:int) :bat[:oid,:wkb];
-       p := MakePointXYZM(x, y, z, nil:bat, 10, srid);
-       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, 0);
+       p := MakePointXYZM(x, y, nil:bat, m, 1);
        return p;
 end MakePointM;
-function MakePointM(x:bat[:oid,:dbl], y:bat[:oid,:dbl], m:bat[:oid,:dbl], 
srid:int) :bat[:oid,:wkb];
-       p := MakePointXYZM(x, y, nil:bat, m, 1, srid);
-       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, 0);
-       return p;
-end MakePoint;
-function MakePoint(x:bat[:oid,:dbl], y:bat[:oid,:dbl], z:bat[:oid,:dbl], 
m:bat[:oid,:dbl], srid:int) :bat[:oid,:wkb];
-       p := MakePointXYZM(x, y, z, m, 11, srid);
+       p := MakePointXYZM(x, y, z, m, 11);
        return p;
 end MakePoint;
 
diff --git a/geom/monetdb5/geomBulk.c b/geom/monetdb5/geomBulk.c
--- a/geom/monetdb5/geomBulk.c
+++ b/geom/monetdb5/geomBulk.c
@@ -368,7 +368,6 @@ WKBtoBIT_bat(bat *outBAT_id, bat *inBAT_
 
        //set the number of elements in the outBAT
        BATsetcount(outBAT, BATcount(inBAT));
-
        BBPunfix(inBAT->batCacheid);
        BBPkeepref(*outBAT_id = outBAT->batCacheid);
 
@@ -816,7 +815,7 @@ wkbFromWKB_bat(bat *outBAT_id, bat *inBA
 /********* Multiple inputs **********/
 /************************************/
 str
-wkbMakePoint_bat(bat *outBAT_id, bat *xBAT_id, bat *yBAT_id, bat *zBAT_id, bat 
*mBAT_id, int *zmFlag, int *srid)
+wkbMakePoint_bat(bat *outBAT_id, bat *xBAT_id, bat *yBAT_id, bat *zBAT_id, bat 
*mBAT_id, int *zmFlag)
 {
        BAT *outBAT = NULL, *xBAT = NULL, *yBAT = NULL, *zBAT = NULL, *mBAT = 
NULL;
        BATiter xBAT_iter, yBAT_iter, zBAT_iter, mBAT_iter;
@@ -868,7 +867,7 @@ wkbMakePoint_bat(bat *outBAT_id, bat *xB
                if (mBAT)
                        m = *((double *) BUNtail(mBAT_iter, i + 
BUNfirst(mBAT)));
 
-        if ((ret = wkbMakePoint(&pointWKB, &x, &y, &z, &m, zmFlag, srid)) != 
MAL_SUCCEED) {    //check
+        if ((ret = wkbMakePoint(&pointWKB, &x, &y, &z, &m, zmFlag)) != 
MAL_SUCCEED) {  //check
             BBPunfix(outBAT->batCacheid);
             goto clean;
         }
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to