PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ lwgeom_locate_along()

LWGEOM* lwgeom_locate_along ( const LWGEOM lwin,
double  m,
double  offset 
)

Determine the location(s) along a measured line where m occurs and return as a multipoint.

Offset to left (positive) or right (negative).

Definition at line 219 of file lwlinearreferencing.c.

220 {
221  if (!lwin)
222  return NULL;
223 
224  if (!lwgeom_has_m(lwin))
225  lwerror("Input geometry does not have a measure dimension");
226 
227  switch (lwin->type)
228  {
229  case POINTTYPE:
230  return (LWGEOM *)lwpoint_locate_along((LWPOINT *)lwin, m, offset);
231  case MULTIPOINTTYPE:
232  return (LWGEOM *)lwmpoint_locate_along((LWMPOINT *)lwin, m, offset);
233  case LINETYPE:
234  return (LWGEOM *)lwline_locate_along((LWLINE *)lwin, m, offset);
235  case MULTILINETYPE:
236  return (LWGEOM *)lwmline_locate_along((LWMLINE *)lwin, m, offset);
237  /* Only line types supported right now */
238  /* TO DO: CurveString, CompoundCurve, MultiCurve */
239  /* TO DO: Point, MultiPoint */
240  default:
241  lwerror("Only linear geometries are supported, %s provided.", lwtype_name(lwin->type));
242  return NULL;
243  }
244  return NULL;
245 }
#define MULTILINETYPE
Definition: liblwgeom.h:120
#define LINETYPE
Definition: liblwgeom.h:117
#define MULTIPOINTTYPE
Definition: liblwgeom.h:119
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:116
const char * lwtype_name(uint8_t type)
Return the type name string associated with a type number (e.g.
Definition: lwutil.c:216
int lwgeom_has_m(const LWGEOM *geom)
Return LW_TRUE if geometry has M ordinates.
Definition: lwgeom.c:923
void lwerror(const char *fmt,...)
Write a notice out to the error handler.
Definition: lwutil.c:190
static LWMPOINT * lwmline_locate_along(const LWMLINE *lwmline, double m, double offset)
static LWMPOINT * lwpoint_locate_along(const LWPOINT *lwpoint, double m, __attribute__((__unused__)) double offset)
static LWMPOINT * lwmpoint_locate_along(const LWMPOINT *lwin, double m, __attribute__((__unused__)) double offset)
static LWMPOINT * lwline_locate_along(const LWLINE *lwline, double m, double offset)
uint8_t type
Definition: liblwgeom.h:448

References LINETYPE, lwerror(), lwgeom_has_m(), lwline_locate_along(), lwmline_locate_along(), lwmpoint_locate_along(), lwpoint_locate_along(), lwtype_name(), MULTILINETYPE, MULTIPOINTTYPE, POINTTYPE, LWGEOM::type, and LWPOINT::type.

Referenced by ST_LocateAlong(), and test_lwgeom_locate_along().

Here is the call graph for this function:
Here is the caller graph for this function: