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

Definition at line 1515 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(), POINTTYPE, and result.

1516 {
1517  GSERIALIZED *pglwg1, *pglwg2;
1518  GSERIALIZED *result=NULL;
1519  LWGEOM *lwgeoms[2];
1520  LWLINE *outline;
1521 
1522  POSTGIS_DEBUG(2, "LWGEOM_makeline called.");
1523 
1524  /* Get input datum */
1525  pglwg1 = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
1526  pglwg2 = (GSERIALIZED *)PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
1527 
1528  if ( (gserialized_get_type(pglwg1) != POINTTYPE && gserialized_get_type(pglwg1) != LINETYPE) ||
1529  (gserialized_get_type(pglwg2) != POINTTYPE && gserialized_get_type(pglwg2) != LINETYPE) )
1530  {
1531  elog(ERROR, "Input geometries must be points or lines");
1532  PG_RETURN_NULL();
1533  }
1534 
1536 
1537  lwgeoms[0] = lwgeom_from_gserialized(pglwg1);
1538  lwgeoms[1] = lwgeom_from_gserialized(pglwg2);
1539 
1540  outline = lwline_from_lwgeom_array(lwgeoms[0]->srid, 2, lwgeoms);
1541 
1542  result = geometry_serialize((LWGEOM *)outline);
1543 
1544  PG_FREE_IF_COPY(pglwg1, 0);
1545  PG_FREE_IF_COPY(pglwg2, 1);
1546  lwgeom_free(lwgeoms[0]);
1547  lwgeom_free(lwgeoms[1]);
1548 
1549  PG_RETURN_POINTER(result);
1550 }
#define LINETYPE
Definition: liblwgeom.h:61
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
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
void error_if_srid_mismatch(int srid1, int srid2)
Definition: lwutil.c:317
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1006
char ** result
Definition: liblwgeom.h:218
LWLINE * lwline_from_lwgeom_array(int srid, uint32_t ngeoms, LWGEOM **geoms)
Definition: lwline.c:152
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:60
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:70

Here is the call graph for this function: