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,125 @@
|
||||
import sqlite3
|
||||
import random
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
conn = sqlite3.connect('rivp.db')
|
||||
c = conn.cursor()
|
||||
|
||||
# Hämta alla vägar - kolla kolumnnamn först
|
||||
c.execute("PRAGMA table_info(roads)")
|
||||
columns = c.fetchall()
|
||||
print("Columns:", [col[1] for col in columns])
|
||||
|
||||
c.execute("SELECT id, name, length_km, bbox, type, county FROM roads")
|
||||
roads = c.fetchall()
|
||||
|
||||
print(f"Generating observations for {len(roads)} roads...")
|
||||
|
||||
observation_types = ['pothole', 'surface_damage', 'crack', 'construction', 'vegetation', 'flooding', 'ice_damage']
|
||||
severities = ['low', 'medium', 'high', 'critical']
|
||||
sources = ['satellite', 'quixzoom', 'manual', 'sensor']
|
||||
|
||||
observation_count = 0
|
||||
|
||||
for road in roads:
|
||||
road_id, name, length_km, bbox, road_type, county = road
|
||||
|
||||
# Antal observationer baserat på väglängd och typ
|
||||
if road_type == 'motorway':
|
||||
num_obs = int(length_km / 10) + random.randint(0, 3)
|
||||
else:
|
||||
num_obs = int(length_km / 15) + random.randint(0, 2)
|
||||
|
||||
for i in range(num_obs):
|
||||
# Generera koordinater inom bounding box
|
||||
bbox_parts = bbox.split(',')
|
||||
min_lon, min_lat, max_lon, max_lat = map(float, bbox_parts)
|
||||
|
||||
lat = random.uniform(min_lat, max_lat)
|
||||
lon = random.uniform(min_lon, max_lon)
|
||||
|
||||
# Observationstyp baserat på säsong
|
||||
month = random.randint(1, 12)
|
||||
if month in [11, 12, 1, 2, 3]:
|
||||
obs_type = random.choice(['pothole', 'ice_damage', 'surface_damage', 'crack'])
|
||||
elif month in [4, 5, 6]:
|
||||
obs_type = random.choice(['construction', 'pothole', 'surface_damage'])
|
||||
elif month in [7, 8]:
|
||||
obs_type = random.choice(['vegetation', 'construction', 'surface_damage'])
|
||||
else:
|
||||
obs_type = random.choice(['pothole', 'flooding', 'surface_damage', 'crack'])
|
||||
|
||||
# Konfidens baserat på källa
|
||||
source = random.choice(sources)
|
||||
if source == 'satellite':
|
||||
confidence = random.uniform(0.6, 0.9)
|
||||
elif source == 'quixzoom':
|
||||
confidence = random.uniform(0.75, 0.95)
|
||||
elif source == 'manual':
|
||||
confidence = random.uniform(0.85, 0.99)
|
||||
else:
|
||||
confidence = random.uniform(0.5, 0.8)
|
||||
|
||||
# Severity
|
||||
if obs_type in ['construction']:
|
||||
severity = random.choice(['medium', 'high'])
|
||||
elif obs_type in ['pothole', 'crack']:
|
||||
severity = random.choice(['low', 'medium', 'high'])
|
||||
elif obs_type in ['flooding', 'ice_damage']:
|
||||
severity = random.choice(['medium', 'high', 'critical'])
|
||||
else:
|
||||
severity = random.choice(['low', 'medium'])
|
||||
|
||||
# Storlek
|
||||
if obs_type == 'construction':
|
||||
size_m2 = random.uniform(500, 5000)
|
||||
elif obs_type == 'pothole':
|
||||
size_m2 = random.uniform(1, 20)
|
||||
elif obs_type == 'vegetation':
|
||||
size_m2 = random.uniform(50, 500)
|
||||
else:
|
||||
size_m2 = random.uniform(10, 200)
|
||||
|
||||
# Datum
|
||||
day = random.randint(1, 28)
|
||||
detected_date = f"2026-{month:02d}-{day:02d}"
|
||||
|
||||
# Verifierad?
|
||||
verified = 1 if confidence > 0.8 else 0
|
||||
|
||||
c.execute('''
|
||||
INSERT INTO observations
|
||||
(road_id, observation_type, latitude, longitude, confidence, severity, size_m2, detected_date, verified, source)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
''', (road_id, obs_type, lat, lon, confidence, severity, size_m2, detected_date, verified, source))
|
||||
|
||||
observation_count += 1
|
||||
|
||||
conn.commit()
|
||||
|
||||
# Räkna totala
|
||||
conn = sqlite3.connect('rivp.db')
|
||||
c = conn.cursor()
|
||||
c.execute("SELECT COUNT(*) FROM observations")
|
||||
total = c.fetchone()[0]
|
||||
print(f"Total observations in database: {total}")
|
||||
|
||||
# Visa fördelning
|
||||
c.execute("SELECT observation_type, COUNT(*) FROM observations GROUP BY observation_type")
|
||||
print("\nBy type:")
|
||||
for row in c.fetchall():
|
||||
print(f" {row[0]}: {row[1]}")
|
||||
|
||||
c.execute("SELECT source, COUNT(*) FROM observations GROUP BY source")
|
||||
print("\nBy source:")
|
||||
for row in c.fetchall():
|
||||
print(f" {row[0]}: {row[1]}")
|
||||
|
||||
c.execute("SELECT severity, COUNT(*) FROM observations GROUP BY severity")
|
||||
print("\nBy severity:")
|
||||
for row in c.fetchall():
|
||||
print(f" {row[0]}: {row[1]}")
|
||||
|
||||
conn.close()
|
||||
|
||||
print(f"\nGenerated {observation_count} new observations")
|
||||
Reference in New Issue
Block a user