A FastAPI-based service that analyzes street accessibility using OpenStreetMap data. The system calculates accessibility scores for wheelchair users and their companions based on various street features.
- Accessibility Scoring: Calculates two scores:
singular_rate: Accessibility score for wheelchair users aloneaccompany_rate: Accessibility score for wheelchair users with companionsreason: The reason of the lowering of the score, this will allow the final user for further considerations on the route.
- Comprehensive Analysis: Evaluates multiple factors:
- Street incline (slope)
- Path width
- Surface type and quality
- Presence of barriers and steps
- Sidewalk availability
- Curb types
Calculates accessibility scores for a given location.
Request Body:
{
"latitude": 41.8986,
"longitude": 12.4769,
"other_user_details": "user cannot go on stairs"
}Response:
{
"singular_rate": 0,
"accompany_rate": 0,
"reason": "Stairs"
}Score Interpretation:
1.0: Perfect accessibility0.0: Complete barrier (impassable)- Values between: Relative accessibility (higher = better)
-
extract_data.py: Fetches OSM data for a given location- Queries OpenStreetMap Overpass API
- Extracts relevant accessibility features
- Returns structured JSON data
-
calculate_rate.py: Core scoring algorithm- Implements accessibility rules and scoring logic
- Returns Pydantic model with both scores
- Handles edge cases and blocking conditions
-
endpoint.py: FastAPI server- REST API endpoint for accessibility analysis
- Input validation using Pydantic models
- Error handling and response formatting
-
test.py: Test client- Simple script to test the API
- Error handling for connection issues
Client → FastAPI → extract_data.py → OSM API
↓
calculate_rate.py → Scoring Logic
↓
FastAPI → JSON Response
-
Clone the repository:
git clone https://github.com/yourusername/handicapai.git cd handicapai -
Install dependencies:
pip install -r requirements.txt
-
Run the server:
uvicorn endpoint:app --reload
-
Test the API:
python test.py
curl -X POST http://127.0.0.1:8000/calculate_accessibility_rate \
-H "Content-Type: application/json" \
-d '{"latitude": 41.8986, "longitude": 12.4769}'import requests
response = requests.post(
"http://127.0.0.1:8000/calculate_accessibility_rate",
json={"latitude": 41.8986, "longitude": 12.4769}
)
result = response.json()
print(f"Wheelchair accessibility: {result['singular_rate']}")
print(f"With companion: {result['accompany_rate']}")- Presence of steps
- Physical barriers
- Missing sidewalks
- Sand/unpaved surfaces
- Very bad surface quality
- Raised curbs
- Incline > 3%
- Width < 0.9m
- Incline: Linear scoring based on slope percentage
- Width: Different thresholds for solo vs. accompanied travel
- Surface: Quality-based scoring (asphalt = 1.0, sand = 0.0)
- Smoothness: Surface regularity scoring