31 #include "../postgis_config.h"
33 #include "lwgeom_pg.h"
46 double start_measure = PG_GETARG_FLOAT8(1);
47 double end_measure = PG_GETARG_FLOAT8(2);
54 lwpgerror(
"Only LINESTRING and MULTILINESTRING are supported");
69 gout = geometry_serialize(lwout);
72 PG_RETURN_POINTER(gout);
86 LWGEOM *lwin = NULL, *lwout = NULL;
87 double measure = PG_GETARG_FLOAT8(1);
88 double offset = PG_GETARG_FLOAT8(2);
93 PG_FREE_IF_COPY(gin, 0);
98 gout = geometry_serialize(lwout);
101 PG_RETURN_POINTER(gout);
113 double from = PG_GETARG_FLOAT8(1);
114 double to = PG_GETARG_FLOAT8(2);
115 double offset = PG_GETARG_FLOAT8(3);
118 static char ordinate =
'M';
122 elog(ERROR,
"This function only accepts geometries that have an M dimension.");
129 PG_RETURN_DATUM(DirectFunctionCall3(
ST_LocateAlong, PG_GETARG_DATUM(0), PG_GETARG_DATUM(1), PG_GETARG_DATUM(3)));
135 PG_FREE_IF_COPY(geom_in, 0);
139 elog(ERROR,
"lwline_clip_to_ordinate_range returned null");
143 PG_RETURN_POINTER(geometry_serialize((
LWGEOM*)geom_out));
154 double from = PG_GETARG_FLOAT8(1);
155 double to = PG_GETARG_FLOAT8(2);
158 static char ordinate =
'Z';
159 static double offset = 0.0;
163 elog(ERROR,
"This function only accepts geometries with Z dimensions.");
170 PG_FREE_IF_COPY(geom_in, 0);
174 elog(ERROR,
"lwline_clip_to_ordinate_range returned null");
178 PG_RETURN_POINTER(geometry_serialize((
LWGEOM*)geom_out));
186 GSERIALIZED *gser_line = PG_GETARG_GSERIALIZED_P(0);
187 GSERIALIZED *gser_point = PG_GETARG_GSERIALIZED_P(1);
193 elog(ERROR,
"ST_InterpolatePoint: 1st argument isn't a line");
198 elog(ERROR,
"ST_InterpolatePoint: 2nd argument isn't a point");
206 elog(ERROR,
"ST_InterpolatePoint only accepts geometries that have an M dimension");
231 elog(ERROR,
"line_locate_point: 1st arg isn't a line");
236 elog(ERROR,
"line_locate_point: 2nd arg isn't a point");
250 PG_RETURN_FLOAT8(ret);
void gserialized_error_if_srid_mismatch(const GSERIALIZED *g1, const GSERIALIZED *g2, const char *funcname)
int gserialized_has_m(const GSERIALIZED *g)
Check if a GSERIALIZED has an M ordinate.
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
int gserialized_has_z(const GSERIALIZED *g)
Check if a GSERIALIZED has a Z ordinate.
uint32_t gserialized_get_type(const GSERIALIZED *g)
Extract the geometry type from the serialized form (it hides in the anonymous data area,...
int lwpoint_getPoint4d_p(const LWPOINT *point, POINT4D *out)
LWLINE * lwgeom_as_lwline(const LWGEOM *lwgeom)
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.
void lwgeom_free(LWGEOM *geom)
double lwgeom_interpolate_point(const LWGEOM *lwin, const LWPOINT *lwpt)
Find the measure value at the location on the line closest to the point.
double ptarray_locate_point(const POINTARRAY *pa, const POINT4D *pt, double *dist, POINT4D *p_located)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
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,...
LWLINE * lwline_measured_from_lwline(const LWLINE *lwline, double m_start, double m_end)
Add a measure dimension to a line, interpolating linearly from the start to the end value.
LWMLINE * lwmline_measured_from_lwmline(const LWMLINE *lwmline, double m_start, double m_end)
Re-write the measure ordinate (or add one, if it isn't already there) interpolating the measure betwe...
This library is the generic geometry handling section of PostGIS.
PG_FUNCTION_INFO_V1(ST_AddMeasure)
Datum ST_AddMeasure(PG_FUNCTION_ARGS)
Datum ST_LocateBetweenElevations(PG_FUNCTION_ARGS)
Datum LWGEOM_line_locate_point(PG_FUNCTION_ARGS)
Datum ST_LocateBetween(PG_FUNCTION_ARGS)
Datum ST_InterpolatePoint(PG_FUNCTION_ARGS)
Datum ST_LocateAlong(PG_FUNCTION_ARGS)
static LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)