35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
# app/routers/amenities.py
|
|
from fastapi import APIRouter, Query, HTTPException
|
|
from typing import Optional, List
|
|
|
|
from app.models.response import NearbyAmenitiesResponse
|
|
from app.services.berlin_data_service import BerlinDataService
|
|
|
|
router = APIRouter(prefix="/amenities", tags=["amenities"])
|
|
|
|
# Services
|
|
berlin_data = BerlinDataService()
|
|
|
|
@router.get("/near-location")
|
|
async def get_amenities_near_location(
|
|
lat: float = Query(..., description="Latitude"),
|
|
lng: float = Query(..., description="Longitude"),
|
|
radius: int = Query(500, ge=100, le=2000, description="Search radius in meters"),
|
|
types: Optional[List[str]] = Query(None, description="Amenity types to include"),
|
|
):
|
|
"""Get all amenities near a specific location."""
|
|
try:
|
|
amenities = await berlin_data.get_amenities_near_point(
|
|
lat, lng, radius, types
|
|
)
|
|
|
|
return NearbyAmenitiesResponse(
|
|
location={"lat": lat, "lng": lng},
|
|
radius=radius,
|
|
amenities={"all": amenities}, # Group by type in real implementation
|
|
summary=berlin_data.summarize_amenities(amenities)
|
|
)
|
|
|
|
except Exception as e:
|
|
raise HTTPException(status_code=500, detail=f"Amenity search failed: {str(e)}")
|