478 double from = PG_GETARG_FLOAT8(1);
479 double to = PG_GETARG_FLOAT8(2);
485 if ( from < 0 || from > 1 )
487 elog(ERROR,
"line_interpolate_point: 2nd arg isn't within [0,1]");
491 if ( to < 0 || to > 1 )
493 elog(ERROR,
"line_interpolate_point: 3rd arg isn't within [0,1]");
499 elog(ERROR,
"2nd arg must be smaller then 3rd arg");
511 PG_FREE_IF_COPY(geom, 0);
531 double length = 0.0, sublength = 0.0, minprop = 0.0, maxprop = 0.0;
539 PG_FREE_IF_COPY(geom, 0);
544 for ( i = 0; i < iline->ngeoms; i++ )
554 for ( i = 0; i < iline->ngeoms; i++ )
557 double subfrom = 0.0, subto = 0.0;
564 maxprop = sublength / length;
568 if ( from > maxprop || to < minprop )
571 if ( from <= minprop )
576 if ( from > minprop && from <= maxprop )
577 subfrom = (from - minprop) / (maxprop - minprop);
579 if ( to < maxprop && to >= minprop )
580 subto = (to - minprop) / (maxprop - minprop);
609 elog(ERROR,
"line_substring: 1st arg isn't a line");
615 PG_FREE_IF_COPY(geom, 0);
616 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 *s)
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)
void lwmline_release(LWMLINE *lwline)
LWMLINE * lwgeom_as_lwmline(const LWGEOM *lwgeom)
LWPOINT * lwpoint_construct(int srid, GBOX *bbox, POINTARRAY *point)
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
LWCOLLECTION * lwcollection_construct(uint8_t type, int srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
void * lwalloc(size_t size)
#define LW_TRUE
Return types for functions with status returns.
#define SRID_UNKNOWN
Unknown SRID value.
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)