PostGIS  3.0.0dev-r@@SVN_REVISION@@

◆ LWGEOM_makeline()

Datum LWGEOM_makeline ( PG_FUNCTION_ARGS  )

Definition at line 1493 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().

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