Find the time of closest point of approach.
1080 double mindist2 = FLT_MAX;
1084 lwerror(
"Both input geometries must have a measure dimension");
1093 lwerror(
"Both input geometries must be linestrings");
1099 lwerror(
"Both input lines must have at least 2 points");
1119 LWDEBUG(1,
"Inputs never exist at the same time");
1129 mvals =
lwalloc(
sizeof(
double) *
1140 nmvals =
uniq(mvals, nmvals);
1146 double t0 = mvals[0];
1148 LWDEBUGF(1,
"Inputs only exist both at a single time (%g)", t0);
1154 lwerror(
"Could not find point with M=%g on first geom", t0);
1160 lwerror(
"Could not find point with M=%g on second geom", t0);
1175 for (i=1; i<nmvals; ++i)
1177 double t0 = mvals[i-1];
1178 double t1 = mvals[i];
1187 if ( -1 == seg )
continue;
1191 if ( -1 == seg )
continue;
1195 if ( -1 == seg )
continue;
1199 if ( -1 == seg )
continue;
1210 dist2 = ( q0.
x - p0.
x ) * ( q0.
x - p0.
x ) +
1211 ( q0.
y - p0.
y ) * ( q0.
y - p0.
y ) +
1212 ( q0.
z - p0.
z ) * ( q0.
z - p0.
z );
1213 if ( dist2 < mindist2 )
1229 *mindist = sqrt(mindist2);
static int uniq(double *vals, int nvals)
static int compare_double(const void *pa, const void *pb)
#define LWDEBUG(level, msg)
int lwgeom_calculate_gbox(const LWGEOM *lwgeom, GBOX *gbox)
Calculate bounding box of a geometry, automatically taking into account whether it is cartesian or ge...
static int ptarray_collect_mvals(const POINTARRAY *pa, double tmin, double tmax, double *mvals)
static int ptarray_locate_along_linear(const POINTARRAY *pa, double m, POINT4D *p, int from)
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
double distance3d_pt_pt(const POINT3D *p1, const POINT3D *p2)
void * lwalloc(size_t size)
#define LWDEBUGF(level, msg,...)
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
static double segments_tcpa(POINT4D *p0, const POINT4D *p1, POINT4D *q0, const POINT4D *q1, double t0, double t1)
void lwerror(const char *fmt,...)
Write a notice out to the error handler.