1306{
1308 int i;
1310 double tmin, tmax;
1311 double *mvals;
1312 int nmvals = 0;
1313 double maxdist2 = maxdist * maxdist;
1315
1317 {
1318 lwerror(
"Both input geometries must have a measure dimension");
1320 }
1321
1324
1325 if (!l1 || !l2)
1326 {
1327 lwerror(
"Both input geometries must be linestrings");
1329 }
1330
1332 {
1333
1334 lwerror(
"Both input lines must have at least 2 points");
1336 }
1337
1338
1339
1340
1343
1344
1345
1346
1347
1348
1351
1352 if (tmax < tmin)
1353 {
1354 LWDEBUG(1,
"Inputs never exist at the same time");
1356 }
1357
1358
1359
1360
1361
1363
1364
1367
1368
1370
1371
1372 nmvals =
uniq(mvals, nmvals);
1373
1374 if (nmvals < 2)
1375 {
1376
1377 double t0 = mvals[0];
1379 LWDEBUGF(1,
"Inputs only exist both at a single time (%g)", t0);
1381 {
1382 lwnotice(
"Could not find point with M=%g on first geom", t0);
1384 }
1386 {
1387 lwnotice(
"Could not find point with M=%g on second geom", t0);
1389 }
1394 }
1395
1396
1397
1398
1399
1400 for (i = 1; i < nmvals; ++i)
1401 {
1402 double t0 = mvals[i - 1];
1403 double t1 = mvals[i];
1404#if POSTGIS_DEBUG_LEVEL >= 1
1405 double t;
1406#endif
1408 int seg;
1409 double dist2;
1410
1411
1412
1414 if (-1 == seg)
1415 continue;
1416
1417
1419 if (-1 == seg)
1420 continue;
1421
1422
1424 if (-1 == seg)
1425 continue;
1426
1427
1429 if (-1 == seg)
1430 continue;
1431
1432
1433#if POSTGIS_DEBUG_LEVEL >= 1
1434 t =
1435#endif
1437
1438
1439
1440
1441
1442
1443
1444 dist2 = (q0.
x - p0.
x) * (q0.
x - p0.
x) + (q0.
y - p0.
y) * (q0.
y - p0.
y) + (q0.
z - p0.
z) * (q0.
z - p0.
z);
1445 if (dist2 <= maxdist2)
1446 {
1447 LWDEBUGF(1,
"Within distance %g at time %g, breaking", sqrt(dist2), t);
1449 break;
1450 }
1451 }
1452
1453
1454
1455
1456
1458
1460}
void * lwalloc(size_t size)
double distance3d_pt_pt(const POINT3D *p1, const POINT3D *p2)
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...
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
#define LW_TRUE
Return types for functions with status returns.
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
Datum within(PG_FUNCTION_ARGS)
#define LWDEBUG(level, msg)
#define LWDEBUGF(level, msg,...)
void lwnotice(const char *fmt,...) __attribute__((format(printf
Write a notice out to the notice handler.
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
static int ptarray_collect_mvals(const POINTARRAY *pa, double tmin, double tmax, double *mvals)
static int compare_double(const void *pa, const void *pb)
static double segments_tcpa(POINT4D *p0, const POINT4D *p1, POINT4D *q0, const POINT4D *q1, double t0, double t1)
static int ptarray_locate_along_linear(const POINTARRAY *pa, double m, POINT4D *p, uint32_t from)
static int uniq(double *vals, int nvals)