518 double from = PG_GETARG_FLOAT8(1);
519 double to = PG_GETARG_FLOAT8(2);
525 if ( from < 0 || from > 1 )
527 elog(ERROR,
"line_interpolate_point: 2nd arg isn't within [0,1]");
531 if ( to < 0 || to > 1 )
533 elog(ERROR,
"line_interpolate_point: 3rd arg isn't within [0,1]");
539 elog(ERROR,
"2nd arg must be smaller then 3rd arg");
551 PG_FREE_IF_COPY(geom, 0);
568 uint32_t i = 0, g = 0;
571 double length = 0.0, sublength = 0.0, minprop = 0.0, maxprop = 0.0;
579 PG_FREE_IF_COPY(geom, 0);
584 for ( i = 0; i < iline->ngeoms; i++ )
594 for ( i = 0; i < iline->ngeoms; i++ )
597 double subfrom = 0.0, subto = 0.0;
604 maxprop = sublength / length;
608 if ( from > maxprop || to < minprop )
611 if ( from <= minprop )
616 if ( from > minprop && from <= maxprop )
617 subfrom = (from - minprop) / (maxprop - minprop);
619 if ( to < maxprop && to >= minprop )
620 subto = (to - minprop) / (maxprop - minprop);
649 elog(ERROR,
"line_substring: 1st arg isn't a line");
655 PG_FREE_IF_COPY(geom, 0);
656 PG_RETURN_POINTER(ret);
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
uint32_t gserialized_get_type(const GSERIALIZED *g)
Extract the geometry type from the serialized form (it hides in the anonymous data area,...
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
POINTARRAY * ptarray_substring(POINTARRAY *pa, double d1, double d2, double tolerance)
@d1 start location (distance from start / total distance) @d2 end location (distance from start / tot...
void lwgeom_free(LWGEOM *geom)
void lwline_release(LWLINE *lwline)
double ptarray_length_2d(const POINTARRAY *pts)
Find the 2d length of the given POINTARRAY (even if it's 3d)
LWLINE * lwline_construct(int32_t srid, GBOX *bbox, POINTARRAY *points)
void lwmline_release(LWMLINE *lwline)
LWMLINE * lwgeom_as_lwmline(const LWGEOM *lwgeom)
LWPOINT * lwpoint_construct(int32_t srid, GBOX *bbox, POINTARRAY *point)
void * lwalloc(size_t size)
LWCOLLECTION * lwcollection_construct(uint8_t type, int32_t srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
#define LW_TRUE
Return types for functions with status returns.
#define SRID_UNKNOWN
Unknown SRID value.
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)