PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ ST_LocateBetweenElevations()

Datum ST_LocateBetweenElevations ( PG_FUNCTION_ARGS  )

Definition at line 138 of file lwgeom_functions_lrs.c.

References geometry_serialize(), gserialized_has_z(), lwgeom_clip_to_ordinate_range(), lwgeom_free(), lwgeom_from_gserialized(), PG_FUNCTION_INFO_V1(), and ST_InterpolatePoint().

Referenced by ST_LocateBetween().

139 {
140  GSERIALIZED *geom_in = PG_GETARG_GSERIALIZED_P(0);
141  double from = PG_GETARG_FLOAT8(1);
142  double to = PG_GETARG_FLOAT8(2);
143  LWCOLLECTION *geom_out = NULL;
144  LWGEOM *line_in = NULL;
145  static char ordinate = 'Z'; /* Z */
146  static double offset = 0.0;
147 
148  if ( ! gserialized_has_z(geom_in) )
149  {
150  elog(ERROR,"This function only accepts LINESTRING or MULTILINESTRING with Z dimensions.");
151  PG_RETURN_NULL();
152  }
153 
154  line_in = lwgeom_from_gserialized(geom_in);
155  geom_out = lwgeom_clip_to_ordinate_range(line_in, ordinate, from, to, offset);
156  lwgeom_free(line_in);
157  PG_FREE_IF_COPY(geom_in, 0);
158 
159  if ( ! geom_out )
160  {
161  elog(ERROR,"lwline_clip_to_ordinate_range returned null");
162  PG_RETURN_NULL();
163  }
164 
165  PG_RETURN_POINTER(geometry_serialize((LWGEOM*)geom_out));
166 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1050
int gserialized_has_z(const GSERIALIZED *gser)
Check if a GSERIALIZED has a Z ordinate.
Definition: g_serialized.c:24
LWCOLLECTION * lwgeom_clip_to_ordinate_range(const LWGEOM *lwin, char ordinate, double from, double to, double offset)
Given a geometry clip based on the from/to range of one of its ordinates (x, y, z, m).
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
Here is the call graph for this function:
Here is the caller graph for this function: