Locate a point along the point array defining a geographic line.
376 int use_sphere = (
s->a ==
s->b ? 1 : 0);
378 double za = 0.0, zb = 0.0;
391 double mindist = 0.0;
399 if ( ! use_sphere || mindist > 0.95 * tolerance )
404 if ( mindistout ) *mindistout = mindist;
416 for ( i = 1; i < pa->
npoints; i++ )
439 else if ( d < tolerance * 0.95 )
455 if ( mindistout ) *mindistout =
distance;
467 for ( i = 1; i < pa->
npoints; i++ )
483 length = sqrt( (zb-za)*(zb-za) + length*length );
490 partlength += length;
491 else if (i - 1 == seg)
523 double f = length / seglength;
525 proj4d->
z = p1.
z + ((p2.
z - p1.
z) * f);
526 proj4d->
m = p1.
m + ((p2.
m - p1.
m) * f);
530 length = sqrt( (zb-za)*(zb-za) + length*length );
534 partlength += length;
538 if ( partlength == 0 || totlength == 0 )
543 if ( seg == 0 &&
p2d_same(&proj, p) )
551 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.