]> granicus.if.org Git - postgis/commitdiff
Use more precise bounds when testing overlap of temporal ranges.
authorPaul Ramsey <pramsey@cleverelephant.ca>
Mon, 26 Feb 2018 18:25:45 +0000 (18:25 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Mon, 26 Feb 2018 18:25:45 +0000 (18:25 +0000)
For 2.4, references #4025

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

NEWS
liblwgeom/lwlinearreferencing.c

diff --git a/NEWS b/NEWS
index 47e2e93ed4a6e0ef4a7b82fb9e52e250c12ba3ac..81ae21081788cf33a8516becdc20062bde9433a3 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@ PostGIS 2.4.4dev
            PolyhedralSurface (Matthias Bay)
   - #3942, geojson: Do not include private header for json-c >= 0.13
            (Björn Esser)
+  - #4025, Incorrect answers for temporally "amost overlapping" ranges
 
  * Enhancements *
     - #3992, Use PKG_PROG_PKG_CONFIG macro from pkg.m4 to detect pkg-config
index 5cb81bb21dfc5dbae1c5b99f4aa8a23e2b5fc1bb..8580e1befafbabac10ffa62b207f46ccfc27658f 100644 (file)
@@ -1073,7 +1073,7 @@ lwgeom_tcpa(const LWGEOM *g1, const LWGEOM *g2, double *mindist)
 {
        LWLINE *l1, *l2;
        int i;
-       const GBOX *gbox1, *gbox2;
+       GBOX gbox1, gbox2;
        double tmin, tmax;
        double *mvals;
        int nmvals = 0;
@@ -1101,20 +1101,19 @@ lwgeom_tcpa(const LWGEOM *g1, const LWGEOM *g2, double *mindist)
                return -1;
        }
 
-       /* WARNING: these ranges may be wider than real ones */
-       gbox1 = lwgeom_get_bbox(g1);
-       gbox2 = lwgeom_get_bbox(g2);
-
-       assert(gbox1); /* or the npoints check above would have failed */
-       assert(gbox2); /* or the npoints check above would have failed */
+       /* We use lwgeom_calculate_gbox() instead of lwgeom_get_gbox() */
+       /* because we cannot afford the float rounding inaccuracy when */
+       /* we compare the ranges for overlap below */
+       lwgeom_calculate_gbox(g1, &gbox1);
+       lwgeom_calculate_gbox(g2, &gbox2);
 
        /*
         * Find overlapping M range
         * WARNING: may be larger than the real one
         */
 
-       tmin = FP_MAX(gbox1->mmin, gbox2->mmin);
-       tmax = FP_MIN(gbox1->mmax, gbox2->mmax);
+       tmin = FP_MAX(gbox1.mmin, gbox2.mmin);
+       tmax = FP_MIN(gbox1.mmax, gbox2.mmax);
 
        if ( tmax < tmin )
        {