hotosm/pg-nearest-city — reverse-engineered prompt
Reverse engineered prompt
Build me a small Python package that can take a longitude and latitude and return the nearest city and country using an existing PostgreSQL database with PostGIS.
It should work well inside web APIs where the app already has a database connection, but also allow creating a connection from config or environment variables. Please support both normal Python use and async use. The main user experience should be simple, something like opening a geocoder, calling query with lon and lat, and getting back an object with city and country.
Include a command line tool that can prepare the database by downloading GeoNames cities data plus country boundary data from GADM or Natural Earth, cleaning it up, loading it into PostGIS, simplifying the shapes, and exporting compressed files for reuse. Keep it lightweight and fast, with minimal memory use.
Add tests, Docker setup for running PostGIS locally, and basic docs with install and usage examples. Look up current docs online if you need to.
Want more depth? Deep Reverse