PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ hexagon_grid_state()

static HexagonGridState* hexagon_grid_state ( double  size,
const GBOX gbox,
int32_t  srid 
)
static

Definition at line 108 of file lwgeom_generate_grid.c.

109 {
110  HexagonGridState *state = palloc0(sizeof(HexagonGridState));
111  double col_width = 1.5 * size;
112  double row_height = size * 2 * H;
113 
114  /* fill in state */
115  state->cell_shape = SHAPE_HEXAGON;
116  state->size = size;
117  state->srid = srid;
118  state->done = false;
119  state->bounds = *gbox;
120 
121  /* Column address is just width / column width, with an */
122  /* adjustment to account for partial overlaps */
123  state->column_min = floor(gbox->xmin / col_width);
124  if(gbox->xmin - state->column_min * col_width > size)
125  state->column_min++;
126 
127  state->column_max = ceil(gbox->xmax / col_width);
128  if(state->column_max * col_width - gbox->xmax > size)
129  state->column_max--;
130 
131  /* Row address range depends on the odd/even column we're on */
132  state->row_min_even = floor(gbox->ymin/row_height + 0.5);
133  state->row_max_even = floor(gbox->ymax/row_height + 0.5);
134  state->row_min_odd = floor(gbox->ymin/row_height);
135  state->row_max_odd = floor(gbox->ymax/row_height);
136 
137  /* Set initial state */
138  state->i = state->column_min;
139  state->j = (state->i % 2) ? state->row_min_odd : state->row_min_even;
140 
141  return state;
142 }
@ SHAPE_HEXAGON
#define H
double ymax
Definition: liblwgeom.h:357
double xmax
Definition: liblwgeom.h:355
double ymin
Definition: liblwgeom.h:356
double xmin
Definition: liblwgeom.h:354
GeometryShape cell_shape

References HexagonGridState::bounds, HexagonGridState::cell_shape, HexagonGridState::column_max, HexagonGridState::column_min, HexagonGridState::done, H, HexagonGridState::i, HexagonGridState::j, HexagonGridState::row_max_even, HexagonGridState::row_max_odd, HexagonGridState::row_min_even, HexagonGridState::row_min_odd, SHAPE_HEXAGON, HexagonGridState::size, HexagonGridState::srid, GBOX::xmax, GBOX::xmin, GBOX::ymax, and GBOX::ymin.

Referenced by ST_ShapeGrid().

Here is the caller graph for this function: