PostGIS  2.5.7dev-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: 2st argument isn't a point");
199  PG_RETURN_NULL();
200  }
201 
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 }
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.
int gserialized_has_m(const GSERIALIZED *gser)
Check if a GSERIALIZED has an M ordinate.
Definition: g_serialized.c:50
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
#define LINETYPE
Definition: liblwgeom.h:86
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: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

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