PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ ST_AddMeasure()

Datum ST_AddMeasure ( PG_FUNCTION_ARGS  )

Definition at line 42 of file lwgeom_functions_lrs.c.

References geometry_serialize(), gserialized_get_type(), LINETYPE, lwgeom_free(), lwgeom_from_gserialized(), lwline_measured_from_lwline(), lwmline_measured_from_lwmline(), MULTILINETYPE, PG_FUNCTION_INFO_V1(), ST_LocateAlong(), and ovdump::type.

43 {
44  GSERIALIZED *gin = PG_GETARG_GSERIALIZED_P(0);
45  GSERIALIZED *gout;
46  double start_measure = PG_GETARG_FLOAT8(1);
47  double end_measure = PG_GETARG_FLOAT8(2);
48  LWGEOM *lwin, *lwout;
49  int type = gserialized_get_type(gin);
50 
51  /* Raise an error if input is not a linestring or multilinestring */
52  if ( type != LINETYPE && type != MULTILINETYPE )
53  {
54  lwpgerror("Only LINESTRING and MULTILINESTRING are supported");
55  PG_RETURN_NULL();
56  }
57 
58  lwin = lwgeom_from_gserialized(gin);
59  if ( type == LINETYPE )
60  lwout = (LWGEOM*)lwline_measured_from_lwline((LWLINE*)lwin, start_measure, end_measure);
61  else
62  lwout = (LWGEOM*)lwmline_measured_from_lwmline((LWMLINE*)lwin, start_measure, end_measure);
63 
64  lwgeom_free(lwin);
65 
66  if ( lwout == NULL )
67  PG_RETURN_NULL();
68 
69  gout = geometry_serialize(lwout);
70  lwgeom_free(lwout);
71 
72  PG_RETURN_POINTER(gout);
73 }
#define LINETYPE
Definition: liblwgeom.h:86
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:86
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...
Definition: lwline.c:396
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1099
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...
Definition: lwmline.c:56
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
type
Definition: ovdump.py:41
#define MULTILINETYPE
Definition: liblwgeom.h:89
Here is the call graph for this function: