PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ ST_InterpolatePoint()

Datum ST_InterpolatePoint ( PG_FUNCTION_ARGS  )

Definition at line 171 of file lwgeom_functions_lrs.c.

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

Referenced by ST_LocateBetweenElevations().

172 {
173  GSERIALIZED *gser_line = PG_GETARG_GSERIALIZED_P(0);
174  GSERIALIZED *gser_point = PG_GETARG_GSERIALIZED_P(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 
190 
191  if ( ! gserialized_has_m(gser_line) )
192  {
193  elog(ERROR,"ST_InterpolatePoint only accepts geometries that have an M dimension");
194  PG_RETURN_NULL();
195  }
196 
197  lwpoint = lwgeom_as_lwpoint(lwgeom_from_gserialized(gser_point));
198  lwline = lwgeom_from_gserialized(gser_line);
199 
200  PG_RETURN_FLOAT8(lwgeom_interpolate_point(lwline, lwpoint));
201 }
#define LINETYPE
Definition: liblwgeom.h:71
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:55
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:29
void error_if_srid_mismatch(int srid1, int srid2)
Definition: lwutil.c:341
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:70
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:69
Here is the call graph for this function:
Here is the caller graph for this function: