Improve the dahboard with the weather info 2
This commit is contained in:
@@ -205,18 +205,30 @@ class MadridTrafficClient(BaseTrafficClient, BaseAPIClient):
|
||||
traffic_record, location_context
|
||||
)
|
||||
|
||||
# Build enhanced response
|
||||
# Calculate average speed based on congestion level
|
||||
if congestion_level == 'high':
|
||||
average_speed = 15.0
|
||||
elif congestion_level == 'medium':
|
||||
average_speed = 35.0
|
||||
elif congestion_level == 'low':
|
||||
average_speed = 50.0
|
||||
else:
|
||||
average_speed = 30.0 # default
|
||||
|
||||
# Build enhanced response with required API fields
|
||||
enhanced_data = {
|
||||
'date': datetime.now(timezone.utc), # Required API field
|
||||
'timestamp': datetime.now(timezone.utc),
|
||||
'latitude': traffic_point.get('latitude'),
|
||||
'longitude': traffic_point.get('longitude'),
|
||||
'measurement_point_id': traffic_point.get('measurement_point_id'),
|
||||
'measurement_point_name': traffic_point.get('measurement_point_name'),
|
||||
'traffic_volume': traffic_point.get('intensidad', 0),
|
||||
'pedestrian_count': pedestrian_count,
|
||||
'congestion_level': congestion_level,
|
||||
'average_speed': average_speed, # Required API field
|
||||
'occupation_percentage': int(traffic_point.get('ocupacion', 0)),
|
||||
'load_percentage': traffic_point.get('carga', 0),
|
||||
'congestion_level': congestion_level,
|
||||
'pedestrian_count': pedestrian_count,
|
||||
'road_type': road_type,
|
||||
'distance_km': distance_km,
|
||||
'source': 'madrid_current_xml',
|
||||
|
||||
Reference in New Issue
Block a user