157 double distance = PG_GETARG_FLOAT8(1);
164 double length, slength, tlength;
166 if ( distance < 0 || distance > 1 )
168 elog(ERROR,
"line_interpolate_point: 2nd arg isn't within [0,1]");
174 elog(ERROR,
"line_interpolate_point: 1st arg isn't a line");
184 PG_RETURN_POINTER(result);
194 if ( distance == 0.0 || distance == 1.0 )
196 if ( distance == 0.0 )
212 for ( i = 0; i < nsegs; i++ )
215 POINT4D *p1ptr=&p1, *p2ptr=&p2;
229 if ( distance < tlength + slength )
231 double dseg = (distance - tlength) / slength;
247 PG_FREE_IF_COPY(gser, 0);
void ptarray_set_point4d(POINTARRAY *pa, int n, const POINT4D *p4d)
uint32_t gserialized_get_type(const GSERIALIZED *s)
Extract the geometry type from the serialized form (it hides in the anonymous data area...
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...
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
int gserialized_has_m(const GSERIALIZED *gser)
Check if a GSERIALIZED has an M ordinate.
void lwpoint_free(LWPOINT *pt)
double ptarray_length_2d(const POINTARRAY *pts)
Find the 2d length of the given POINTARRAY (even if it's 3d)
double distance2d_pt_pt(const POINT2D *p1, const POINT2D *p2)
The old function nessecary for ptarray_segmentize2d in ptarray.c.
LWPOINT * lwpoint_construct_empty(int srid, char hasz, char hasm)
int gserialized_has_z(const GSERIALIZED *gser)
Check if a GSERIALIZED has a Z ordinate.
int lwgeom_has_z(const LWGEOM *geom)
Return LW_TRUE if geometry has Z ordinates.
void interpolate_point4d(POINT4D *A, 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...
int gserialized_is_empty(const GSERIALIZED *g)
Check if a GSERIALIZED is empty without deserializing first.
Datum distance(PG_FUNCTION_ARGS)
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
LWGEOM * lwpoint_as_lwgeom(const LWPOINT *obj)
LWPOINT * lwpoint_construct(int srid, GBOX *bbox, POINTARRAY *point)
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
int32_t gserialized_get_srid(const GSERIALIZED *s)
Extract the SRID from the serialized form (it is packed into three bytes so this is a handy function)...
int getPoint4d_p(const POINTARRAY *pa, int n, POINT4D *point)