Interpolate one or more points along a line.
538 {
540 uint32_t i;
541 uint32_t points_to_interpolate;
542 uint32_t points_found = 0;
543 double length;
544 double length_fraction_increment = length_fraction;
545 double length_fraction_consumed = 0;
550
551
553 {
555 }
556
557
558
559
560 if ( length_fraction == 0.0 || length_fraction == 1.0 )
561 {
562 if ( length_fraction == 0.0 )
564 else
566
569
570 return opa;
571 }
572
573
575 points_to_interpolate = repeat ? (uint32_t) floor(1 / length_fraction) : 1;
577
579 for ( i = 0; i < ipa->
npoints - 1 && points_found < points_to_interpolate; i++ )
580 {
583
584
585
586
587
588 while ( length_fraction < length_fraction_consumed + segment_length_frac && points_found < points_to_interpolate )
589 {
592
593 double segment_fraction = (length_fraction - length_fraction_consumed) / segment_length_frac;
596 length_fraction += length_fraction_increment;
597 }
598
599 length_fraction_consumed += segment_length_frac;
600
601 p1 = p2;
602 }
603
604
605
606 if (points_found < points_to_interpolate) {
609 }
610
611 return opa;
612}
POINT4D getPoint4d(const POINTARRAY *pa, uint32_t n)
double distance2d_pt_pt(const POINT2D *p1, const POINT2D *p2)
void interpolate_point4d(const POINT4D *A, const POINT4D *B, POINT4D *I, double F)
Find interpolation point I between point A and point B so that the len(AI) == len(AB)*F and I falls o...
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
double ptarray_length_2d(const POINTARRAY *pts)
Find the 2d length of the given POINTARRAY (even if it's 3d)
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
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)
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 lwline_is_empty(const LWLINE *line)
static const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.