1305 double mindist=DBL_MAX;
1308 POINT4D start4d, end4d, projtmp;
1310 const POINT2D *start = NULL, *end = NULL;
1316 if ( ! proj4d ) proj4d = &projtmp;
1338 if (dist_sqr < mindist)
1344 LWDEBUG(3,
"Breaking on mindist=0");
1351 mindist = sqrt(mindist);
1353 if ( mindistout ) *mindistout = mindist;
1355 LWDEBUGF(3,
"Closest segment: %d", seg);
1356 LWDEBUGF(3,
"mindist: %g", mindist);
1378 LWDEBUGF(3,
"Closest point on segment: %g,%g", proj.
x, proj.
y);
1386 if ( tlen == 0 )
return 0;
1390 for (t=0; t<seg; t++, start=end)
1395 LWDEBUGF(4,
"Segment %d made plen %g", t, plen);
1400 LWDEBUGF(3,
"plen %g, tlen %g", plen, tlen);
double distance2d_pt_pt(const POINT2D *p1, const POINT2D *p2)
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
double distance2d_sqr_pt_seg(const POINT2D *p, const POINT2D *A, const POINT2D *B)
int p2d_same(const POINT2D *p1, const POINT2D *p2)
#define LWDEBUG(level, msg)
#define LWDEBUGF(level, msg,...)
static const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
void closest_point_on_segment(const POINT4D *p, const POINT4D *A, const POINT4D *B, POINT4D *ret)
double ptarray_length_2d(const POINTARRAY *pts)
Find the 2d length of the given POINTARRAY (even if it's 3d)