Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GBOX patch for #4032 #234

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 8 additions & 12 deletions liblwgeom/lwlinearreferencing.c
Expand Up @@ -23,7 +23,6 @@
*
**********************************************************************/


#include "liblwgeom_internal.h"
#include "lwgeom_log.h"
#include "measures3d.h"
Expand Down Expand Up @@ -1245,7 +1244,7 @@ lwgeom_cpa_within(const LWGEOM *g1, const LWGEOM *g2, double maxdist)
{
LWLINE *l1, *l2;
int i;
const GBOX *gbox1, *gbox2;
GBOX gbox1, gbox2;
double tmin, tmax;
double *mvals;
int nmvals = 0;
Expand Down Expand Up @@ -1274,29 +1273,26 @@ lwgeom_cpa_within(const LWGEOM *g1, const LWGEOM *g2, double maxdist)
return LW_FALSE;
}

/* 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 )
{
LWDEBUG(1, "Inputs never exist at the same time");
return LW_FALSE;
}

// lwnotice("Min:%g, Max:%g", tmin, tmax);

/*
* Collect M values in common time range from inputs
*/
Expand Down