This application is designed to process text input containing geographical information and return corresponding geocoded locations. The main functionality is powered by the Geocoder class, which utilizes NER models and OpenStreetMap (OSM) data for accurate address extraction and geocoding.
The application is built using FastAPI and exposes the following endpoints:
-
GET /- Description: Root endpoint providing a welcome message.
- Response:
{ "message": "Hello! Give me any text with geo subject and I will tell you where it is." }
-
GET /items- Description: Fetches a geocoded item's map visualization by its ID.
- Parameters:
item_id(int): ID of the item to fetch.
- Response:
- Returns an interactive map (HTML response) for the specified item.
- Error Handling:
- Returns a
404HTTP error if the item ID does not exist.
- Returns a
-
POST /items- Description: Processes the input text to extract geographical entities, geocodes them, and stores the result.
- Parameters:
text_ent(str): Input text containing geographical information.
- Response:
- Returns an interactive map (HTML response) of the geocoded location.
- Process Flow:
- The input text is wrapped in a DataFrame.
- The Geocoder class processes the text to extract geographical information using OSM data (defaulting to Saint Petersburg's OSM ID:
337422). - Geocoded results are appended to a global DataFrame (
data_df). - An interactive map with the geocoded results is returned.
- Interactive Maps: Uses the
exploremethod to provide interactive map visualizations. - Dynamic Data Storage: Stores geocoded entries in a global DataFrame for easy retrieval.
- Install dependencies using Poetry:
poetry install
- Start the application:
uvicorn main:app --host 0.0.0.0 --port 8000
- Build the Docker image:
docker build -t geocoder-app . - Run the Docker container:
docker run -p 8000:8000 geocoder-app
- Python 3.11.5
- Docker (if running in a containerized environment)
- Add a spellchecker for improved text input handling.
- Extend support for multiple languages and regions.
- Optimize map rendering for large datasets.
Developed with ❤️ by KhudyakovGleb.