Add README.md and LICENSE

This commit is contained in:
Edward Betts 2023-10-10 10:08:15 +01:00
parent 4375b80d45
commit 6e9b2eb50e
2 changed files with 114 additions and 0 deletions

21
LICENSE Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 Edward Betts <edward@4angle.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

93
README.md Normal file
View file

@ -0,0 +1,93 @@
# Wikidata reverse geocoder
This project offers a reverse geocoding service that returns Wikidata and OpenStreetMap (OSM) information based on geographical coordinates within the UK and Ireland. It uses Python 3 and Flask for the web server, while SQLAlchemy provides database connectivity. This service can look up administrative divisions such as Scottish parishes, English counties, or city districts based on latitude and longitude.
## Overview
The main Python script `lookup.py` performs the following tasks:
- Initializes a Flask application and database
- Provides routes to various API endpoints
- Implements geocoding logic by querying OSM and Wikidata
The `geocode` package consists of:
- `database.py`: Initializes SQLAlchemy session and database engine
- `model.py`: SQLAlchemy model for the database schema
- `scotland.py`: Functions for handling Scottish parishes
## Dependencies
- Python 3.8+
- Flask
- SQLAlchemy
- psycopg2
- GeoAlchemy2
- lxml
## Installation
1. Clone the repository to your local machine.
2. Create a Python virtual environment and install the requirements.
3. Update the configuration settings in `config.default`.
4. Run the Flask application.
5. Set environment variables for database connectivity, if needed.
## Configuration
Create a file named `default.py` in the `config` directory and configure database parameters and other settings.
Example:
```python
# config.py
DB_URL = "postgresql://username:password@localhost/geocode_db"
```
## Usage
To start the server:
```bash
python lookup.py
```
The web server will start at `http://0.0.0.0:5000`.
## API Endpoints
### Home `/`
Renders the homepage where samples are displayed.
### Random Location `/random`
Displays random UK location details based on latitude and longitude.
### Wikidata Tag `/wikidata_tag`
Returns details based on a specific Wikidata tag.
### Detail Page `/detail`
Displays detail based on latitude and longitude coordinates.
## Database Schema
See `geocode/model.py` for the SQLAlchemy database schema definitions.
## Testing
For now, manual testing is the way to go. Automated tests are planned for future iterations of the project.
## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
## License
This project is licensed under the MIT License.
## Contact
If you have any queries or suggestions, feel free to contact the maintainer, Edward Betts, at edward@4angle.com.