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

Definition at line 1443 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.

1444 {
1445  GSERIALIZED *pglwg1, *pglwg2;
1446  GSERIALIZED *result=NULL;
1447  LWGEOM *lwgeoms[2];
1448  LWLINE *outline;
1449 
1450  POSTGIS_DEBUG(2, "LWGEOM_makeline called.");
1451 
1452  /* Get input datum */
1453  pglwg1 = PG_GETARG_GSERIALIZED_P(0);
1454  pglwg2 = PG_GETARG_GSERIALIZED_P(1);
1455 
1456  if ( (gserialized_get_type(pglwg1) != POINTTYPE && gserialized_get_type(pglwg1) != LINETYPE) ||
1457  (gserialized_get_type(pglwg2) != POINTTYPE && gserialized_get_type(pglwg2) != LINETYPE) )
1458  {
1459  elog(ERROR, "Input geometries must be points or lines");
1460  PG_RETURN_NULL();
1461  }
1462 
1464 
1465  lwgeoms[0] = lwgeom_from_gserialized(pglwg1);
1466  lwgeoms[1] = lwgeom_from_gserialized(pglwg2);
1467 
1468  outline = lwline_from_lwgeom_array(lwgeoms[0]->srid, 2, lwgeoms);
1469 
1470  result = geometry_serialize((LWGEOM *)outline);
1471 
1472  PG_FREE_IF_COPY(pglwg1, 0);
1473  PG_FREE_IF_COPY(pglwg2, 1);
1474  lwgeom_free(lwgeoms[0]);
1475  lwgeom_free(lwgeoms[1]);
1476 
1477  PG_RETURN_POINTER(result);
1478 }
#define LINETYPE
Definition: liblwgeom.h:71
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.
void lwgeom_free(LWGEOM *geom)
Definition: lwgeom.c:1050
void error_if_srid_mismatch(int srid1, int srid2)
Definition: lwutil.c:341
LWLINE * lwline_from_lwgeom_array(int srid, uint32_t ngeoms, LWGEOM **geoms)
Definition: lwline.c:153
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:70
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:69

Here is the call graph for this function: