PostGIS  2.1.10dev-r@@SVN_REVISION@@
Datum ST_InterpolatePoint ( PG_FUNCTION_ARGS  )

Definition at line 171 of file lwgeom_functions_lrs.c.

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

172 {
173  GSERIALIZED *gser_line = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
174  GSERIALIZED *gser_point = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
175  LWGEOM *lwline;
176  LWPOINT *lwpoint;
177 
178  if ( gserialized_get_type(gser_line) != LINETYPE )
179  {
180  elog(ERROR,"ST_InterpolatePoint: 1st argument isn't a line");
181  PG_RETURN_NULL();
182  }
183  if ( gserialized_get_type(gser_point) != POINTTYPE )
184  {
185  elog(ERROR,"ST_InterpolatePoint: 2st argument isn't a point");
186  PG_RETURN_NULL();
187  }
188  if ( gserialized_get_srid(gser_line) != gserialized_get_srid(gser_point) )
189  {
190  elog(ERROR, "Operation on two geometries with different SRIDs");
191  PG_RETURN_NULL();
192  }
193  if ( ! gserialized_has_m(gser_line) )
194  {
195  elog(ERROR,"ST_InterpolatePoint only accepts geometries that have an M dimension");
196  PG_RETURN_NULL();
197  }
198 
199  lwpoint = lwgeom_as_lwpoint(lwgeom_from_gserialized(gser_point));
200  lwline = lwgeom_from_gserialized(gser_line);
201 
202  PG_RETURN_FLOAT8(lwgeom_interpolate_point(lwline, lwpoint));
203 }
#define LINETYPE
Definition: liblwgeom.h:61
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:56
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:30
LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
Definition: lwgeom.c:80
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:60
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:70

Here is the call graph for this function: