PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ LWGEOM_makeline()

Datum LWGEOM_makeline ( PG_FUNCTION_ARGS  )

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

1491 {
1492  GSERIALIZED *pglwg1, *pglwg2;
1493  GSERIALIZED *result=NULL;
1494  LWGEOM *lwgeoms[2];
1495  LWLINE *outline;
1496 
1497  POSTGIS_DEBUG(2, "LWGEOM_makeline called.");
1498 
1499  /* Get input datum */
1500  pglwg1 = PG_GETARG_GSERIALIZED_P(0);
1501  pglwg2 = PG_GETARG_GSERIALIZED_P(1);
1502 
1503  if ( (gserialized_get_type(pglwg1) != POINTTYPE && gserialized_get_type(pglwg1) != LINETYPE) ||
1504  (gserialized_get_type(pglwg2) != POINTTYPE && gserialized_get_type(pglwg2) != LINETYPE) )
1505  {
1506  elog(ERROR, "Input geometries must be points or lines");
1507  PG_RETURN_NULL();
1508  }
1509 
1511 
1512  lwgeoms[0] = lwgeom_from_gserialized(pglwg1);
1513  lwgeoms[1] = lwgeom_from_gserialized(pglwg2);
1514 
1515  outline = lwline_from_lwgeom_array(lwgeoms[0]->srid, 2, lwgeoms);
1516 
1517  result = geometry_serialize((LWGEOM *)outline);
1518 
1519  PG_FREE_IF_COPY(pglwg1, 0);
1520  PG_FREE_IF_COPY(pglwg2, 1);
1521  lwgeom_free(lwgeoms[0]);
1522  lwgeom_free(lwgeoms[1]);
1523 
1524  PG_RETURN_POINTER(result);
1525 }
#define LINETYPE
Definition: liblwgeom.h:86
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:1099
void error_if_srid_mismatch(int srid1, int srid2)
Definition: lwutil.c:371
LWLINE * lwline_from_lwgeom_array(int srid, uint32_t ngeoms, LWGEOM **geoms)
Definition: lwline.c:166
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
#define POINTTYPE
LWTYPE numbers, used internally by PostGIS.
Definition: liblwgeom.h:85
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: