Interpolate a point along a geographic line.
262 uint32_t points_to_interpolate;
263 uint32_t points_found = 0;
265 double length_fraction_increment = length_fraction;
266 double length_fraction_consumed = 0;
275 uint32_t srid = line->
srid;
287 if ( length_fraction == 0.0 || length_fraction == 1.0 )
289 if ( length_fraction == 0.0 )
301 points_to_interpolate = repeat ? (uint32_t) floor(1 / length_fraction) : 1;
306 for ( i = 0; i < ipa->
npoints - 1 && points_found < points_to_interpolate; i++ )
308 double segment_length_frac;
323 while ( length_fraction < length_fraction_consumed + segment_length_frac && points_found < points_to_interpolate )
327 double segment_fraction = (length_fraction - length_fraction_consumed) / segment_length_frac;
330 length_fraction += length_fraction_increment;
333 length_fraction_consumed += segment_length_frac;
341 if (points_found < points_to_interpolate)
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
LWGEOM * lwmpoint_as_lwgeom(const LWMPOINT *obj)
LWGEOM * lwgeom_clone_deep(const LWGEOM *lwgeom)
Deep clone an LWGEOM, everything is copied.
POINTARRAY * ptarray_construct(char hasz, char hasm, uint32_t npoints)
Construct an empty pointarray, allocating storage and setting the npoints, but not filling in any inf...
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
LWPOINT * lwpoint_construct(int32_t srid, GBOX *bbox, POINTARRAY *point)
int getPoint4d_p(const POINTARRAY *pa, uint32_t n, POINT4D *point)
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
void ptarray_set_point4d(POINTARRAY *pa, uint32_t n, const POINT4D *p4d)
LWMPOINT * lwmpoint_construct(int32_t srid, const POINTARRAY *pa)
int lwline_is_empty(const LWLINE *line)
void geographic_point_init(double lon, double lat, GEOGRAPHIC_POINT *g)
Initialize a geographic point.
double ptarray_length_spheroid(const POINTARRAY *pa, const SPHEROID *s)
double sphere_distance(const GEOGRAPHIC_POINT *s, const GEOGRAPHIC_POINT *e)
Given two points on a unit sphere, calculate their distance apart in radians.
void geog2cart(const GEOGRAPHIC_POINT *g, POINT3D *p)
Convert spherical coordinates to cartesian coordinates on unit sphere.
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 void interpolate_point4d_spheroid(const POINT4D *p1, const POINT4D *p2, POINT4D *p, const SPHEROID *s, double f)
Find interpolation point p between geography points p1 and p2 so that the len(p1,p) == len(p1,...
Point in spherical coordinates on the world.