- make (if not present,
apt install make
on Linux Debian orbrew install make
on Mac) - the current sources (python-test-sebastienhoarau)
A Makefile provides convenient shortcuts for most tasks.
Create a dedicated Python virtual environment, ie. with conda:
conda create -n geo-transformer python=3.9 pip
Activate the virtual environment:
conda activate geo-transformer
Install minimum requirements and package locally with:
make install
at the root of the project.
Change directory to geo_transformer
directory:
cd geo_transformer
then run:
python app.py data/test_points.txt.gz
to use the provided sample data and print output to the console.
You can also use any file respecting the same schema as the one provided, compressed in gzip format for the INPUT_FILE
argument.
List all available commands with:
python app.py --help
python-test-sebastienhoarau
├── LICENSE
├── Makefile
├── README.md # this file
├── geo_transformer # main package
│ ├── __init__.py
│ ├── app.py # application entrypoint
│ ├── data # sample application data
│ ├── io.py # input/output functions
│ ├── models.py # datas structures
│ ├── tests # tests
│ └── transformer.py # transformer functions (geohash encoding, unique prefix)
├── pyproject.toml
├── requirements-dev.in # dev requirements
├── requirements-dev.txt # compiled dev requirements with pip-compile
├── requirements.in # requirements
├── requirements.txt # compiled requirements with pip-compile
└── setup.py
Python source code is formatted with Black.
Similar to Setup, while at the root of the project, install development requirements and package locally with:
make install-dev
Tests can be run with:
make test
The console prints tests outputs as well as code coverage.
Benchmarks can be run with:
make benchmark
A standalone binary for your platform can be created with:
make standalone
And will be found as geo-transformer
in newly created dist
directory. The produced binary does not require any Python installation or dependencies and can be run just like in Usage with:
./geo-transformer <input file>
A downloadable version (ELF / Linux only) is available in the Releases
section.
The requirements files requirements.txt
and requirements-dev.txt
are generated with pip-compile
from pip-tools.
- update
requirements.in
andrequirements-dev.in
as needed - run
pip-compile requirements.in
andpip-compile requirements-dev.in
to update the compiled requirements.
Your task is to transform the set of longitude, latitude coordinates provided in the test_points.txt.gz
file
into corresponding GeoHash codes.
For each pair of coordinates only the shortest geohash prefix that uniquely identifies this point must be stored.
For instance, this 3 points dataset will store these unique prefixes:
latitude | longitude | geohash | unique_prefix |
---|---|---|---|
41.388828145321 | 2.1689976634898 | sp3e3qe7mkcb | sp3e3 |
41.390743 | 2.138067 | sp3e2wuys9dr | sp3e2wuy |
41.390853 | 2.138177 | sp3e2wuzpnhr | sp3e2wuz |
The solution must be coded in Python
and you can use any public domain libraries.
It should work with any file respecting the same schema as the one provided.
The executable must output the solution on stdout
in CSV format
with 4 columns following the structure of the example, ie:
lat,lng,geohash,uniq
41.388828145321,2.1689976634898,sp3e3qe7mkcb,sp3e3
41.390743,2.138067,sp3e2wuys9dr,sp3e2wuy
41.390853,2.138177,sp3e2wuzpnhr,sp3e2wuz
- Good software design
- Proper documentation
- Compliance to Python standards and modern usages (eg.: PEP8)
- Proper use of data structures
- Ergonomy of the command line interface
- Setup/Launch instructions if required