PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ hexagon()

static LWGEOM * hexagon ( double  origin_x,
double  origin_y,
double  size,
int  cell_i,
int  cell_j,
int32_t  srid 
)
static

Definition at line 74 of file lwgeom_generate_grid.c.

75{
76 POINTARRAY **ppa = lwalloc(sizeof(POINTARRAY*));
77 POINTARRAY *pa = ptarray_construct(0, 0, 7);
78
79 for (uint32_t i = 0; i < 7; ++i)
80 {
81 double height = size * 2 * H;
82 POINT4D pt;
83 pt.x = origin_x + size * (1.5 * cell_i + hex_x[i]);
84 pt.y = origin_y + height * (cell_j + 0.5 * (abs(cell_i) % 2) + hex_y[i]);
85 ptarray_set_point4d(pa, i, &pt);
86 }
87
88 ppa[0] = pa;
89 return lwpoly_as_lwgeom(lwpoly_construct(srid, NULL, 1 /* nrings */, ppa));
90}
void * lwalloc(size_t size)
Definition lwutil.c:227
LWPOLY * lwpoly_construct(int32_t srid, GBOX *bbox, uint32_t nrings, POINTARRAY **points)
Definition lwpoly.c:43
void ptarray_set_point4d(POINTARRAY *pa, uint32_t n, const POINT4D *p4d)
Definition lwgeom_api.c:369
LWGEOM * lwpoly_as_lwgeom(const LWPOLY *obj)
Definition lwgeom.c:357
POINTARRAY * ptarray_construct(char hasz, char hasm, uint32_t npoints)
Construct an empty pointarray, allocating storage and setting the npoints, but not filling in any inf...
Definition ptarray.c:51
static const double hex_x[]
static const double hex_y[]
#define H
double x
Definition liblwgeom.h:414
double y
Definition liblwgeom.h:414

References H, hex_x, hex_y, lwalloc(), lwpoly_as_lwgeom(), lwpoly_construct(), ptarray_construct(), ptarray_set_point4d(), POINT4D::x, and POINT4D::y.

Referenced by ST_Hexagon(), and ST_ShapeGrid().

Here is the call graph for this function:
Here is the caller graph for this function: