landvex: Fixar och tester klara för alla komponenter
- Datafabrik: Dockerfile fix, agentorkestrering fungerar - Vision: Identify-modell, FAISS, OCR alla testade - API: Alla 7 integrationstester passerade - Upplösare: Entitetsupplösning verifierad
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
#!/usr/bin/env python3
|
||||
import requests
|
||||
import sqlite3
|
||||
from datetime import datetime
|
||||
|
||||
DB_PATH = "/home/bernt/.openclaw/workspace/rivp-pilot-1/rivp.db"
|
||||
|
||||
def fetch_roads():
|
||||
query = '[out:json];way["highway"~"motorway|trunk|primary|secondary"](59.8,17.4,60.1,17.8);out body;'
|
||||
|
||||
response = requests.post(
|
||||
"https://overpass-api.de/api/interpreter",
|
||||
data={"data": query},
|
||||
timeout=60
|
||||
)
|
||||
|
||||
if response.status_code == 200:
|
||||
data = response.json()
|
||||
roads = []
|
||||
for element in data.get("elements", []):
|
||||
if element.get("type") == "way":
|
||||
tags = element.get("tags", {})
|
||||
roads.append({
|
||||
"osm_id": element.get("id"),
|
||||
"name": tags.get("name", "Unknown"),
|
||||
"ref": tags.get("ref", ""),
|
||||
"highway": tags.get("highway", ""),
|
||||
"surface": tags.get("surface", "")
|
||||
})
|
||||
return roads
|
||||
return []
|
||||
|
||||
def save_to_db(roads):
|
||||
conn = sqlite3.connect(DB_PATH)
|
||||
c = conn.cursor()
|
||||
|
||||
c.execute('''
|
||||
CREATE TABLE IF NOT EXISTS osm_roads (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
osm_id INTEGER UNIQUE,
|
||||
name TEXT,
|
||||
ref TEXT,
|
||||
highway_type TEXT,
|
||||
surface TEXT,
|
||||
imported_date TEXT,
|
||||
source TEXT
|
||||
)
|
||||
''')
|
||||
|
||||
count = 0
|
||||
for road in roads:
|
||||
try:
|
||||
c.execute('''
|
||||
INSERT OR IGNORE INTO osm_roads
|
||||
(osm_id, name, ref, highway_type, surface, imported_date, source)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)
|
||||
''', (
|
||||
road["osm_id"],
|
||||
road["name"],
|
||||
road["ref"],
|
||||
road["highway"],
|
||||
road["surface"],
|
||||
datetime.now().isoformat(),
|
||||
"openstreetmap"
|
||||
))
|
||||
if c.rowcount > 0:
|
||||
count += 1
|
||||
except:
|
||||
pass
|
||||
|
||||
conn.commit()
|
||||
conn.close()
|
||||
return count
|
||||
|
||||
if __name__ == "__main__":
|
||||
roads = fetch_roads()
|
||||
print(f"Hittade {len(roads)} vägar")
|
||||
|
||||
for road in roads[:5]:
|
||||
print(f" {road['ref'] or 'N/A'}: {road['name']} ({road['highway']})")
|
||||
|
||||
saved = save_to_db(roads)
|
||||
print(f"Sparade {saved} nya vägar")
|
||||
Reference in New Issue
Block a user