Timezone lookup using latitude and longitud (part 2)

fastapi test project.

For the fastapi project we are going to use Sqlalchemy and postgresql taking some reference from the fastapi documentation.

# create a virtualenv, with any tool: poetry, pipenv, virtualenv module, etc 
pip install fastapi uvicorn aiofiles SQLAlchemy psycopg2-binary

project structure

.
├── Dockerfile
├── LICENSE
├── main.py
├── README.md
├── requirements.txt
└── timezone_utils
    ├── database.py
    ├── __init__.py
    ├── models.py
    ├── schemas.py
    └── utils.py

1 directory, 10 files

we define the models, schemas and engine for sqlalchemy and the api in the package timezone_utils

[Read More]

Timezone lookup using latitude and longitude (part 1)

fastapi test project.

First timezones are evil, but sometimes you need to work with them. Sometimes is easy to consume some third party api to get timezone information based on a given location using geocoding but there also exists some alternatives.

Then inspired on this blog post and the project Timezone boundary builder decided to create a test project using fastapi and postgis to do the timezone lookup using the latitude and longitude.

The project timezone boundary builder provide in their releases a shapefile that can be imported into a postgresql database with postgis shp2pgsql tool

[Read More]