Update tools/geographic_tools.py
Browse files- tools/geographic_tools.py +14 -1
tools/geographic_tools.py
CHANGED
|
@@ -347,8 +347,21 @@ async def list_villages(state: str, district: str = None):
|
|
| 347 |
async def reverse_geocode(location_name: str):
|
| 348 |
"""
|
| 349 |
Returns the coordinates for a given location name.
|
|
|
|
| 350 |
"""
|
| 351 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 352 |
|
| 353 |
async def get_administrative_bounds(village_id: str):
|
| 354 |
"""
|
|
|
|
| 347 |
async def reverse_geocode(location_name: str):
|
| 348 |
"""
|
| 349 |
Returns the coordinates for a given location name.
|
| 350 |
+
Handles case-insensitive matching and partial matches.
|
| 351 |
"""
|
| 352 |
+
# First try exact lowercase match
|
| 353 |
+
exact_match = locations.get(location_name.lower())
|
| 354 |
+
if exact_match:
|
| 355 |
+
return exact_match
|
| 356 |
+
|
| 357 |
+
# Try partial matching if exact match fails
|
| 358 |
+
location_lower = location_name.lower()
|
| 359 |
+
for key, coords in locations.items():
|
| 360 |
+
if location_lower in key or key in location_lower:
|
| 361 |
+
return coords
|
| 362 |
+
|
| 363 |
+
# If no match found
|
| 364 |
+
return {"error": "Location not found"}
|
| 365 |
|
| 366 |
async def get_administrative_bounds(village_id: str):
|
| 367 |
"""
|