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

◆ ST_InterpolatePoint()

Datum ST_InterpolatePoint ( PG_FUNCTION_ARGS  )

Definition at line 184 of file lwgeom_functions_lrs.c.

185{
186 GSERIALIZED *gser_line = PG_GETARG_GSERIALIZED_P(0);
187 GSERIALIZED *gser_point = PG_GETARG_GSERIALIZED_P(1);
188 LWGEOM *lwline;
189 LWPOINT *lwpoint;
190
191 if ( gserialized_get_type(gser_line) != LINETYPE )
192 {
193 elog(ERROR,"ST_InterpolatePoint: 1st argument isn't a line");
194 PG_RETURN_NULL();
195 }
196 if ( gserialized_get_type(gser_point) != POINTTYPE )
197 {
198 elog(ERROR,"ST_InterpolatePoint: 2nd argument isn't a point");
199 PG_RETURN_NULL();
200 }
201
202 gserialized_error_if_srid_mismatch(gser_line, gser_point, __func__);
203
204 if ( ! gserialized_has_m(gser_line) )
205 {
206 elog(ERROR,"ST_InterpolatePoint only accepts geometries that have an M dimension");
207 PG_RETURN_NULL();
208 }
209
210 lwpoint = lwgeom_as_lwpoint(lwgeom_from_gserialized(gser_point));
211 lwline = lwgeom_from_gserialized(gser_line);
212
213 PG_RETURN_FLOAT8(lwgeom_interpolate_point(lwline, lwpoint));
214}
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.
int gserialized_has_m(const GSERIALIZED *g)
Check if a GSERIALIZED has an M ordinate.
uint32_t gserialized_get_type(const GSERIALIZED *g)
Extract the geometry type from the serialized form (it hides in the anonymous data area,...
#define LINETYPE
Definition liblwgeom.h:103
double lwgeom_interpolate_point(const LWGEOM *lwin, const LWPOINT *lwpt)
Find the measure value at the location on the line closest to the point.
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition liblwgeom.h:102
static LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
Definition lwinline.h:127

References gserialized_error_if_srid_mismatch(), gserialized_get_type(), gserialized_has_m(), LINETYPE, lwgeom_as_lwpoint(), lwgeom_from_gserialized(), lwgeom_interpolate_point(), and POINTTYPE.

Here is the call graph for this function: