Metadata-Version: 2.4
Name: digipin2
Version: 0.1.0
Summary: Python packaging of the India Post DIGIPIN reference algorithm.
Project-URL: Homepage, https://github.com/adarshnagrikar14/digipin-package
Project-URL: Repository, https://github.com/adarshnagrikar14/digipin-package
Project-URL: Issues, https://github.com/adarshnagrikar14/digipin-package/issues
Author: Adarsh Nagrikar
License-Expression: ISC
License-File: LICENSE
Keywords: digipin,geocode,india-post,latitude,longitude
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: ISC License (ISCL)
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
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
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Provides-Extra: build
Requires-Dist: build>=1.2; extra == 'build'
Requires-Dist: twine>=5.0; extra == 'build'
Provides-Extra: test
Requires-Dist: pytest>=8.0; extra == 'test'
Description-Content-Type: text/markdown

# digipin2

`digipin2` is an independent Python package for encoding and decoding DIGIPIN values using the open-source reference algorithm published by India Post.

This repository is a Python packaging and distribution project. It is not the official India Post repository and does not represent India Post. The upstream reference implementation is available at:

- https://github.com/INDIAPOST-gov/digipin

## What it provides

- Python library API for encoding and decoding
- Command-line interface for quick use from the terminal
- A packaged distribution that can be published to PyPI

## Installation

```bash
pip install digipin2
```

## Library usage

```python
from digipin2 import decode, encode

code = encode(21.034792, 79.029753)
print(code)

latitude, longitude = decode(code)
print(latitude, longitude)
```

Expected output:

```text
3PT-9CP-86JL
21.034777 79.029741
```

## CLI usage

Encode coordinates:

```bash
digipin2 encode --lat 21.034792 --lon 79.029753
```

Decode a DIGIPIN:

```bash
digipin2 decode 3PT-9CP-86JL
```

## API

### `encode(latitude, longitude) -> str`

Encodes a latitude/longitude pair into a formatted DIGIPIN string.

### `decode(digipin) -> tuple[float, float]`

Decodes a DIGIPIN into the center point of its resolved grid cell.

## Coordinate bounds

The reference implementation only accepts coordinates inside these bounds:

- Latitude: `2.5` to `38.5`
- Longitude: `63.5` to `99.5`

## Attribution

This package is based on the DIGIPIN reference algorithm published by India Post. It is maintained separately as a Python distribution so the algorithm can be installed with `pip`.

## Development

```bash
python -m venv .venv
.venv\Scripts\activate
pip install -e .[test]
pytest
python -m build
```
