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:
Bernt
2026-07-05 06:41:32 +00:00
parent f4f853d94b
commit aee0f09db8
19583 changed files with 1450867 additions and 1153 deletions
+83
View File
@@ -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")
+82
View File
@@ -0,0 +1,82 @@
#!/usr/bin/env python3
"""
Hämta väderdata från SMHI
"""
import requests
import sqlite3
from datetime import datetime
DB_PATH = "/home/bernt/.openclaw/workspace/rivp-pilot-1/rivp.db"
def fetch_temperature(station_id="97530"):
"""Hämta temperatur från SMHI"""
url = f"https://opendata-download-metobs.smhi.se/api/version/latest/parameter/1/station/{station_id}/period/latest-hour/data.json"
try:
response = requests.get(url, timeout=30)
if response.status_code == 200:
data = response.json()
values = data.get("value", [])
if values:
latest = values[-1]
return {
"station": data["station"]["name"],
"temperature": float(latest["value"]),
"timestamp": latest["date"]
}
except Exception as e:
print(f"Fel: {e}")
return None
def fetch_precipitation(station_id="97530"):
"""Hämta nederbörd från SMHI"""
url = f"https://opendata-download-metobs.smhi.se/api/version/latest/parameter/7/station/{station_id}/period/latest-day/data.json"
try:
response = requests.get(url, timeout=30)
if response.status_code == 200:
data = response.json()
values = data.get("value", [])
if values:
total = sum(float(v["value"]) for v in values if float(v["value"]) >= 0)
return {
"station": data["station"]["name"],
"precipitation_mm": total
}
except Exception as e:
print(f"Fel: {e}")
return None
def save_weather_observation(road_id, weather_type, value, severity, source="smhi_real"):
"""Spara väderobservation"""
conn = sqlite3.connect(DB_PATH)
c = conn.cursor()
c.execute('''
INSERT INTO observations
(road_id, observation_type, latitude, longitude, confidence, severity, detected_date, source)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
''', (
road_id,
weather_type,
59.85, # Uppsala lat
17.65, # Uppsala lon
0.95,
severity,
datetime.now().strftime('%Y-%m-%d'),
source
))
conn.commit()
conn.close()
if __name__ == "__main__":
temp = fetch_temperature()
precip = fetch_precipitation()
if temp:
print(f"Temperatur: {temp['temperature']}°C")
if precip:
print(f"Nederbörd: {precip['precipitation_mm']}mm")