PostGIS  2.1.10dev-r@@SVN_REVISION@@
Datum LWGEOM_line_from_mpoint ( PG_FUNCTION_ARGS  )

Definition at line 1351 of file lwgeom_functions_basic.c.

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

1352 {
1353  GSERIALIZED *ingeom, *result;
1354  LWLINE *lwline;
1355  LWMPOINT *mpoint;
1356 
1357  POSTGIS_DEBUG(2, "LWGEOM_line_from_mpoint called");
1358 
1359  /* Get input GSERIALIZED and deserialize it */
1360  ingeom = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
1361 
1362  if ( gserialized_get_type(ingeom) != MULTIPOINTTYPE )
1363  {
1364  elog(ERROR, "makeline: input must be a multipoint");
1365  PG_RETURN_NULL(); /* input is not a multipoint */
1366  }
1367 
1368  mpoint = lwgeom_as_lwmpoint(lwgeom_from_gserialized(ingeom));
1369  lwline = lwline_from_lwmpoint(mpoint->srid, mpoint);
1370  if ( ! lwline )
1371  {
1372  PG_FREE_IF_COPY(ingeom, 0);
1373  elog(ERROR, "makeline: lwline_from_lwmpoint returned NULL");
1374  PG_RETURN_NULL();
1375  }
1376 
1377  result = geometry_serialize(lwline_as_lwgeom(lwline));
1378 
1379  PG_FREE_IF_COPY(ingeom, 0);
1380  lwline_free(lwline);
1381 
1382  PG_RETURN_POINTER(result);
1383 }
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:56
LWLINE * lwline_from_lwmpoint(int srid, LWMPOINT *mpoint)
Definition: lwline.c:260
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
#define MULTIPOINTTYPE
Definition: liblwgeom.h:63
void lwline_free(LWLINE *line)
Definition: lwline.c:63
char ** result
Definition: liblwgeom.h:218
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
Definition: lwgeom.c:249
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
LWMPOINT * lwgeom_as_lwmpoint(const LWGEOM *lwgeom)
Definition: lwgeom.c:152
int32_t srid
Definition: liblwgeom.h:423

Here is the call graph for this function: