Metadata-Version: 2.4
Name: a5_fast
Version: 0.2.1
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: GIS
License-File: LICENSE
Summary: Fast Python bindings for the A5 discrete global grid system
Keywords: a5,dggs,geospatial,grid,spatial-index
Author: After Realism
License-Expression: MIT
Requires-Python: >=3.10
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Repository, https://github.com/afterrealism/a5_fast

# a5_fast

Fast Python bindings for the [A5 discrete global grid system](https://github.com/afterrealism/a5), powered by Rust and PyO3.

## Installation

```bash
pip install a5_fast
```

## Usage

```python
import a5_fast

# Convert (lon, lat) to a cell index at resolution 5
cell = a5_fast.lonlat_to_cell(13.4, 52.5, 5)

# Get the centre of a cell
lon, lat = a5_fast.cell_to_lonlat(cell)

# Get the boundary polygon of a cell
boundary = a5_fast.cell_to_boundary(cell)

# Batch convert coordinates (flat list: [lon0, lat0, lon1, lat1, ...])
cells = a5_fast.lonlat_to_cell_batch([13.4, 52.5, -73.9, 40.7], 5)

# Traverse the hierarchy
parent = a5_fast.cell_to_parent(cell)
children = a5_fast.cell_to_children(cell)

# Neighbours within k hops
disk = a5_fast.grid_disk(cell, 1)

# Compact / uncompact cell sets
compacted = a5_fast.compact(cells)
expanded = a5_fast.uncompact(compacted, 5)

# Hex conversion
hex_str = a5_fast.u64_to_hex(cell)
cell = a5_fast.hex_to_u64(hex_str)

# Metadata
res = a5_fast.get_resolution(cell)
area = a5_fast.cell_area(5)           # area in m² at resolution 5
n = a5_fast.get_num_cells(5)          # total cells at resolution 5
base = a5_fast.get_res0_cells()       # the 12 resolution-0 cells
```

## License

MIT

