Changeset: e9e3355b22c2 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/e9e3355b22c2
Modified Files:
        geom/monetdb5/geom.c
        geom/monetdb5/geom.h
Branch: geo-update
Log Message:

Fixed formatting.


diffs (truncated from 8058 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
@@ -32,7 +32,8 @@ const double earth_radius = 6371.009;
 const double earth_radius_meters = 6371009;
 
 /* Converts a longitude value in degrees to radians */
-static double deg2RadLongitude(double lon_degrees)
+static double 
+deg2RadLongitude(double lon_degrees)
 {
        //Convert
        double lon = M_PI * lon_degrees / 180.0;
@@ -61,7 +62,8 @@ static double deg2RadLongitude(double lo
 }
 
 /* Converts a latitude value in degrees to radians */
-static double deg2RadLatitude(double lat_degrees)
+static double 
+deg2RadLatitude(double lat_degrees)
 {
        //Convert
        double lat = M_PI * lat_degrees / 180.0;
@@ -89,7 +91,8 @@ static double deg2RadLatitude(double lat
 }
 
 /* Converts the GeoPoint from degrees to radians latitude and longitude*/
-static GeoPoint deg2RadPoint(GeoPoint geo)
+static GeoPoint 
+deg2RadPoint(GeoPoint geo)
 {
        geo.lon = deg2RadLongitude(geo.lon);
        geo.lat = deg2RadLatitude(geo.lat);
@@ -99,7 +102,8 @@ static GeoPoint deg2RadPoint(GeoPoint ge
 /**
  *  Converts a longitude value in radians to degrees
  */
-static double rad2DegLongitude(double lon_radians)
+static double 
+rad2DegLongitude(double lon_radians)
 {
        //Convert
        double lon = lon_radians * 180.0 / M_PI;
@@ -129,7 +133,8 @@ static double rad2DegLongitude(double lo
 /**
  *  Converts a latitude value in radians to degrees
  */
-static double rad2DegLatitude(double lat_radians)
+static double 
+rad2DegLatitude(double lat_radians)
 {
        //Convert
        double lat = lat_radians * 180.0 / M_PI;
@@ -157,7 +162,8 @@ static double rad2DegLatitude(double lat
 }
 
 /* Converts the GeoPoint from degrees to radians latitude and longitude*/
-static GeoPoint rad2DegPoint(GeoPoint geo)
+static GeoPoint 
+rad2DegPoint(GeoPoint geo)
 {
        geo.lon = rad2DegLongitude(geo.lon);
        geo.lat = rad2DegLatitude(geo.lat);
@@ -165,7 +171,8 @@ static GeoPoint rad2DegPoint(GeoPoint ge
 }
 
 /* Converts the a GEOSGeom Point into a GeoPoint */
-static GeoPoint geoPointFromGeom(GEOSGeom geom)
+static GeoPoint 
+geoPointFromGeom(GEOSGeom geom)
 {
        GeoPoint geo;
        GEOSGeomGetX(geom, &(geo.lon));
@@ -175,7 +182,8 @@ static GeoPoint geoPointFromGeom(GEOSGeo
 
 /* Converts the a GEOSGeom Line into GeoLines (one or more line segments) 
    Argument must be a Line geometry. */
-static GeoLines geoLinesFromGeom(GEOSGeom geom)
+static GeoLines 
+geoLinesFromGeom(GEOSGeom geom)
 {
        const GEOSCoordSequence *gcs = GEOSGeom_getCoordSeq(geom);
        int segmentCount = GEOSGeomGetNumPoints(geom) - 1;
@@ -183,8 +191,7 @@ static GeoLines geoLinesFromGeom(GEOSGeo
        geo.segmentCount = segmentCount;
        //TODO Malloc fail exception?
        geo.segments = GDKmalloc(sizeof(GeoLine) * segmentCount);
-       for (int i = 0; i < segmentCount; i++)
-       {
+       for (int i = 0; i < segmentCount; i++) {
                GEOSCoordSeq_getXY(gcs, i, &geo.segments[i].start.lon, 
&geo.segments[i].start.lat);
                GEOSCoordSeq_getXY(gcs, i + 1, &geo.segments[i].end.lon, 
&geo.segments[i].end.lat);
        }
@@ -195,29 +202,27 @@ static GeoLines geoLinesFromGeom(GEOSGeo
 
 /* Converts the a GEOSGeom Line into GeoPolygon (with exterior ring and 
zero-to-multiple interior rings) 
    Argument must be a Polygon geometry. */
-static GeoPolygon geoPolygonFromGeom(GEOSGeom geom)
+static GeoPolygon 
+geoPolygonFromGeom(GEOSGeom geom)
 {
        GeoPolygon geo;
-       //TODO Calculate Boundind Box on initializion?
-       geo.bbox = NULL;
        //Get exterior ring GeoLines
        geo.exteriorRing = 
geoLinesFromGeom((GEOSGeom)GEOSGetExteriorRing(geom));
        geo.interiorRingsCount = GEOSGetNumInteriorRings(geom);
        //If there are interior rings, allocate space to their GeoLines 
representation
-       if (geo.interiorRingsCount > 0)
-       {
+       if (geo.interiorRingsCount > 0) 
                //TODO Malloc fail exception?
                geo.interiorRings = GDKmalloc(sizeof(GeoLines) * 
geo.interiorRingsCount);
-       }
        //Get interior rings GeoLines
        for (int i = 0; i < geo.interiorRingsCount; i++)
-       {
                geo.interiorRings[i] = 
geoLinesFromGeom((GEOSGeom)GEOSGetInteriorRingN(geom, i));
-       }
+       //TODO Calculate Boundind Box on initializion?
+       geo.bbox = NULL;
        return geo;
 }
 
-static GeoPoint geoPointFromLatLon(double lon, double lat)
+static GeoPoint 
+geoPointFromLatLon(double lon, double lat)
 {
        GeoPoint geo;
        geo.lon = lon;
@@ -225,7 +230,8 @@ static GeoPoint geoPointFromLatLon(doubl
        return geo;
 }
 
-static CartPoint cartPointFromXYZ(double x, double y, double z)
+static CartPoint 
+cartPointFromXYZ(double x, double y, double z)
 {
        CartPoint cart;
        cart.x = x;
@@ -235,12 +241,12 @@ static CartPoint cartPointFromXYZ(double
 }
 
 /* Converts Well-Known Bytes into Geos Geometries, if they are not NULL and 
have the same SRID (used for geographic functions) */
-static str wkbGetComplatibleGeometries(wkb **a, wkb **b, GEOSGeom *ga, 
GEOSGeom *gb)
+static str 
+wkbGetComplatibleGeometries(wkb **a, wkb **b, GEOSGeom *ga, GEOSGeom *gb)
 {
        str err = MAL_SUCCEED;
 
-       if (is_wkb_nil(*a) || is_wkb_nil(*b))
-       {
+       if (is_wkb_nil(*a) || is_wkb_nil(*b)) {
                (*ga) = NULL;
                (*gb) = NULL;
                return MAL_SUCCEED;
@@ -248,11 +254,8 @@ static str wkbGetComplatibleGeometries(w
        (*ga) = wkb2geos(*a);
        (*gb) = wkb2geos(*b);
        if ((*ga) == NULL || (*gb) == NULL)
-       {
                err = createException(MAL, "geom.wkbGetComplatibleGeometries", 
SQLSTATE(38000) "Geos operation wkb2geos failed");
-       }
-       else if (GEOSGetSRID((*ga)) != GEOSGetSRID(*gb))
-       {
+       else if (GEOSGetSRID((*ga)) != GEOSGetSRID(*gb)) {
                GEOSGeom_destroy(*ga);
                GEOSGeom_destroy(*gb);
                err = createException(MAL, "geom.wkbGetComplatibleGeometries", 
SQLSTATE(38000) "Geometries of different SRID");
@@ -264,7 +267,8 @@ static str wkbGetComplatibleGeometries(w
 * Convert spherical coordinates to cartesian coordinates on unit sphere.
 * The inputs have to be in radians.
 */
-static CartPoint geo2cart(GeoPoint geo)
+static CartPoint 
+geo2cart(GeoPoint geo)
 {
        CartPoint cart;
        cart.x = cos(geo.lat) * cos(geo.lon);
@@ -277,13 +281,15 @@ static CartPoint geo2cart(GeoPoint geo)
 * Convert spherical coordinates to cartesian coordinates on unit sphere.
 * The inputs have to be in degrees.
 */
-static CartPoint geo2cartFromDegrees(GeoPoint geo)
+static CartPoint 
+geo2cartFromDegrees(GeoPoint geo)
 {
        return geo2cart(deg2RadPoint(geo));
 }
 
 /* Convert cartesian coordinates to spherical coordinates on unit sphere */
-static GeoPoint cart2geo(CartPoint cart)
+static GeoPoint 
+cart2geo(CartPoint cart)
 {
        GeoPoint geo;
        geo.lon = atan2(cart.y, cart.x);
@@ -292,7 +298,8 @@ static GeoPoint cart2geo(CartPoint cart)
 }
 
 /* Converts two lat/lon points into cartesian coordinates and creates a Line 
geometry */
-static GEOSGeom cartesianLineFromGeoPoints(GeoPoint p1, GeoPoint p2)
+static GEOSGeom 
+cartesianLineFromGeoPoints(GeoPoint p1, GeoPoint p2)
 {
        CartPoint p1_cart, p2_cart;
        p1_cart = geo2cartFromDegrees(p1);
@@ -308,7 +315,8 @@ static GEOSGeom cartesianLineFromGeoPoin
 * 
 **/
 /* Adds a Cartesian Point to the BoundingBox */
-static void boundingBoxAddPoint(BoundingBox *bb, CartPoint p)
+static void 
+boundingBoxAddPoint(BoundingBox *bb, CartPoint p)
 {
        if (bb->xmin > p.x)
                bb->xmin = p.x;
@@ -325,16 +333,15 @@ static void boundingBoxAddPoint(Bounding
 }
 
 /* Builds the BoundingBox for a GeoLines geometry */
-static BoundingBox *boundingBoxLines(GeoLines lines)
+static BoundingBox *
+boundingBoxLines(GeoLines lines)
 {
        CartPoint c;
        BoundingBox *bb = GDKzalloc(sizeof(BoundingBox));
 
        //If there are no segments, return NULL
        if (lines.segmentCount == 0)
-       {
                return NULL;
-       }
 
        c = geo2cartFromDegrees(lines.segments[0].start);
 
@@ -343,21 +350,23 @@ static BoundingBox *boundingBoxLines(Geo
        bb->ymin = bb->ymax = c.y;
        bb->zmin = bb->zmax = c.z;
 
-       for (int i = 0; i < lines.segmentCount; i++)
-       {
+       for (int i = 0; i < lines.segmentCount; i++) {
                c = geo2cartFromDegrees(lines.segments[i].end);
                boundingBoxAddPoint(bb, c);
        }
        return bb;
 }
 
-static int boundingBoxContainsPoint(BoundingBox bb, CartPoint pt)
+static int 
+boundingBoxContainsPoint(BoundingBox bb, CartPoint pt)
 {
        return bb.xmin <= pt.x && bb.xmax >= pt.x && bb.ymin <= pt.y && bb.ymax 
>= pt.y && bb.zmin <= pt.z && bb.zmax >= pt.z;
 }
 
-static BoundingBox boundingBoxCopy(BoundingBox bb)
-{
+static BoundingBox 
+boundingBoxCopy(BoundingBox bb)
+{
+       //TODO Malloc fail?
        BoundingBox *copy = GDKmalloc(sizeof(BoundingBox));
        copy->xmin = bb.xmin;
        copy->xmax = bb.xmax;
@@ -369,22 +378,20 @@ static BoundingBox boundingBoxCopy(Bound
 }
 
 /* Returns a point outside of the polygon's bounding box, for Point-In-Polygon 
calculation */
-static GeoPoint pointOutsidePolygon(GeoPolygon polygon)
+static GeoPoint 
+pointOutsidePolygon(GeoPolygon polygon)
 {
        //If the geometry doesn't have its BoundingBox calculated, calculate it
        //TODO Should we consider the interior rings for bounding box 
calculation?
        if (polygon.bbox == NULL)
-       {
                polygon.bbox = boundingBoxLines(polygon.exteriorRing);
-       }
        BoundingBox bb = *polygon.bbox;
        BoundingBox bb2 = boundingBoxCopy(*polygon.bbox);
 
        //TODO: From POSTGIS -> CHANGE
        double grow = M_PI / 180.0 / 60.0;
        CartPoint corners[8];
-       while (grow < M_PI)
-       {
+       while (grow < M_PI) {
                if (bb.xmin > -1)
                        bb.xmin -= grow;
                if (bb.ymin > -1)
@@ -431,13 +438,10 @@ static GeoPoint pointOutsidePolygon(GeoP
                corners[7].z = bb.zmax;
 
                for (int i = 0; i < 8; i++)
-               {
-                       if (!boundingBoxContainsPoint(bb2, corners[i]))
-                       {
+                       if (!boundingBoxContainsPoint(bb2, corners[i])) {
                                CartPoint pt_cart = corners[i];
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to