PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ LWGEOM_line_locate_point()

Datum LWGEOM_line_locate_point ( PG_FUNCTION_ARGS  )

Definition at line 219 of file lwgeom_functions_lrs.c.

220{
221 GSERIALIZED *geom1 = PG_GETARG_GSERIALIZED_P(0);
222 GSERIALIZED *geom2 = PG_GETARG_GSERIALIZED_P(1);
223 LWLINE *lwline;
224 LWPOINT *lwpoint;
225 POINTARRAY *pa;
226 POINT4D p, p_proj;
227 double ret;
228
229 if ( gserialized_get_type(geom1) != LINETYPE )
230 {
231 elog(ERROR,"line_locate_point: 1st arg isn't a line");
232 PG_RETURN_NULL();
233 }
234 if ( gserialized_get_type(geom2) != POINTTYPE )
235 {
236 elog(ERROR,"line_locate_point: 2nd arg isn't a point");
237 PG_RETURN_NULL();
238 }
239
240 gserialized_error_if_srid_mismatch(geom1, geom2, __func__);
241
244
245 pa = lwline->points;
246 lwpoint_getPoint4d_p(lwpoint, &p);
247
248 ret = ptarray_locate_point(pa, &p, NULL, &p_proj);
249
250 PG_RETURN_FLOAT8(ret);
251}
void gserialized_error_if_srid_mismatch(const GSERIALIZED *g1, const GSERIALIZED *g2, const char *funcname)
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,...
int lwpoint_getPoint4d_p(const LWPOINT *point, POINT4D *out)
Definition lwpoint.c:57
#define LINETYPE
Definition liblwgeom.h:103
double ptarray_locate_point(const POINTARRAY *pa, const POINT4D *pt, double *dist, POINT4D *p_located)
Definition ptarray.c:1518
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition liblwgeom.h:102
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
Definition lwgeom.c:207
static LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
Definition lwinline.h:127
POINTARRAY * points
Definition liblwgeom.h:483

References gserialized_error_if_srid_mismatch(), gserialized_get_type(), LINETYPE, lwgeom_as_lwline(), lwgeom_as_lwpoint(), lwgeom_from_gserialized(), lwpoint_getPoint4d_p(), LWLINE::points, POINTTYPE, and ptarray_locate_point().

Here is the call graph for this function: