PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ 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: 2st arg isn't a point");
237  PG_RETURN_NULL();
238  }
239 
241 
242  lwline = lwgeom_as_lwline(lwgeom_from_gserialized(geom1));
243  lwpoint = lwgeom_as_lwpoint(lwgeom_from_gserialized(geom2));
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 }
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)...
Definition: g_serialized.c:100
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,...
Definition: g_serialized.c:86
int lwpoint_getPoint4d_p(const LWPOINT *point, POINT4D *out)
Definition: lwpoint.c:57
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
Definition: lwgeom.c:170
#define LINETYPE
Definition: liblwgeom.h:86
double ptarray_locate_point(const POINTARRAY *pa, const POINT4D *pt, double *dist, POINT4D *p_located)
Definition: ptarray.c:1305
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
Definition: lwgeom.c:161
void error_if_srid_mismatch(int srid1, int srid2)
Definition: lwutil.c:338
POINTARRAY * points
Definition: liblwgeom.h:425

References error_if_srid_mismatch(), gserialized_get_srid(), 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: