Changeset: 78e571beb414 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=78e571beb414
Modified Files:
geom/monetdb5/geom.c
Branch: Jun2016
Log Message:
Ran through indent.
diffs (truncated from 5817 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
@@ -15,9 +15,18 @@
int TYPE_mbr;
-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 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)
@@ -33,39 +42,46 @@ wkbNULLcopy(void)
#ifdef HAVE_PROJ
/** convert degrees to radians */
-static void degrees2radians(double *x, double *y, double *z) {
- (*x) *= M_PI/180.0;
- (*y) *= M_PI/180.0;
- (*z) *= M_PI/180.0;
+static void
+degrees2radians(double *x, double *y, double *z)
+{
+ (*x) *= M_PI / 180.0;
+ (*y) *= M_PI / 180.0;
+ (*z) *= M_PI / 180.0;
}
/** convert radians to degrees */
-static void radians2degrees(double *x, double *y, double *z) {
- (*x) *= 180.0/M_PI;
- (*y) *= 180.0/M_PI;
- (*z) *= 180.0/M_PI;
-}
-
-static str transformCoordSeq(int idx, int coordinatesNum, projPJ proj4_src,
projPJ proj4_dst, const GEOSCoordSequence* gcs_old, GEOSCoordSequence**
gcs_new){
- double x=0, y=0, z=0;
- int* errorNum =0 ;
+static void
+radians2degrees(double *x, double *y, double *z)
+{
+ (*x) *= 180.0 / M_PI;
+ (*y) *= 180.0 / M_PI;
+ (*z) *= 180.0 / M_PI;
+}
+
+static str
+transformCoordSeq(int idx, int coordinatesNum, projPJ proj4_src, projPJ
proj4_dst, const GEOSCoordSequence *gcs_old, GEOSCoordSequence **gcs_new)
+{
+ double x = 0, y = 0, z = 0;
+ int *errorNum = 0;
GEOSCoordSeq_getX(gcs_old, idx, &x);
GEOSCoordSeq_getY(gcs_old, idx, &y);
- if(coordinatesNum > 2)
+ if (coordinatesNum > 2)
GEOSCoordSeq_getZ(gcs_old, idx, &z);
/* check if the passed reference system is geographic (proj=latlong)
* and change the degrees to radians because pj_transform works with
radians*/
- if (pj_is_latlong(proj4_src)) degrees2radians(&x, &y, &z) ;
+ if (pj_is_latlong(proj4_src))
+ degrees2radians(&x, &y, &z);
pj_transform(proj4_src, proj4_dst, 1, 0, &x, &y, &z);
errorNum = pj_get_errno_ref();
- if (*errorNum != 0){
- if(coordinatesNum >2)
+ if (*errorNum != 0) {
+ if (coordinatesNum > 2)
throw(MAL, "geom.wkbTransform", "Couldn't transform
point (%f %f %f): %s\n", x, y, z, pj_strerrno(*errorNum));
else
throw(MAL, "geom.wkbTransform", "Couldn't transform
point (%f %f): %s\n", x, y, pj_strerrno(*errorNum));
@@ -74,13 +90,14 @@ static str transformCoordSeq(int idx, in
/* check if the destination reference system is geographic and change
* the destination coordinates from radians to degrees */
- if (pj_is_latlong(proj4_dst)) radians2degrees(&x, &y, &z);
+ if (pj_is_latlong(proj4_dst))
+ radians2degrees(&x, &y, &z);
GEOSCoordSeq_setX(*gcs_new, idx, x);
GEOSCoordSeq_setY(*gcs_new, idx, y);
- if(coordinatesNum > 2)
+ if (coordinatesNum > 2)
GEOSCoordSeq_setZ(*gcs_new, idx, z);
@@ -88,9 +105,11 @@ static str transformCoordSeq(int idx, in
return MAL_SUCCEED;
}
-static str transformPoint(GEOSGeometry** transformedGeometry, const
GEOSGeometry* geosGeometry, projPJ proj4_src, projPJ proj4_dst) {
+static str
+transformPoint(GEOSGeometry **transformedGeometry, const GEOSGeometry
*geosGeometry, projPJ proj4_src, projPJ proj4_dst)
+{
int coordinatesNum = 0;
- const GEOSCoordSequence* gcs_old;
+ const GEOSCoordSequence *gcs_old;
GEOSCoordSeq gcs_new;
str ret = MAL_SUCCEED;
@@ -99,7 +118,7 @@ static str transformPoint(GEOSGeometry**
/* get the coordinates of the points comprising the geometry */
gcs_old = GEOSGeom_getCoordSeq(geosGeometry);
- if(gcs_old == NULL) {
+ if (gcs_old == NULL) {
*transformedGeometry = NULL;
throw(MAL, "geom.wkbTransform", "GEOSGeom_getCoordSeq failed");
}
@@ -109,7 +128,7 @@ static str transformPoint(GEOSGeometry**
/* create the transformed coordinates */
ret = transformCoordSeq(0, coordinatesNum, proj4_src, proj4_dst,
gcs_old, &gcs_new);
- if(ret != MAL_SUCCEED) {
+ if (ret != MAL_SUCCEED) {
*transformedGeometry = NULL;
return ret;
}
@@ -120,10 +139,12 @@ static str transformPoint(GEOSGeometry**
return MAL_SUCCEED;
}
-static str transformLine(GEOSCoordSeq *gcs_new, const GEOSGeometry*
geosGeometry, projPJ proj4_src, projPJ proj4_dst) {
+static str
+transformLine(GEOSCoordSeq *gcs_new, const GEOSGeometry *geosGeometry, projPJ
proj4_src, projPJ proj4_dst)
+{
int coordinatesNum = 0;
- const GEOSCoordSequence* gcs_old;
- unsigned int pointsNum =0, i=0;
+ const GEOSCoordSequence *gcs_old;
+ unsigned int pointsNum = 0, i = 0;
str ret = MAL_SUCCEED;
/* get the number of coordinates the geometry has */
@@ -131,7 +152,7 @@ static str transformLine(GEOSCoordSeq *g
/* get the coordinates of the points comprising the geometry */
gcs_old = GEOSGeom_getCoordSeq(geosGeometry);
- if(gcs_old == NULL)
+ if (gcs_old == NULL)
throw(MAL, "geom.wkbTransform", "GEOSGeom_getCoordSeq failed");
/* get the number of points in the geometry */
@@ -141,9 +162,9 @@ static str transformLine(GEOSCoordSeq *g
*gcs_new = GEOSCoordSeq_create(pointsNum, coordinatesNum);
/* create the transformed coordinates */
- for(i=0; i<pointsNum; i++) {
+ for (i = 0; i < pointsNum; i++) {
ret = transformCoordSeq(i, coordinatesNum, proj4_src,
proj4_dst, gcs_old, gcs_new);
- if(ret != MAL_SUCCEED) {
+ if (ret != MAL_SUCCEED) {
GEOSCoordSeq_destroy(*gcs_new);
gcs_new = NULL;
return ret;
@@ -154,13 +175,15 @@ static str transformLine(GEOSCoordSeq *g
return MAL_SUCCEED;
}
-static str transformLineString(GEOSGeometry** transformedGeometry, const
GEOSGeometry* geosGeometry, projPJ proj4_src, projPJ proj4_dst) {
+static str
+transformLineString(GEOSGeometry **transformedGeometry, const GEOSGeometry
*geosGeometry, projPJ proj4_src, projPJ proj4_dst)
+{
GEOSCoordSeq coordSeq;
str ret = MAL_SUCCEED;
ret = transformLine(&coordSeq, geosGeometry, proj4_src, proj4_dst);
- if(ret != MAL_SUCCEED) {
+ if (ret != MAL_SUCCEED) {
*transformedGeometry = NULL;
return ret;
}
@@ -171,13 +194,15 @@ static str transformLineString(GEOSGeome
return ret;
}
-static str transformLinearRing(GEOSGeometry** transformedGeometry, const
GEOSGeometry* geosGeometry, projPJ proj4_src, projPJ proj4_dst) {
+static str
+transformLinearRing(GEOSGeometry **transformedGeometry, const GEOSGeometry
*geosGeometry, projPJ proj4_src, projPJ proj4_dst)
+{
GEOSCoordSeq coordSeq = NULL;
str ret = MAL_SUCCEED;
ret = transformLine(&coordSeq, geosGeometry, proj4_src, proj4_dst);
- if(ret != MAL_SUCCEED) {
+ if (ret != MAL_SUCCEED) {
*transformedGeometry = NULL;
return ret;
}
@@ -188,39 +213,41 @@ static str transformLinearRing(GEOSGeome
return ret;
}
-static str transformPolygon(GEOSGeometry** transformedGeometry, const
GEOSGeometry* geosGeometry, projPJ proj4_src, projPJ proj4_dst, int srid) {
- const GEOSGeometry* exteriorRingGeometry;
- GEOSGeometry* transformedExteriorRingGeometry = NULL;
- GEOSGeometry** transformedInteriorRingGeometries = NULL;
- int numInteriorRings=0, i=0;
+static str
+transformPolygon(GEOSGeometry **transformedGeometry, const GEOSGeometry
*geosGeometry, projPJ proj4_src, projPJ proj4_dst, int srid)
+{
+ const GEOSGeometry *exteriorRingGeometry;
+ GEOSGeometry *transformedExteriorRingGeometry = NULL;
+ GEOSGeometry **transformedInteriorRingGeometries = NULL;
+ int numInteriorRings = 0, i = 0;
str ret = MAL_SUCCEED;
/* get the exterior ring of the polygon */
exteriorRingGeometry = GEOSGetExteriorRing(geosGeometry);
- if(!exteriorRingGeometry) {
+ if (!exteriorRingGeometry) {
*transformedGeometry = NULL;
- throw(MAL, "geom.wkbTransform","GEOSGetExteriorRing failed");
+ throw(MAL, "geom.wkbTransform", "GEOSGetExteriorRing failed");
}
ret = transformLinearRing(&transformedExteriorRingGeometry,
exteriorRingGeometry, proj4_src, proj4_dst);
- if(ret != MAL_SUCCEED) {
+ if (ret != MAL_SUCCEED) {
*transformedGeometry = NULL;
return ret;
}
GEOSSetSRID(transformedExteriorRingGeometry, srid);
numInteriorRings = GEOSGetNumInteriorRings(geosGeometry);
- if (numInteriorRings == -1 ) {
+ if (numInteriorRings == -1) {
*transformedGeometry = NULL;
GEOSGeom_destroy(transformedExteriorRingGeometry);
throw(MAL, "geom.wkbTransform", "GEOSGetInteriorRingN failed.");
}
/* iterate over the interiorRing and transform each one of them */
- transformedInteriorRingGeometries =
GDKmalloc(numInteriorRings*sizeof(GEOSGeometry*));
- for(i=0; i<numInteriorRings; i++) {
+ transformedInteriorRingGeometries = GDKmalloc(numInteriorRings *
sizeof(GEOSGeometry *));
+ for (i = 0; i < numInteriorRings; i++) {
ret =
transformLinearRing(&(transformedInteriorRingGeometries[i]),
GEOSGetInteriorRingN(geosGeometry, i), proj4_src, proj4_dst);
- if(ret != MAL_SUCCEED) {
+ if (ret != MAL_SUCCEED) {
GDKfree(*transformedInteriorRingGeometries);
*transformedGeometry = NULL;
return ret;
@@ -232,21 +259,23 @@ static str transformPolygon(GEOSGeometry
return MAL_SUCCEED;
}
-static str transformMultiGeometry(GEOSGeometry** transformedGeometry, const
GEOSGeometry* geosGeometry, projPJ proj4_src, projPJ proj4_dst, int srid, int
geometryType) {
+static str
+transformMultiGeometry(GEOSGeometry **transformedGeometry, const GEOSGeometry
*geosGeometry, projPJ proj4_src, projPJ proj4_dst, int srid, int geometryType)
+{
int geometriesNum, subGeometryType, i;
- GEOSGeometry** transformedMultiGeometries = NULL;
- const GEOSGeometry* multiGeometry = NULL;
+ GEOSGeometry **transformedMultiGeometries = NULL;
+ const GEOSGeometry *multiGeometry = NULL;
str ret = MAL_SUCCEED;
geometriesNum = GEOSGetNumGeometries(geosGeometry);
- transformedMultiGeometries =
GDKmalloc(geometriesNum*sizeof(GEOSGeometry*));
-
- for(i=0; i<geometriesNum; i++) {
+ transformedMultiGeometries = GDKmalloc(geometriesNum *
sizeof(GEOSGeometry *));
+
+ for (i = 0; i < geometriesNum; i++) {
multiGeometry = GEOSGetGeometryN(geosGeometry, i);
- subGeometryType = GEOSGeomTypeId(multiGeometry)+1;
-
- switch(subGeometryType) {
+ subGeometryType = GEOSGeomTypeId(multiGeometry) + 1;
+
+ switch (subGeometryType) {
case wkbPoint_mdb:
ret = transformPoint(&(transformedMultiGeometries[i]),
multiGeometry, proj4_src, proj4_dst);
break;
@@ -264,7 +293,7 @@ static str transformMultiGeometry(GEOSGe
ret = createException(MAL, "geom.Transform", "Unknown
geometry type");
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list