PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ 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)
Definition: gserialized.c:404
int gserialized_has_m(const GSERIALIZED *g)
Check if a GSERIALIZED has an M ordinate.
Definition: gserialized.c:185
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:239
uint32_t gserialized_get_type(const GSERIALIZED *g)
Extract the geometry type from the serialized form (it hides in the anonymous data area,...
Definition: gserialized.c:89
#define LINETYPE
Definition: liblwgeom.h:117
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:116
static LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
Definition: lwinline.h:121

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: