PostGIS  2.2.8dev-r@@SVN_REVISION@@

◆ LWGEOM_line_from_mpoint()

Datum LWGEOM_line_from_mpoint ( PG_FUNCTION_ARGS  )

Definition at line 1299 of file lwgeom_functions_basic.c.

References geometry_serialize(), gserialized_get_type(), lwgeom_as_lwmpoint(), lwgeom_from_gserialized(), LWGEOM_makeline_garray(), lwline_as_lwgeom(), lwline_free(), lwline_from_lwmpoint(), MULTIPOINTTYPE, PG_FUNCTION_INFO_V1(), and LWMPOINT::srid.

Referenced by LWGEOM_collect_garray().

1300 {
1301  GSERIALIZED *ingeom, *result;
1302  LWLINE *lwline;
1303  LWMPOINT *mpoint;
1304 
1305  POSTGIS_DEBUG(2, "LWGEOM_line_from_mpoint called");
1306 
1307  /* Get input GSERIALIZED and deserialize it */
1308  ingeom = PG_GETARG_GSERIALIZED_P(0);
1309 
1310  if ( gserialized_get_type(ingeom) != MULTIPOINTTYPE )
1311  {
1312  elog(ERROR, "makeline: input must be a multipoint");
1313  PG_RETURN_NULL(); /* input is not a multipoint */
1314  }
1315 
1316  mpoint = lwgeom_as_lwmpoint(lwgeom_from_gserialized(ingeom));
1317  lwline = lwline_from_lwmpoint(mpoint->srid, mpoint);
1318  if ( ! lwline )
1319  {
1320  PG_FREE_IF_COPY(ingeom, 0);
1321  elog(ERROR, "makeline: lwline_from_lwmpoint returned NULL");
1322  PG_RETURN_NULL();
1323  }
1324 
1325  result = geometry_serialize(lwline_as_lwgeom(lwline));
1326 
1327  PG_FREE_IF_COPY(ingeom, 0);
1328  lwline_free(lwline);
1329 
1330  PG_RETURN_POINTER(result);
1331 }
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:55
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
#define MULTIPOINTTYPE
Definition: liblwgeom.h:73
void lwline_free(LWLINE *line)
Definition: lwline.c:63
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
Definition: lwgeom.c:249
LWLINE * lwline_from_lwmpoint(int srid, const LWMPOINT *mpoint)
Definition: lwline.c:261
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
LWMPOINT * lwgeom_as_lwmpoint(const LWGEOM *lwgeom)
Definition: lwgeom.c:152
int32_t srid
Definition: liblwgeom.h:451
Here is the call graph for this function:
Here is the caller graph for this function: