Changeset: 7c79f1aa066e for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7c79f1aa066e
Modified Files:
geom/monetdb5/geom.c
Branch: geo
Log Message:
Layout.
diffs (truncated from 3233 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
@@ -43,15 +43,15 @@ static str transformCoordSeq(int idx, in
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*/
+ /* 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) ;
-
+
pj_transform(proj4_src, proj4_dst, 1, 0, &x, &y, &z);
errorNum = pj_get_errno_ref();
@@ -64,14 +64,14 @@ static str transformCoordSeq(int idx, in
/* check if the destination reference system is geographic and change
- * the destination coordinates from radians to degrees */
+ * the destination coordinates from radians to degrees */
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);
@@ -81,7 +81,7 @@ static str transformCoordSeq(int idx, in
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;
@@ -89,7 +89,7 @@ static str transformPoint(GEOSGeometry**
coordinatesNum = GEOSGeom_getCoordinateDimension(geosGeometry);
/* get the coordinates of the points comprising the geometry */
gcs_old = GEOSGeom_getCoordSeq(geosGeometry);
-
+
if(gcs_old == NULL) {
*transformedGeometry = NULL;
return createException(MAL, "geom.wkbTransform",
"GEOSGeom_getCoordSeq failed");
@@ -104,7 +104,7 @@ static str transformPoint(GEOSGeometry**
*transformedGeometry = NULL;
return ret;
}
-
+
/* create the geometry from the coordinates seqience */
*transformedGeometry = GEOSGeom_createPoint(gcs_new);
@@ -113,24 +113,24 @@ static str transformPoint(GEOSGeometry**
static str transformLine(GEOSCoordSeq *gcs_new, const GEOSGeometry*
geosGeometry, projPJ proj4_src, projPJ proj4_dst) {
int coordinatesNum = 0;
- const GEOSCoordSequence* gcs_old;
+ const GEOSCoordSequence* gcs_old;
unsigned int pointsNum =0, i=0;
- str ret = MAL_SUCCEED;
+ str ret = MAL_SUCCEED;
/* get the number of coordinates the geometry has */
coordinatesNum = GEOSGeom_getCoordinateDimension(geosGeometry);
/* get the coordinates of the points comprising the geometry */
gcs_old = GEOSGeom_getCoordSeq(geosGeometry);
-
+
if(gcs_old == NULL)
return createException(MAL, "geom.wkbTransform",
"GEOSGeom_getCoordSeq failed");
-
+
/* get the number of points in the geometry */
GEOSCoordSeq_getSize(gcs_old, &pointsNum);
/* create the coordinates sequence for the transformed geometry */
*gcs_new = GEOSCoordSeq_create(pointsNum, coordinatesNum);
-
+
/* create the transformed coordinates */
for(i=0; i<pointsNum; i++) {
ret = transformCoordSeq(i, coordinatesNum, proj4_src,
proj4_dst, gcs_old, gcs_new);
@@ -141,7 +141,7 @@ static str transformLine(GEOSCoordSeq *g
}
}
-
+
return MAL_SUCCEED;
}
@@ -155,10 +155,10 @@ static str transformLineString(GEOSGeome
*transformedGeometry = NULL;
return ret;
}
-
+
/* create the geometry from the coordinates sequence */
*transformedGeometry = GEOSGeom_createLineString(coordSeq);
-
+
return ret;
}
@@ -172,10 +172,10 @@ static str transformLinearRing(GEOSGeome
*transformedGeometry = NULL;
return ret;
}
-
+
/* create the geometry from the coordinates sequence */
*transformedGeometry = GEOSGeom_createLinearRing(coordSeq);
-
+
return ret;
}
@@ -191,7 +191,7 @@ static str transformPolygon(GEOSGeometry
if(!exteriorRingGeometry) {
*transformedGeometry = NULL;
return createException(MAL,
"geom.wkbTransform","GEOSGetExteriorRing failed");
- }
+ }
ret = transformLinearRing(&transformedExteriorRingGeometry,
exteriorRingGeometry, proj4_src, proj4_dst);
if(ret != MAL_SUCCEED) {
@@ -238,21 +238,21 @@ static str transformMultiGeometry(GEOSGe
subGeometryType = GEOSGeomTypeId(multiGeometry)+1;
switch(subGeometryType) {
- case wkbPoint:
- ret =
transformPoint(&(transformedMultiGeometries[i]), multiGeometry, proj4_src,
proj4_dst);
- break;
- case wkbLineString:
- ret =
transformLineString(&(transformedMultiGeometries[i]), multiGeometry, proj4_src,
proj4_dst);
- break;
- case wkbLinearRing:
- ret =
transformLinearRing(&(transformedMultiGeometries[i]), multiGeometry, proj4_src,
proj4_dst);
- break;
- case wkbPolygon:
- ret =
transformPolygon(&(transformedMultiGeometries[i]), multiGeometry, proj4_src,
proj4_dst, srid);
- break;
- default:
- transformedMultiGeometries[i] = NULL;
- ret = createException(MAL, "geom.Transform",
"Unknown geometry type");
+ case wkbPoint:
+ ret = transformPoint(&(transformedMultiGeometries[i]),
multiGeometry, proj4_src, proj4_dst);
+ break;
+ case wkbLineString:
+ ret =
transformLineString(&(transformedMultiGeometries[i]), multiGeometry, proj4_src,
proj4_dst);
+ break;
+ case wkbLinearRing:
+ ret =
transformLinearRing(&(transformedMultiGeometries[i]), multiGeometry, proj4_src,
proj4_dst);
+ break;
+ case wkbPolygon:
+ ret =
transformPolygon(&(transformedMultiGeometries[i]), multiGeometry, proj4_src,
proj4_dst, srid);
+ break;
+ default:
+ transformedMultiGeometries[i] = NULL;
+ ret = createException(MAL, "geom.Transform", "Unknown
geometry type");
}
if(ret != MAL_SUCCEED) {
@@ -260,20 +260,20 @@ static str transformMultiGeometry(GEOSGe
*transformedGeometry = NULL;
return ret;
}
-
+
GEOSSetSRID(transformedMultiGeometries[i], srid);
}
-
+
*transformedGeometry = GEOSGeom_createCollection(geometryType-1,
transformedMultiGeometries, geometriesNum);
return ret;
}
/* the following function is used in postgis to get projPJ from str.
- * it is necessary to do it ina detailed way like that because pj_init_plus
- * does not set all parameters correctly and I cannot test whether the
+ * it is necessary to do it ina detailed way like that because pj_init_plus
+ * does not set all parameters correctly and I cannot test whether the
* coordinate reference systems are geographic or not */
- static projPJ projFromStr(char* projStr) {
+static projPJ projFromStr(char* projStr) {
int t;
char *params[1024]; // one for each parameter
char *loc;
@@ -295,22 +295,22 @@ static str transformMultiGeometry(GEOSGe
loc = str;
t = 1;
while ((loc != NULL) && (*loc != 0) )
- {
- loc = strchr(loc, ' ');
- if (loc != NULL)
{
- *loc = 0; // null terminate
- params[t] = loc+1;
- loc++; // next char
- t++; //next param
+ loc = strchr(loc, ' ');
+ if (loc != NULL)
+ {
+ *loc = 0; // null terminate
+ params[t] = loc+1;
+ loc++; // next char
+ t++; //next param
+ }
}
- }
if (!(result=pj_init(t, params)))
- {
- GDKfree(str);
- return NULL;
- }
+ {
+ GDKfree(str);
+ return NULL;
+ }
GDKfree(str);
return result;
@@ -319,14 +319,14 @@ static str transformMultiGeometry(GEOSGe
/* It gets a geometry and transforms its coordinates to the provided srid */
str wkbTransform(wkb** transformedWKB, wkb** geomWKB, int* srid_src, int*
srid_dst, char** proj4_src_str, char** proj4_dst_str) {
-#ifndef HAVE_PROJ
-*transformedWKB = NULL;
-(void)**geomWKB;
-(void)*srid_src;
-(void)*srid_dst;
-(void)**proj4_src_str;
-(void)**proj4_dst_str;
-return createException(MAL, "geom.Transform", "Function Not Implemented");
+#ifndef HAVE_PROJ
+ *transformedWKB = NULL;
+ (void)**geomWKB;
+ (void)*srid_src;
+ (void)*srid_dst;
+ (void)**proj4_src_str;
+ (void)**proj4_dst_str;
+ return createException(MAL, "geom.Transform", "Function Not
Implemented");
#else
projPJ proj4_src, proj4_dst;
GEOSGeom geosGeometry, transformedGeosGeometry;
@@ -340,8 +340,8 @@ return createException(MAL, "geom.Transf
throw(MAL, "geom.wkbTransform", "Could not find in
spatial_ref_sys srid %d\n", *srid_dst);
proj4_src = /*pj_init_plus*/projFromStr(*proj4_src_str);
proj4_dst = /*pj_init_plus*/projFromStr(*proj4_dst_str);
-
-
+
+
if(*geomWKB == NULL) {
*transformedWKB = wkb_nil;
pj_free(proj4_src);
@@ -355,26 +355,26 @@ return createException(MAL, "geom.Transf
geometryType = GEOSGeomTypeId(geosGeometry)+1;
switch(geometryType) {
- case wkbPoint:
- ret = transformPoint(&transformedGeosGeometry,
geosGeometry, proj4_src, proj4_dst);
- break;
- case wkbLineString:
- ret = transformLineString(&transformedGeosGeometry,
geosGeometry, proj4_src, proj4_dst);
- break;
- case wkbLinearRing:
- ret = transformLinearRing(&transformedGeosGeometry,
geosGeometry, proj4_src, proj4_dst);
- break;
- case wkbPolygon:
- ret = transformPolygon(&transformedGeosGeometry,
geosGeometry, proj4_src, proj4_dst, *srid_dst);
- break;
- case wkbMultiPoint:
- case wkbMultiLineString:
- case wkbMultiPolygon:
- ret = transformMultiGeometry(&transformedGeosGeometry,
geosGeometry, proj4_src, proj4_dst, *srid_dst, geometryType);
- break;
- default:
- transformedGeosGeometry = NULL;
- ret = createException(MAL, "geom.Transform", "Unknown
geometry type");
+ case wkbPoint:
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list