PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ ST_LocateBetween()

Datum ST_LocateBetween ( PG_FUNCTION_ARGS  )

Definition at line 110 of file lwgeom_functions_lrs.c.

111 {
112  GSERIALIZED *geom_in = PG_GETARG_GSERIALIZED_P(0);
113  double from = PG_GETARG_FLOAT8(1);
114  double to = PG_GETARG_FLOAT8(2);
115  double offset = PG_GETARG_FLOAT8(3);
116  LWCOLLECTION *geom_out = NULL;
117  LWGEOM *line_in = NULL;
118  static char ordinate = 'M'; /* M */
119 
120  if ( ! gserialized_has_m(geom_in) )
121  {
122  elog(ERROR,"This function only accepts geometries that have an M dimension.");
123  PG_RETURN_NULL();
124  }
125 
126  /* This should be a call to ST_LocateAlong! */
127  if ( to == from )
128  {
129  PG_RETURN_DATUM(DirectFunctionCall3(ST_LocateAlong, PG_GETARG_DATUM(0), PG_GETARG_DATUM(1), PG_GETARG_DATUM(3)));
130  }
131 
132  line_in = lwgeom_from_gserialized(geom_in);
133  geom_out = lwgeom_clip_to_ordinate_range(line_in, ordinate, from, to, offset);
134  lwgeom_free(line_in);
135  PG_FREE_IF_COPY(geom_in, 0);
136 
137  if ( ! geom_out )
138  {
139  elog(ERROR,"lwline_clip_to_ordinate_range returned null");
140  PG_RETURN_NULL();
141  }
142 
143  PG_RETURN_POINTER(geometry_serialize((LWGEOM*)geom_out));
144 }
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
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1144
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,...
Datum ST_LocateAlong(PG_FUNCTION_ARGS)
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)

References geometry_serialize(), gserialized_has_m(), lwgeom_clip_to_ordinate_range(), lwgeom_free(), lwgeom_from_gserialized(), and ST_LocateAlong().

Here is the call graph for this function: