mirror of
https://github.com/zvx-echo6/recon.git
synced 2026-05-20 06:34:40 +02:00
feat(navi): add netsyms tier-2 geocoding + geocode API
Add Netsyms AddressDatabase2025 (159M US+CA addresses) as tier-2
in the geocode chain: address_book → netsyms → photon.
- lib/netsyms.py: SQLite lookup module (lazy, read-only, thread-safe)
- lib/netsyms_api.py: Flask blueprints for /api/netsyms/* and /api/geocode
- lib/netsyms_test.py: 7 test cases (street, free-text, zipcode, health)
- lib/nav_tools.py: new geocode() with consistent {name,lat,lon,source,raw}
- lib/api.py: register netsyms_bp and geocode_bp
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
23483e8198
commit
dfab388769
5 changed files with 475 additions and 0 deletions
48
lib/netsyms_api.py
Normal file
48
lib/netsyms_api.py
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
"""
|
||||
RECON Netsyms API + Geocode chain — Flask Blueprints.
|
||||
|
||||
GET /api/netsyms/lookup?q=<free text>&country=<optional>
|
||||
GET /api/netsyms/health
|
||||
GET /api/geocode?q=<query> (full 3-tier chain: address_book → netsyms → photon)
|
||||
"""
|
||||
|
||||
from flask import Blueprint, request, jsonify
|
||||
|
||||
from . import netsyms
|
||||
from . import address_book
|
||||
from . import nav_tools
|
||||
from .utils import setup_logging
|
||||
|
||||
logger = setup_logging('recon.netsyms_api')
|
||||
|
||||
netsyms_bp = Blueprint('netsyms', __name__)
|
||||
geocode_bp = Blueprint('geocode', __name__)
|
||||
|
||||
|
||||
@netsyms_bp.route('/api/netsyms/lookup')
|
||||
def api_netsyms_lookup():
|
||||
q = request.args.get('q', '').strip()
|
||||
if not q:
|
||||
return jsonify({'error': 'Missing q parameter'}), 400
|
||||
|
||||
country = request.args.get('country', '').strip() or None
|
||||
results = netsyms.lookup_free_text(q, country_hint=country)
|
||||
return jsonify({'results': results, 'count': len(results), 'query': q})
|
||||
|
||||
|
||||
@netsyms_bp.route('/api/netsyms/health')
|
||||
def api_netsyms_health():
|
||||
return jsonify(netsyms.health())
|
||||
|
||||
|
||||
@geocode_bp.route('/api/geocode')
|
||||
def api_geocode():
|
||||
q = request.args.get('q', '').strip()
|
||||
if not q:
|
||||
return jsonify({'error': 'Missing q parameter'}), 400
|
||||
|
||||
result = nav_tools.geocode(q)
|
||||
if result is None:
|
||||
return jsonify({'error': 'No results', 'query': q}), 404
|
||||
|
||||
return jsonify(result)
|
||||
Loading…
Add table
Add a link
Reference in a new issue