PostGIS  2.5.2dev-r@@SVN_REVISION@@

◆ LWGEOM_makeline()

Datum LWGEOM_makeline ( PG_FUNCTION_ARGS  )

Definition at line 1494 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(), LWGEOM_makepoly(), lwline_from_lwgeom_array(), genraster::outline, PG_FUNCTION_INFO_V1(), and POINTTYPE.

Referenced by LWGEOM_makeline_garray().

1495 {
1496  GSERIALIZED *pglwg1, *pglwg2;
1497  GSERIALIZED *result=NULL;
1498  LWGEOM *lwgeoms[2];
1499  LWLINE *outline;
1500 
1501  POSTGIS_DEBUG(2, "LWGEOM_makeline called.");
1502 
1503  /* Get input datum */
1504  pglwg1 = PG_GETARG_GSERIALIZED_P(0);
1505  pglwg2 = PG_GETARG_GSERIALIZED_P(1);
1506 
1507  if ( (gserialized_get_type(pglwg1) != POINTTYPE && gserialized_get_type(pglwg1) != LINETYPE) ||
1508  (gserialized_get_type(pglwg2) != POINTTYPE && gserialized_get_type(pglwg2) != LINETYPE) )
1509  {
1510  elog(ERROR, "Input geometries must be points or lines");
1511  PG_RETURN_NULL();
1512  }
1513 
1515 
1516  lwgeoms[0] = lwgeom_from_gserialized(pglwg1);
1517  lwgeoms[1] = lwgeom_from_gserialized(pglwg2);
1518 
1519  outline = lwline_from_lwgeom_array(lwgeoms[0]->srid, 2, lwgeoms);
1520 
1521  result = geometry_serialize((LWGEOM *)outline);
1522 
1523  PG_FREE_IF_COPY(pglwg1, 0);
1524  PG_FREE_IF_COPY(pglwg2, 1);
1525  lwgeom_free(lwgeoms[0]);
1526  lwgeom_free(lwgeoms[1]);
1527 
1528  PG_RETURN_POINTER(result);
1529 }
#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:1144
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:100
Here is the call graph for this function:
Here is the caller graph for this function: