PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ LWGEOM_line_from_mpoint()

Datum LWGEOM_line_from_mpoint ( PG_FUNCTION_ARGS  )

Definition at line 1413 of file lwgeom_functions_basic.c.

1414 {
1415  GSERIALIZED *ingeom, *result;
1416  LWLINE *lwline;
1417  LWMPOINT *mpoint;
1418 
1419  POSTGIS_DEBUG(2, "LWGEOM_line_from_mpoint called");
1420 
1421  /* Get input GSERIALIZED and deserialize it */
1422  ingeom = PG_GETARG_GSERIALIZED_P(0);
1423 
1424  if (gserialized_get_type(ingeom) != MULTIPOINTTYPE)
1425  {
1426  elog(ERROR, "makeline: input must be a multipoint");
1427  PG_RETURN_NULL(); /* input is not a multipoint */
1428  }
1429 
1430  mpoint = lwgeom_as_lwmpoint(lwgeom_from_gserialized(ingeom));
1431  lwline = lwline_from_lwmpoint(mpoint->srid, mpoint);
1432  if (!lwline)
1433  {
1434  PG_FREE_IF_COPY(ingeom, 0);
1435  elog(ERROR, "makeline: lwline_from_lwmpoint returned NULL");
1436  PG_RETURN_NULL();
1437  }
1438 
1439  result = geometry_serialize(lwline_as_lwgeom(lwline));
1440 
1441  PG_FREE_IF_COPY(ingeom, 0);
1442  lwline_free(lwline);
1443 
1444  PG_RETURN_POINTER(result);
1445 }
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition: cu_print.c:262
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:239
uint32_t gserialized_get_type(const GSERIALIZED *g)
Extract the geometry type from the serialized form (it hides in the anonymous data area,...
Definition: gserialized.c:89
LWGEOM * lwline_as_lwgeom(const LWLINE *obj)
Definition: lwgeom.c:339
LWMPOINT * lwgeom_as_lwmpoint(const LWGEOM *lwgeom)
Definition: lwgeom.c:242
#define MULTIPOINTTYPE
Definition: liblwgeom.h:105
LWLINE * lwline_from_lwmpoint(int32_t srid, const LWMPOINT *mpoint)
Definition: lwline.c:275
void lwline_free(LWLINE *line)
Definition: lwline.c:67
int32_t srid
Definition: liblwgeom.h:534

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

Here is the call graph for this function: