PostGIS  2.5.0dev-r@@SVN_REVISION@@
Datum LWGEOM_makeline ( PG_FUNCTION_ARGS  )

Definition at line 1491 of file lwgeom_functions_basic.c.

References error_if_srid_mismatch(), geometry_serialize(), gserialized_get_srid(), gserialized_get_type(), LINETYPE, lwgeom_free(), lwgeom_from_gserialized(), lwline_from_lwgeom_array(), and POINTTYPE.

1492 {
1493  GSERIALIZED *pglwg1, *pglwg2;
1494  GSERIALIZED *result=NULL;
1495  LWGEOM *lwgeoms[2];
1496  LWLINE *outline;
1497 
1498  POSTGIS_DEBUG(2, "LWGEOM_makeline called.");
1499 
1500  /* Get input datum */
1501  pglwg1 = PG_GETARG_GSERIALIZED_P(0);
1502  pglwg2 = PG_GETARG_GSERIALIZED_P(1);
1503 
1504  if ( (gserialized_get_type(pglwg1) != POINTTYPE && gserialized_get_type(pglwg1) != LINETYPE) ||
1505  (gserialized_get_type(pglwg2) != POINTTYPE && gserialized_get_type(pglwg2) != LINETYPE) )
1506  {
1507  elog(ERROR, "Input geometries must be points or lines");
1508  PG_RETURN_NULL();
1509  }
1510 
1512 
1513  lwgeoms[0] = lwgeom_from_gserialized(pglwg1);
1514  lwgeoms[1] = lwgeom_from_gserialized(pglwg2);
1515 
1516  outline = lwline_from_lwgeom_array(lwgeoms[0]->srid, 2, lwgeoms);
1517 
1518  result = geometry_serialize((LWGEOM *)outline);
1519 
1520  PG_FREE_IF_COPY(pglwg1, 0);
1521  PG_FREE_IF_COPY(pglwg2, 1);
1522  lwgeom_free(lwgeoms[0]);
1523  lwgeom_free(lwgeoms[1]);
1524 
1525  PG_RETURN_POINTER(result);
1526 }
#define LINETYPE
Definition: liblwgeom.h:85
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
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1137
void error_if_srid_mismatch(int srid1, int srid2)
Definition: lwutil.c:338
LWLINE * lwline_from_lwgeom_array(int srid, uint32_t ngeoms, LWGEOM **geoms)
Definition: lwline.c:160
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:84
int32_t gserialized_get_srid(const GSERIALIZED *s)
Extract the SRID from the serialized form (it is packed into three bytes so this is a handy function)...
Definition: g_serialized.c:99

Here is the call graph for this function: