% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/grid.R
\name{a5_grid}
\alias{a5_grid}
\title{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}}
\usage{
a5_grid(x, resolution)
}
\arguments{
\item{x}{An area specification. One of:
\itemize{
\item A numeric vector of length 4 (\code{c(xmin, ymin, xmax, ymax)}) interpreted
as a WGS 84 bounding box.
\item Any geometry handleable by \code{\link[wk:wk_handle]{wk::wk_handle()}} (e.g. \code{\link[wk:wkt]{wk::wkt()}},
\code{\link[wk:wkb]{wk::wkb()}}, \code{sfc}, \code{sf}, \link{a5_cell}).
}}

\item{resolution}{Integer scalar target resolution (0--30).}
}
\value{
An \link{a5_cell} vector of cells at \code{resolution} that intersect \code{x}.
}
\description{
Generate a grid of A5 cells covering an area
}
\details{
Returns all cells at the target resolution that intersect the given
geometry. Uses hierarchical flood-fill: starting from the 12 resolution-0
root cells, the algorithm repeatedly expands and prunes by spatial
intersection until the target resolution is reached.

Grid generation runs entirely in Rust via hierarchical flood-fill with
bounding-box pruning. For non-bbox geometry inputs, an exact intersection
filter removes cells that fall outside the target shape. No cell count
limit is imposed — high resolutions over large areas can consume
significant memory.

Input geometries must use WGS 84 coordinates; projected geometries are
not reprojected and will produce incorrect results. Multiple geometries
are collected into a GEOMETRYCOLLECTION automatically.
Antimeridian-crossing bounding boxes are supported: when \code{xmin > xmax}
(e.g. \code{c(170, -50, -170, -30)}), the bbox is split at the antimeridian.

\strong{Limitation:} spatial filtering uses planar geometry on lon/lat
coordinates, which can produce incomplete results very close to the poles
(above ~88° latitude) or the antimeridian. Use a larger target geometry
to ensure complete coverage in these areas.
}
\examples{
# Grid from a bounding box
cells <- a5_grid(c(-3.3, 55.9, -3.1, 56.0), resolution = 5)
cells

# Grid from a WKT polygon
poly <- wk::wkt("POLYGON ((-3.3 55.9, -3.1 55.9, -3.1 56, -3.3 56, -3.3 55.9))")
cells <- a5_grid(poly, resolution = 5)
}
\seealso{
\code{\link[=a5_cell_to_boundary]{a5_cell_to_boundary()}} to convert result cells to geometries.
}
