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

◆ geography_line_locate_point()

Datum geography_line_locate_point ( PG_FUNCTION_ARGS  )

Definition at line 1346 of file geography_measurement.c.

1347{
1348 GSERIALIZED *gs1 = PG_GETARG_GSERIALIZED_P(0);
1349 GSERIALIZED *gs2 = PG_GETARG_GSERIALIZED_P(1);
1350 bool use_spheroid = PG_GETARG_BOOL(2);
1351 double tolerance = FP_TOLERANCE;
1352 SPHEROID s;
1353 LWLINE *lwline;
1354 LWPOINT *lwpoint;
1355 POINTARRAY *pa;
1356 POINT4D p, p_proj;
1357 double ret;
1358
1359 gserialized_error_if_srid_mismatch(gs1, gs2, __func__);
1360
1361 /* Return NULL on empty argument. */
1363 {
1364 PG_FREE_IF_COPY(gs1, 0);
1365 PG_FREE_IF_COPY(gs2, 1);
1366 PG_RETURN_NULL();
1367 }
1368
1369 if ( gserialized_get_type(gs1) != LINETYPE )
1370 {
1371 elog(ERROR,"%s: 1st arg is not a line", __func__);
1372 PG_RETURN_NULL();
1373 }
1374 if ( gserialized_get_type(gs2) != POINTTYPE )
1375 {
1376 elog(ERROR,"%s: 2nd arg is not a point", __func__);
1377 PG_RETURN_NULL();
1378 }
1379
1380 /* Set to sphere if requested */
1381 if ( ! use_spheroid ) {
1382 s.a = s.b = s.radius;
1383 }
1384 else {
1385 /* Initialize spheroid */
1386 spheroid_init_from_srid(gserialized_get_srid(gs1), &s);
1387 }
1388
1391
1392 pa = lwline->points;
1393 lwpoint_getPoint4d_p(lwpoint, &p);
1394
1395 ret = ptarray_locate_point_spheroid(pa, &p, &s, tolerance, NULL, &p_proj);
1396
1397 PG_RETURN_FLOAT8(ret);
1398}
char * s
Definition cu_in_wkt.c:23
void gserialized_error_if_srid_mismatch(const GSERIALIZED *g1, const GSERIALIZED *g2, const char *funcname)
int32_t gserialized_get_srid(const GSERIALIZED *g)
Extract the SRID from the serialized form (it is packed into three bytes so this is a handy function)...
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
int gserialized_is_empty(const GSERIALIZED *g)
Check if a GSERIALIZED is empty without deserializing first.
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
double ptarray_locate_point_spheroid(const POINTARRAY *pa, const POINT4D *p4d, const SPHEROID *s, double tolerance, double *mindistout, POINT4D *proj4d)
Locate a point along the point array defining a geographic line.
#define LINETYPE
Definition liblwgeom.h:103
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition liblwgeom.h:102
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
Definition lwgeom.c:207
#define FP_TOLERANCE
Floating point comparators.
static LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
Definition lwinline.h:127
POINTARRAY * points
Definition liblwgeom.h:483

References FP_TOLERANCE, gserialized_error_if_srid_mismatch(), gserialized_get_srid(), gserialized_get_type(), gserialized_is_empty(), LINETYPE, lwgeom_as_lwline(), lwgeom_as_lwpoint(), lwgeom_from_gserialized(), lwpoint_getPoint4d_p(), LWLINE::points, POINTTYPE, ptarray_locate_point_spheroid(), and s.

Here is the call graph for this function: