Changeset: b9fb49852f3e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/b9fb49852f3e
Modified Files:
.editorconfig
geom/lib/libgeom.c
geom/monetdb5/geod.c
geom/monetdb5/geod.h
geom/monetdb5/geom.c
geom/monetdb5/geomBulk.c
geom/monetdb5/geom_atoms.c
Branch: default
Log Message:
Use 8-space tabs in geom directory.
diffs (truncated from 1163 to 300 lines):
diff --git a/.editorconfig b/.editorconfig
--- a/.editorconfig
+++ b/.editorconfig
@@ -24,7 +24,7 @@ indent_style = space
indent_size = 2
trim_trailing_whitespace = true
-[{clients/{mapi{lib,client},odbc},common/{options,utils},gdk}/**.{c,h}{,.in}]
+[{clients/{mapi{lib,client},odbc},common/{options,utils},gdk,geom}/**.{c,h}{,.in}]
tab_width = 8
max_line_length = 72
diff --git a/geom/lib/libgeom.c b/geom/lib/libgeom.c
--- a/geom/lib/libgeom.c
+++ b/geom/lib/libgeom.c
@@ -99,7 +99,7 @@ geom_type2str(int t, int flag)
if (flag == 0) {
switch (t) {
//case wkbGeometry:
- // return "GEOMETRY";
+ // return "GEOMETRY";
case wkbPoint_mdb:
return "POINT";
case wkbLineString_mdb:
@@ -120,7 +120,7 @@ geom_type2str(int t, int flag)
} else if (flag == 1) {
switch (t) {
//case wkbGeometry:
- // return "ST_Geometry";
+ // return "ST_Geometry";
case wkbPoint_mdb:
return "ST_Point";
case wkbLineString_mdb:
diff --git a/geom/monetdb5/geod.c b/geom/monetdb5/geod.c
--- a/geom/monetdb5/geod.c
+++ b/geom/monetdb5/geod.c
@@ -11,9 +11,9 @@
#include "geod.h"
/**
-* Conversions
-*
-**/
+ * Conversions
+ *
+ **/
const double earth_radius = 6371.009;
const double earth_radius_meters = 6371009;
@@ -21,7 +21,7 @@ const double earth_radius_meters = 63710
#define M_PI ((double) 3.14159265358979323846) /* pi */
#endif
#ifndef M_PI_2
-#define M_PI_2 1.57079632679489661923132169163975144 /* pi/2
*/
+#define M_PI_2 1.57079632679489661923132169163975144 /* pi/2 */
#endif
/* Converts a longitude value in degrees to radians */
@@ -186,8 +186,9 @@ geoLinesFromGeom(allocator *ma, GEOSGeom
static BoundingBox * boundingBoxLines(allocator *ma, GeoLines lines);
-/* Converts the a GEOSGeom Line into GeoPolygon (with exterior ring and
zero-to-multiple interior rings)
- Argument must be a Polygon geometry. */
+/* 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(allocator *ma, GEOSGeom geom)
{
@@ -195,7 +196,8 @@ geoPolygonFromGeom(allocator *ma, GEOSGe
//Get exterior ring GeoLines
geo.exteriorRing = geoLinesFromGeom(ma,
(GEOSGeom)GEOSGetExteriorRing_r(geoshandle, geom));
geo.interiorRingsCount = GEOSGetNumInteriorRings_r(geoshandle, geom);
- //If there are interior rings, allocate space to their GeoLines
representation
+ //If there are interior rings, allocate space to their GeoLines
+ //representation
if (geo.interiorRingsCount > 0)
//TODO Malloc fail exception?
geo.interiorRings = ma_alloc(ma, sizeof(GeoLines) *
geo.interiorRingsCount);
@@ -228,7 +230,8 @@ cartPointFromXYZ(double x, double y, dou
return cart;
}
-/* Converts Well-Known Bytes into Geos Geometries, if they are not NULL and
have the same SRID (used for geographic functions) */
+/* Converts Well-Known Bytes into Geos Geometries, if they are not NULL
+ * and have the same SRID (used for geographic functions) */
str
wkbGetCompatibleGeometries(wkb * const *a, wkb * const *b, GEOSGeom *ga,
GEOSGeom *gb)
{
@@ -252,9 +255,9 @@ wkbGetCompatibleGeometries(wkb * const *
}
/**
-* Convert spherical coordinates to cartesian coordinates on unit sphere.
-* The inputs have to be in radians.
-*/
+ * Convert spherical coordinates to cartesian coordinates on unit sphere.
+ * The inputs have to be in radians.
+ */
static CartPoint3D
geo2cart(GeoPoint geo)
{
@@ -266,9 +269,9 @@ geo2cart(GeoPoint geo)
}
/**
-* Convert spherical coordinates to cartesian coordinates on unit sphere.
-* The inputs have to be in degrees.
-*/
+ * Convert spherical coordinates to cartesian coordinates on unit sphere.
+ * The inputs have to be in degrees.
+ */
static CartPoint3D
geo2cartFromDegrees(GeoPoint geo)
{
@@ -285,7 +288,8 @@ cart2geo(CartPoint3D cart)
return geo;
}
-/* Converts two lat/lon points into cartesian coordinates and creates a Line
geometry */
+/* Converts two lat/lon points into cartesian coordinates and creates a
+ * Line geometry */
static GEOSGeom
cartesianLineFromGeoPoints(GeoPoint p1, GeoPoint p2)
{
@@ -299,9 +303,9 @@ cartesianLineFromGeoPoints(GeoPoint p1,
}
/**
-* Bounding Box functions
-*
-**/
+ * Bounding Box functions
+ *
+ **/
/* Adds a Cartesian Point to the BoundingBox */
static void
boundingBoxAddPoint(BoundingBox *bb, CartPoint3D p)
@@ -360,7 +364,8 @@ boundingBoxContainsPoint(BoundingBox bb,
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;
}
-/* Returns a point outside of the polygon's bounding box, for Point-In-Polygon
calculation */
+/* Returns a point outside of the polygon's bounding box, for
+ * Point-In-Polygon calculation */
static GeoPoint
pointOutsidePolygon(GeoPolygon polygon)
{
@@ -428,14 +433,15 @@ pointOutsidePolygon(GeoPolygon polygon)
}
/**
-* Distance functions
-*
-**/
+ * Distance functions
+ *
+ **/
/**
-* The haversine formula calculate the distance in meters between two lat/lon
points
-* The points must be measured in radians.
-* This formula assumes a spherical model of the earth, which can lead to an
error of about 0.3% compared to a ellipsoidal model.
-*/
+ * The haversine formula calculate the distance in meters between two
+ * lat/lon points The points must be measured in radians. This formula
+ * assumes a spherical model of the earth, which can lead to an error of
+ * about 0.3% compared to a ellipsoidal model.
+ */
static double
haversine(GeoPoint a, GeoPoint b)
{
@@ -454,7 +460,8 @@ geoDistancePointPoint(GeoPoint a, GeoPoi
return haversine(deg2RadPoint(a), deg2RadPoint(b));
}
-/* Calculates the distance between the perpendicular projection of a point in
the Line */
+/* Calculates the distance between the perpendicular projection of a
+ * point in the Line */
static double
calculatePerpendicularDistance(GeoPoint p_geo, GeoPoint l1_geo, GeoPoint
l2_geo)
{
@@ -470,11 +477,13 @@ calculatePerpendicularDistance(GeoPoint
double d_ab = (l2.z - l1.z) * (l2.z - l1.z) + (l2.y - l1.y) * (l2.y -
l1.y) + (l2.x - l1.x) * (l2.x - l1.x);
double t = (((p.x - l1.x) * (l2.x - l1.x)) + ((p.y - l1.y) * (l2.y -
l1.y)) + ((p.z - l1.z) * (l2.z - l1.z))) / d_ab;
- //If t is not between 0 and 1, the projected point is not in the line,
so there is no perpendicular, return huge number
+ //If t is not between 0 and 1, the projected point is not in the
+ //line, so there is no perpendicular, return huge number
if (t < 0 || t > 1)
return INT_MAX;
- //If the projection is in the line segment, build the point ->
projection = l1 + t * (l2-l1)
+ //If the projection is in the line segment, build the point ->
+ //projection = l1 + t * (l2-l1)
projection = cartPointFromXYZ(l1.x + t * (l2.x - l1.x), l1.y + t *
(l2.y - l1.y), l1.z + t * (l2.z - l1.z));
//Convert into geographic coordinates (radians)
@@ -485,8 +494,9 @@ calculatePerpendicularDistance(GeoPoint
}
/* Distance between Point and Line
- The returned distance is the minimum distance between the point and the
line vertices
- and the perpendicular projection of the point in each line segment. */
+ The returned distance is the minimum distance between the point and
+ the line vertices and the perpendicular projection of the point in
+ each line segment. */
static double
geoDistancePointLine(GeoPoint point, GeoLines lines, double distance_min_limit)
{
@@ -498,7 +508,8 @@ geoDistancePointLine(GeoPoint point, Geo
min_distance = distancePoint;
if (distancePerpendicular < min_distance)
min_distance = distancePerpendicular;
- //Shortcut, if the geometries are already at their minimum
distance
+ //Shortcut, if the geometries are already at their
+ //minimum distance
if (min_distance <= distance_min_limit)
return min_distance;
}
@@ -515,7 +526,8 @@ geoDistanceLineLine(GeoLines line1, GeoL
distance = geoDistancePointLine(line1.points[i], line2,
distance_min_limit);
if (distance < min_distance)
min_distance = distance;
- //Shortcut, if the geometries are already at their minimum
distance
+ //Shortcut, if the geometries are already at their
+ //minimum distance
if (min_distance <= distance_min_limit)
return min_distance;
}
@@ -524,7 +536,8 @@ geoDistanceLineLine(GeoLines line1, GeoL
distance =
calculatePerpendicularDistance(line2.points[i],line1.points[j],line1.points[j+1]);
if (distance < min_distance)
min_distance = distance;
- //Shortcut, if the geometries are already at their
minimum distance
+ //Shortcut, if the geometries are already at
+ //their minimum distance
if (min_distance <= distance_min_limit)
return min_distance;
}
@@ -548,19 +561,22 @@ pointWithinPolygon(GeoPolygon polygon, G
return false;
/*printf("Outside point: (%f %f)\n",outsidePoint.lon, outsidePoint.lat);
- fflush(stdout);*/
+ fflush(stdout);*/
//Construct a line between the outside point and the input point
GEOSGeometry *outInLine = cartesianLineFromGeoPoints(point,
outsidePoint);
- //TODO This is producing wrong results, review the intersection
conditional
- //Count the number of intersections between the polygon exterior ring
and the constructed line
+ //TODO This is producing wrong results, review the intersection
+ //conditional
+ //Count the number of intersections between the polygon exterior
+ //ring and the constructed line
polygonRing = polygon.exteriorRing;
for (int i = 0; i < polygonRing.pointCount-1; i++) {
segmentPolygon =
cartesianLineFromGeoPoints(polygonRing.points[i], polygonRing.points[i+1]);
intersectionPoints = GEOSIntersection_r(geoshandle,
segmentPolygon, outInLine);
- //If there is an intersection, a point will be returned (line
when there is none)
+ //If there is an intersection, a point will be returned
+ //(line when there is none)
if (GEOSGeomTypeId_r(geoshandle, intersectionPoints) ==
GEOS_POINT)
intersectionNum++;
@@ -570,14 +586,16 @@ pointWithinPolygon(GeoPolygon polygon, G
GEOSGeom_destroy_r(geoshandle, segmentPolygon);
}
- //Count the number of intersections between the polygon interior rings
and the constructed line
+ //Count the number of intersections between the polygon interior
+ //rings and the constructed line
for (int j = 0; j < polygon.interiorRingsCount; j++) {
polygonRing = polygon.interiorRings[j];
for (int i = 0; i < polygonRing.pointCount-1; i++) {
segmentPolygon =
cartesianLineFromGeoPoints(polygonRing.points[i], polygonRing.points[i+1]);
intersectionPoints = GEOSIntersection_r(geoshandle,
segmentPolygon, outInLine);
- //If there is an intersection, a point will be returned
(line when there is none)
+ //If there is an intersection, a point will be
+ //returned (line when there is none)
if (GEOSGeomTypeId_r(geoshandle, intersectionPoints) ==
GEOS_POINT)
intersectionNum++;
@@ -603,13 +621,15 @@ geoDistancePointPolygon(GeoPoint point,
if (pointWithinPolygon(polygon, point))
return 0;
- //Calculate distance from Point to the exterior and interior rings of
the polygon
+ //Calculate distance from Point to the exterior and interior
+ //rings of the polygon
double distance, min_distance = INT_MAX;
//First, calculate distance to the exterior ring
min_distance = geoDistancePointLine(point, polygon.exteriorRing,
distance_min_limit);
//Then, calculate distance to the interior rings
for (int i = 0; i < polygon.interiorRingsCount; i++) {
- //Shortcut, if the geometries are already at their minimum
distance
+ //Shortcut, if the geometries are already at their
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]