Interpolate one or more points along a line.
528 {
530 uint32_t i;
531 uint32_t points_to_interpolate;
532 uint32_t points_found = 0;
533 double length;
534 double length_fraction_increment = length_fraction;
535 double length_fraction_consumed = 0;
540
541
543 {
545 }
546
547
548
549
550 if ( length_fraction == 0.0 || length_fraction == 1.0 )
551 {
552 if ( length_fraction == 0.0 )
554 else
556
559
560 return opa;
561 }
562
563
565 points_to_interpolate = repeat ? (uint32_t) floor(1 / length_fraction) : 1;
567
569 for ( i = 0; i < ipa->
npoints - 1 && points_found < points_to_interpolate; i++ )
570 {
573
574
575
576
577
578 while ( length_fraction < length_fraction_consumed + segment_length_frac && points_found < points_to_interpolate )
579 {
582
583 double segment_fraction = (length_fraction - length_fraction_consumed) / segment_length_frac;
586 length_fraction += length_fraction_increment;
587 }
588
589 length_fraction_consumed += segment_length_frac;
590
591 p1 = p2;
592 }
593
594
595
596 if (points_found < points_to_interpolate) {
599 }
600
601 return opa;
602}
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.