Locate a point along the point array defining a geographic line.
375 int use_sphere = (
s->a ==
s->b ? 1 : 0);
377 double za = 0.0, zb = 0.0;
390 double mindist = 0.0;
398 if ( ! use_sphere || mindist > 0.95 * tolerance )
403 if ( mindistout ) *mindistout = mindist;
415 for ( i = 1; i < pa->
npoints; i++ )
438 else if ( d < tolerance * 0.95 )
454 if ( mindistout ) *mindistout =
distance;
466 for ( i = 1; i < pa->
npoints; i++ )
482 length = sqrt( (zb-za)*(zb-za) + length*length );
489 partlength += length;
490 else if (i - 1 == seg)
522 double f = length / seglength;
524 proj4d->
z = p1.
z + ((p2.
z - p1.
z) * f);
525 proj4d->
m = p1.
m + ((p2.
m - p1.
m) * f);
529 length = sqrt( (zb-za)*(zb-za) + length*length );
533 partlength += length;
537 if ( partlength == 0 || totlength == 0 )
542 if ( seg == 0 &&
p2d_same(&proj, p) )
550 return partlength / totlength;
#define FLAGS_GET_Z(flags)
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
int p2d_same(const POINT2D *p1, const POINT2D *p2)
void geographic_point_init(double lon, double lat, GEOGRAPHIC_POINT *g)
Initialize a geographic point.
double sphere_distance(const GEOGRAPHIC_POINT *s, const GEOGRAPHIC_POINT *e)
Given two points on a unit sphere, calculate their distance apart in radians.
double edge_distance_to_point(const GEOGRAPHIC_EDGE *e, const GEOGRAPHIC_POINT *gp, GEOGRAPHIC_POINT *closest)
double spheroid_distance(const GEOGRAPHIC_POINT *a, const GEOGRAPHIC_POINT *b, const SPHEROID *spheroid)
Computes the shortest distance along the surface of the spheroid between two points,...
static const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
static double distance(double x1, double y1, double x2, double y2)
Two-point great circle segment from a to b.
Point in spherical coordinates on the world.