mirror of
https://github.com/zvx-echo6/recon.git
synced 2026-05-20 06:34:40 +02:00
feat(navi): address book with geocoding integration
- YAML-backed saved locations (config/address_book.yaml) - Exact/partial alias matching with case-insensitive lookup - Flask blueprint: /api/address_book/lookup, /api/address_book/list - Geocoder short-circuits Photon when address book has exact match - Test suite for lookup behavior Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
3243f2f252
commit
23483e8198
6 changed files with 263 additions and 1 deletions
|
|
@ -3,6 +3,10 @@
|
|||
import re
|
||||
import requests
|
||||
|
||||
from .utils import setup_logging
|
||||
|
||||
logger = setup_logging('recon.nav_tools')
|
||||
|
||||
PHOTON_URL = "http://localhost:2322"
|
||||
VALHALLA_URL = "http://localhost:8002"
|
||||
|
||||
|
|
@ -20,11 +24,26 @@ def _parse_coords(text: str):
|
|||
|
||||
|
||||
def _geocode(query: str):
|
||||
"""Geocode a place name via Photon. Returns (lat, lon, display_name) or raises."""
|
||||
"""Geocode a place name via address book then Photon. Returns (lat, lon, display_name) or raises."""
|
||||
coords = _parse_coords(query)
|
||||
if coords:
|
||||
return coords[0], coords[1], query
|
||||
|
||||
# ── Address book lookup (before Photon) ──
|
||||
try:
|
||||
from . import address_book
|
||||
match = address_book.lookup(query)
|
||||
if match and match['confidence'] == 'exact' and match.get('lat') and match.get('lon'):
|
||||
logger.info("Address book exact match: %r → %s (%s, %s)",
|
||||
query, match['name'], match['lat'], match['lon'])
|
||||
return match['lat'], match['lon'], match.get('address') or match['name']
|
||||
elif match and match['confidence'] == 'partial':
|
||||
logger.info("Address book partial match: %r → %s (falling through to Photon)",
|
||||
query, match['name'])
|
||||
except Exception as e:
|
||||
logger.debug("Address book lookup failed: %s", e)
|
||||
|
||||
# ── Photon geocoding ──
|
||||
try:
|
||||
resp = requests.get(
|
||||
f"{PHOTON_URL}/api",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue