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

◆ lwgeom_interpolate_point()

double lwgeom_interpolate_point ( const LWGEOM lwin,
const LWPOINT lwpt 
)

Find the measure value at the location on the line closest to the point.

Definition at line 920 of file lwlinearreferencing.c.

921{
922 POINT4D p, p_proj;
923 double ret = 0.0;
924
925 if (!lwin)
926 lwerror("lwgeom_interpolate_point: null input geometry!");
927
928 if (!lwgeom_has_m(lwin))
929 lwerror("Input geometry does not have a measure dimension");
930
931 if (lwgeom_is_empty(lwin) || lwpoint_is_empty(lwpt))
932 lwerror("Input geometry is empty");
933
934 switch (lwin->type)
935 {
936 case LINETYPE:
937 {
938 LWLINE *lwline = lwgeom_as_lwline(lwin);
939 lwpoint_getPoint4d_p(lwpt, &p);
940 ret = ptarray_locate_point(lwline->points, &p, NULL, &p_proj);
941 ret = p_proj.m;
942 break;
943 }
944 default:
945 lwerror("This function does not accept %s geometries.", lwtype_name(lwin->type));
946 }
947 return ret;
948}
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition lwutil.c:216
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
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
Definition lwgeom.c:207
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
Definition lwgeom.c:969
int lwpoint_is_empty(const LWPOINT *point)
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
Definition lwinline.h:199
uint8_t type
Definition liblwgeom.h:462
POINTARRAY * points
Definition liblwgeom.h:483
double m
Definition liblwgeom.h:414

References LINETYPE, lwerror(), lwgeom_as_lwline(), lwgeom_has_m(), lwgeom_is_empty(), lwpoint_getPoint4d_p(), lwpoint_is_empty(), lwtype_name(), POINT4D::m, LWLINE::points, ptarray_locate_point(), and LWGEOM::type.

Referenced by gserialized_distance_nd(), and ST_InterpolatePoint().

Here is the call graph for this function:
Here is the caller graph for this function: