]> granicus.if.org Git - postgis/commitdiff
Geodetic tolerance issue in 32-bit
authorPaul Ramsey <pramsey@cleverelephant.ca>
Fri, 18 Jan 2019 18:05:36 +0000 (18:05 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Fri, 18 Jan 2019 18:05:36 +0000 (18:05 +0000)
References #4298

git-svn-id: http://svn.osgeo.org/postgis/branches/2.3@17184 b70326c6-7e19-0410-871a-916f4a2858ee

NEWS
liblwgeom/lwgeodetic.c

diff --git a/NEWS b/NEWS
index 8b01d9bca529276ae9eb307a0fc20c6cdf9f3d55..f1839bc875564a55b1b2365ffa8e171efb897920 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,8 @@ PostGIS 2.3.9
   - #4275, Avoid passing a NULL pointer to GEOSisEmpty (Raúl Marín)
 
   - #4296, Use `server_version_num` instead of parsing `version()` (Raúl Marín)
+  - #4298, Geodetic tolerance issue in 32-bit (Paul Ramsey)
+
 
 PostGIS 2.3.8
 2018/11/24
index 9f7e3a33e47c577cad43bd8749e49f365c088909..3c5d4dc2cf0c009944a867ac25d4e0fcef7056f6 100644 (file)
 */
 int gbox_geocentric_slow = LW_FALSE;
 
+/**
+* Utility function for ptarray_contains_point_sphere()
+*/
+static int
+point3d_equals(const POINT3D *p1, const POINT3D *p2)
+{
+       return FP_EQUALS(p1->x, p2->x) && FP_EQUALS(p1->y, p2->y) && FP_EQUALS(p1->z, p2->z);
+}
+
 /**
 * Convert a longitude to the range of -PI,PI
 */
@@ -3059,6 +3068,10 @@ point_in_cone(const POINT3D *A1, const POINT3D *A2, const POINT3D *P)
        POINT3D AC; /* Center point of A1/A2 */
        double min_similarity, similarity;
 
+       /* Boundary case */
+       if (point3d_equals(A1, P) || point3d_equals(A2, P))
+               return LW_TRUE;
+
        /* The normalized sum bisects the angle between start and end. */
        vector_sum(A1, A2, &AC);
        normalize(&AC);
@@ -3067,7 +3080,7 @@ point_in_cone(const POINT3D *A1, const POINT3D *A2, const POINT3D *P)
        min_similarity = dot_product(A1, &AC);
 
        /* If the edge is sufficiently curved, use the dot product test */
-       if (fabs(1.0 - min_similarity) > 1e-10 )
+       if (fabs(1.0 - min_similarity) > 1e-10)
        {
                /* The projection of candidate p onto the center */
                similarity = dot_product(P, &AC);
@@ -3076,7 +3089,7 @@ point_in_cone(const POINT3D *A1, const POINT3D *A2, const POINT3D *P)
                /* the projection of the start point, the candidate */
                /* must be closer to the center than the start, so */
                /* therefor inside the cone */
-               if ( similarity > min_similarity )
+               if (similarity > min_similarity)
                {
                        return LW_TRUE;
                }
@@ -3111,14 +3124,6 @@ point_in_cone(const POINT3D *A1, const POINT3D *A2, const POINT3D *P)
 }
 
 
-/**
-* Utility function for ptarray_contains_point_sphere()
-*/
-static int
-point3d_equals(const POINT3D *p1, const POINT3D *p2)
-{
-       return FP_EQUALS(p1->x, p2->x) && FP_EQUALS(p1->y, p2->y) && FP_EQUALS(p1->z, p2->z);
-}
 
 /**
 * Utility function for edge_intersects(), signum with a tolerance