Changeset: b8b677151f55 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b8b677151f55
Modified Files:
geom/monetdb5/Makefile.ag
geom/monetdb5/geom.c
geom/monetdb5/geom.h
geom/monetdb5/geom_clean.c
geom/monetdb5/sfcgal.c
Branch: sfcgal
Log Message:
It compiles, but it is not yet functional because one function is still void.
diffs (truncated from 777 to 300 lines):
diff --git a/geom/monetdb5/Makefile.ag b/geom/monetdb5/Makefile.ag
--- a/geom/monetdb5/Makefile.ag
+++ b/geom/monetdb5/Makefile.ag
@@ -17,7 +17,7 @@ INCLUDES = ../lib \
lib__geom = {
MODULE
DIR = libdir/monetdb5
- SOURCES = geom.h geom.c geomBulk.c geom_upgrade.c geom_geojson.c
geom_x3d.c
+ SOURCES = geom.h geom.c geomBulk.c geom_upgrade.c geom_geojson.c
geom_x3d.c geom_clean.c
LIBS = ../lib/libgeom \
../../gdk/libbat \
../../common/stream/libstream \
diff --git a/geom/monetdb5/geom.c b/geom/monetdb5/geom.c
--- a/geom/monetdb5/geom.c
+++ b/geom/monetdb5/geom.c
@@ -18,6 +18,27 @@ int TYPE_mbr;
static str BATgroupWKBWKBtoWKB(bat *outBAT_id, BAT *b, BAT *g, BAT *e, int
skip_nils, oid min, oid max, BUN ngrp, BUN start, BUN end, wkb **empty_geoms,
str (*func) (wkb **, wkb **, wkb**), char* name);
+static inline int
+geometryHasZ(int info)
+{
+ return (info & 0x02);
+}
+
+static inline int
+geometryHasM(int info)
+{
+ return (info & 0x01);
+}
+static wkb wkb_nil = { ~0, 0 };
+
+static wkb *
+wkbNULLcopy(void)
+{
+ wkb *n = GDKmalloc(sizeof(wkb_nil));
+ if (n)
+ *n = wkb_nil;
+ return n;
+}
/* the first argument in the functions is the return variable */
#ifdef HAVE_PROJ
@@ -4053,7 +4074,7 @@ wkbEndPoint(wkb **out, wkb **geom)
return wkbBorderPoint(out, geom, GEOSGeomGetEndPoint, "geom.EndPoint");
}
-static str
+str
numPointsLineString(unsigned int *out, const GEOSGeometry *geosGeometry)
{
/* get the coordinates of the points comprising the geometry */
diff --git a/geom/monetdb5/geom.h b/geom/monetdb5/geom.h
--- a/geom/monetdb5/geom.h
+++ b/geom/monetdb5/geom.h
@@ -54,27 +54,8 @@
b->tnonil = 0; \
b->tnodense = 1;
-static inline int
-geometryHasZ(int info)
-{
- return (info & 0x02);
-}
-
-static inline int
-geometryHasM(int info)
-{
- return (info & 0x01);
-}
-static wkb wkb_nil = { ~0, 0 };
-
-static wkb *
-wkbNULLcopy(void)
-{
- wkb *n = GDKmalloc(sizeof(wkb_nil));
- if (n)
- *n = wkb_nil;
- return n;
-}
+/*Necessary for external functionality*/
+geom_export str numPointsLineString(unsigned int *out, const GEOSGeometry
*geosGeometry);
/* general functions */
geom_export str geoHasZ(int* res, int* info);
diff --git a/geom/monetdb5/geom_clean.c b/geom/monetdb5/geom_clean.c
--- a/geom/monetdb5/geom_clean.c
+++ b/geom/monetdb5/geom_clean.c
@@ -1,49 +1,14 @@
#include "geom.h"
-static str
-geos_verify(const GEOSGeometry **res, const GEOSGeometry *geom)
-{
- int geometryType = GEOSGeomTypeId(geosGeometry) + 1;
- str msg = MAL_SUCCEED;
-
- switch (geom->type)
- {
- case POINTTYPE:
- case MULTIPOINTTYPE:
- *res = geom;
- break;
- case LINETYPE:
- msg = geos_line_verify(res, geom);
- break;
- case POLYGONTYPE:
- msg = geos_polygon_verify(res, geom);
- break;
- case MULTILINETYPE:
- case MULTIPOLYGONTYPE:
- case COLLECTIONTYPE:
- msg = geos_collection_verify(res, geom);
- break;
- case CIRCSTRINGTYPE:
- case COMPOUNDTYPE:
- case CURVEPOLYTYPE:
- case MULTISURFACETYPE:
- case MULTICURVETYPE:
- default:
- *res = NULL;
- msg = createException(MAL, "geos_verify", "Unknown geometry type");
- break;
- }
-
- return msg;
-}
+static str geos_geom_verify(GEOSGeometry **res, const GEOSGeometry
*geosGeometry);
static str
-geos_ring_verify(const GEOSGeometry **res, const GEOSGeometry *geosGeometry)
+geos_ring_verify(GEOSGeometry **res, const GEOSGeometry *geosGeometry)
{
int closed = 0;
- str err = MAL_SUCCEED;
+ str err = MAL_SUCCEED, msg = MAL_SUCCEED;
unsigned int pointsNum;
- int srid = 0;
+ int srid = 0, j = 0;
/*Check if the ring is closed*/
if ((closed = GEOSisClosed(geosGeometry)) == 2)
@@ -51,20 +16,21 @@ geos_ring_verify(const GEOSGeometry **re
/*If it is not closed, close it*/
if (closed != 1) {
- const GEOSCoordSequence *gcs_new = NULL, *gcs_old;
+ GEOSCoordSequence *gcs_new = NULL;
+ const GEOSCoordSequence *gcs_old = NULL;
srid = GEOSGetSRID(geosGeometry);
double x, y, z;
- int lineDim = 0;
+ int lineDim = 0, i = 0;
if ((err = numPointsLineString(&pointsNum, geosGeometry)) !=
MAL_SUCCEED) {
*res = NULL;
- msg = createException(MAL, "geos_ring_verify",
"numPointsLineString failed:%s", err;
+ msg = createException(MAL, "geos_ring_verify",
"numPointsLineString failed:%s", err);
GDKfree(err);
return msg;
} else {
assert(pointsNum < 4);
//get the coordinate sequences of the LineString
- if (!(gcs_old = GEOSGeom_getCoordSeq(line))) {
+ if (!(gcs_old = GEOSGeom_getCoordSeq(geosGeometry))) {
*res = NULL;
throw(MAL, "geom.AddPoint", "GEOSGeom_getCoordSeq failed");
}
@@ -105,27 +71,26 @@ geos_ring_verify(const GEOSGeometry **re
}
}
//Create new LineString
- if (!(res = GEOSGeom_createLineString(gcs_new))) {
+ if (!(*res = GEOSGeom_createLineString(gcs_new))) {
throw(MAL, "geom.AddPoint", "GEOSGeom_createLineString
failed");
}
- GEOSSetSRID(res, srid);
+ GEOSSetSRID(*res, srid);
}
} else {
- /*We might have to clone it*/
- *res = geosGeometry;
+ *res = GEOSGeom_clone(geosGeometry);
}
return MAL_SUCCEED;
}
-str
-geos_poly_verify(const GEOSGeometry **res, const GEOSGeometry *geosGeometry)
+static str
+geos_polygon_verify(GEOSGeometry **res, const GEOSGeometry *geosGeometry)
{
- const GEOSGeometry *extRing = NULL, *extRres = NULL, **intRings = NULL;
- int numInteriorRings = 0, i = 0, j = 0;
- POINTARRAY **new_rings;
- int i = 0, numIntRings = 0;
+ const GEOSGeometry *extRing = NULL;
+ GEOSGeometry *extRes = NULL, **intRings = NULL;
+ int i = 0, j = 0, numIntRings = 0;
+ str err = MAL_SUCCEED, msg = MAL_SUCCEED;
bit untouched = 1;
/* get the exterior ring of the polygon */
@@ -141,30 +106,30 @@ geos_poly_verify(const GEOSGeometry **re
untouched = 0;
numIntRings = GEOSGetNumInteriorRings(geosGeometry);
- if (numInteriorRings == -1) {
+ if (numIntRings == -1) {
*res = NULL;
throw(MAL, "geos_poly_verify", "GEOSGetNumInteriorRings
failed.");
} else if(numIntRings) {
- if ( (intRings = (const GEOSGeometry **) GDKzalloc(sizeof(const
GEOSGeometry *)*numInteriorRings)) == NULL) {
+ if ( (intRings = (GEOSGeometry **) GDKzalloc(sizeof(GEOSGeometry
*)*numIntRings)) == NULL) {
*res = NULL;
throw(MAL, "geos_poly_verify", MAL_MALLOC_FAIL);
}
- for (i = 0; i < numInteriorRings; i++) {
+ for (i = 0; i < numIntRings; i++) {
const GEOSGeometry *intRing = NULL;
if ((intRing = GEOSGetInteriorRingN(geosGeometry, i)) == NULL) {
msg = createException(MAL, "geos_poly_verify",
"GEOSGetInteriorRingN failed.");
break;
}
- if ( (msg = geos_ring_verify(intRings[i], intRing)) !=
MAL_SUCCEED) {
+ if ( (msg = geos_ring_verify(&intRings[i], intRing)) !=
MAL_SUCCEED) {
break;
} else if (intRings[i] != intRing)
untouched = 0;
}
if (msg != MAL_SUCCEED) {
*res = NULL;
- /*TODO: You should destroy if you are cloning*/
+ /*TODO: You should only destroy if you have clonned it*/
for (j = 0; j < i; j++)
GEOSGeom_destroy(intRings[j]);
GDKfree(intRings);
@@ -174,19 +139,18 @@ geos_poly_verify(const GEOSGeometry **re
/*Create a new geometry*/
if (!untouched) {
- if ( (*res = GEOSGeom_createPolygon(exteriorRingGeometry, intRings,
numInteriorRings)) == NULL) {
- GEOSGeom_destroy(exteriorRingGeometry);
- if (numInteriorRings) {
- /*TODO: You should destroy if you are cloning*/
- for (i = 0; i < numInteriorRings; i++)
+ if ( (*res = GEOSGeom_createPolygon(extRes, intRings, numIntRings)) ==
NULL) {
+ GEOSGeom_destroy(extRes);
+ if (numIntRings) {
+ /*TODO: You should only destroy if you have clonned it*/
+ for (i = 0; i < numIntRings; i++)
GEOSGeom_destroy(intRings[i]);
GDKfree(intRings);
}
return createException(MAL, "geos_poly_verify",
"GEOSGeom_createPolygon failed");
}
} else {
- /*TODO: Maybe we should clone it*/
- *res = geosGeometry;
+ *res = GEOSGeom_clone(geosGeometry);
}
if (intRings)
@@ -196,17 +160,17 @@ geos_poly_verify(const GEOSGeometry **re
}
/*Line has 0 or more than one point. If missing duplicate points*/
-str
-geos_line_verify(const GEOSGeometry **res, const GEOSGeometry *geosGeometry)
+static str
+geos_line_verify(GEOSGeometry **res, const GEOSGeometry *geosGeometry)
{
- unsigned int *pointsN;
+ unsigned int pointsN;
GEOSGeom *ret;
- str err = MAL_SUCCEED;
+ str err = MAL_SUCCEED, msg = MAL_SUCCEED;
int srid = 0;
//get the points in the exterior ring
- if ((err = numPointsLineString(pointsN, lineGeometry)) != MAL_SUCCEED) {
+ if ( (err = numPointsLineString(&pointsN, geosGeometry)) !=
MAL_SUCCEED) {
msg = createException(MAL,"geos_line_verify", "numPointsLineString
failed:%s", err);
GDKfree(err);
*res = NULL;
@@ -214,12 +178,13 @@ geos_line_verify(const GEOSGeometry **re
}
if (pointsN == 1) {
- const GEOSCoordSequence *gcs_new = NULL, *gcs_old;
+ GEOSCoordSequence *gcs_new = NULL;
+ const GEOSCoordSequence *gcs_old = NULL;
srid = GEOSGetSRID(geosGeometry);
double x, y, z;
int lineDim = 0;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list