505 double from = PG_GETARG_FLOAT8(1);
506 double to = PG_GETARG_FLOAT8(2);
512 if ( from < 0 || from > 1 )
514 elog(ERROR,
"line_interpolate_point: 2nd arg isn't within [0,1]");
518 if ( to < 0 || to > 1 )
520 elog(ERROR,
"line_interpolate_point: 3rd arg isn't within [0,1]");
526 elog(ERROR,
"2nd arg must be smaller then 3rd arg");
538 PG_FREE_IF_COPY(geom, 0);
558 double length = 0.0, sublength = 0.0, minprop = 0.0, maxprop = 0.0;
566 PG_FREE_IF_COPY(geom, 0);
571 for ( i = 0; i < iline->ngeoms; i++ )
581 for ( i = 0; i < iline->ngeoms; i++ )
584 double subfrom = 0.0, subto = 0.0;
591 maxprop = sublength / length;
595 if ( from > maxprop || to < minprop )
598 if ( from <= minprop )
603 if ( from > minprop && from <= maxprop )
604 subfrom = (from - minprop) / (maxprop - minprop);
606 if ( to < maxprop && to >= minprop )
607 subto = (to - minprop) / (maxprop - minprop);
636 elog(ERROR,
"line_substring: 1st arg isn't a line");
642 PG_FREE_IF_COPY(geom, 0);
643 PG_RETURN_POINTER(ret);
uint32_t gserialized_get_type(const GSERIALIZED *s)
Extract the geometry type from the serialized form (it hides in the anonymous data area...
LWCOLLECTION * lwcollection_construct(uint8_t type, int srid, GBOX *bbox, uint32_t ngeoms, LWGEOM **geoms)
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
POINTARRAY * ptarray_substring(POINTARRAY *pa, double d1, double d2, double tolerance)
start location (distance from start / total distance) end location (distance from start / total dist...
double ptarray_length_2d(const POINTARRAY *pts)
Find the 2d length of the given POINTARRAY (even if it's 3d)
#define LW_TRUE
Return types for functions with status returns.
LWLINE * lwline_construct(int srid, GBOX *bbox, POINTARRAY *points)
#define SRID_UNKNOWN
Unknown SRID value.
LWMLINE * lwgeom_as_lwmline(const LWGEOM *lwgeom)
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
LWPOINT * lwpoint_construct(int srid, GBOX *bbox, POINTARRAY *point)
void * lwalloc(size_t size)
int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members) ...
void lwmline_release(LWMLINE *lwline)
void lwline_release(LWLINE *lwline)