PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ ST_Hexagon()

Datum ST_Hexagon ( PG_FUNCTION_ARGS  )

Definition at line 349 of file lwgeom_generate_grid.c.

350 {
351  LWPOINT *lwpt;
352  double size = PG_GETARG_FLOAT8(0);
353  GSERIALIZED *ghex;
354  int cell_i = PG_GETARG_INT32(1);
355  int cell_j = PG_GETARG_INT32(2);
356  GSERIALIZED *gorigin = PG_GETARG_GSERIALIZED_P(3);
357  LWGEOM *lwhex;
358  LWGEOM *lworigin = lwgeom_from_gserialized(gorigin);
359 
360  if (lwgeom_is_empty(lworigin))
361  {
362  elog(ERROR, "%s: origin point is empty", __func__);
363  PG_RETURN_NULL();
364  }
365 
366  lwpt = lwgeom_as_lwpoint(lworigin);
367  if (!lwpt)
368  {
369  elog(ERROR, "%s: origin argument is not a point", __func__);
370  PG_RETURN_NULL();
371  }
372 
373  lwhex = hexagon(lwpoint_get_x(lwpt), lwpoint_get_y(lwpt),
374  size, cell_i, cell_j,
375  lwgeom_get_srid(lworigin));
376 
377  ghex = geometry_serialize(lwhex);
378  PG_FREE_IF_COPY(gorigin, 3);
379  PG_RETURN_POINTER(ghex);
380 }
LWGEOM * lwgeom_from_gserialized(const GSERIALIZED *g)
Allocate a new LWGEOM from a GSERIALIZED.
Definition: gserialized.c:239
int32_t lwgeom_get_srid(const LWGEOM *geom)
Return SRID number.
Definition: lwgeom.c:927
double lwpoint_get_x(const LWPOINT *point)
Definition: lwpoint.c:63
double lwpoint_get_y(const LWPOINT *point)
Definition: lwpoint.c:76
static LWGEOM * hexagon(double origin_x, double origin_y, double size, int cell_i, int cell_j, int32_t srid)
static int lwgeom_is_empty(const LWGEOM *geom)
Return true or false depending on whether a geometry is an "empty" geometry (no vertices members)
Definition: lwinline.h:203
static LWPOINT * lwgeom_as_lwpoint(const LWGEOM *lwgeom)
Definition: lwinline.h:131

References hexagon(), lwgeom_as_lwpoint(), lwgeom_from_gserialized(), lwgeom_get_srid(), lwgeom_is_empty(), lwpoint_get_x(), and lwpoint_get_y().

Here is the call graph for this function: