Resolve "Implement Lambda: check_limits"
Implemented all queries to get and put data is required:
- Retrieve street data:
- List of camera IDs covering that street
- ID of station covering that street
- Maximum traffic capacity of that street
- Air quality limit of that street
- Get car count predictions and emergency vehicle counts for cameras on that street
- Get air quality prediction for the station covering that street
- Store finally calculated information
Algorithms to calculate information:
- Traffic load is calculated by:
- Select the 3 cameras with the highest traffic counts
- Calculate relative load (considering the limit defined for the street)
- Total street load is mean of 3 calculated relative loads
- Emergency vehicles are considered to be active, when there is at least one emergency vehicle visible on any camera
- Air quality load is calculated as:
- Load = 0.0 -> best possible air quality
- Load = 1.0 -> air quality at defined limit for street
- Load > 1.0 -> air quality below limit for street
- Air quality ... the higher, the better, but always in range [0.0, 1.0]
- Air quality limit on same scale as air quality
Tested by manually creating entries in DynamoDB table:
Street:
- PK: baseEntity
- SK: street#street_1
- airQualityLimit: 0.7
- cameras: [ { "S" : "camera_1" }, { "S" : "camera_2" } ]
- station: station_1
- trafficCapacity: 42
Traffic count for camera 1:
- PK: camera#camera_1
- SK: trafficCount#1703157200
- carCountPrediction: 20
- emergencyVehicleCount: 2
Traffic count for camera 2:
- PK: camera#camera_2
- SK: trafficCount#1703157200
- carCountPrediction: 32
- emergencyVehicleCount: 1
Prediction for station 1:
- PK: station#station_1
- SK: prediction#1703157200
- airQuality: 0.65
Created item in DynamoDB:
- PK: street#street_1
- SK: info#1703157200
- airQualityLoad: 1.1666666666666665
- CORRECT -> limit for street is at 0.7, prediction is at 0.65, meaning that the air quality is BELOW the defined limit (and thereby too bad) -> air quality is "overloaded" and in further step mitigation measurements should take place
- emergencyVehiclesActive: true
- CORRECT -> on camera_1 there are 2 emergency vehicles, on camera_2 there is 1 emergency vehicle
- trafficLoad: 0.6190476190476191
- CORRECT -> limit for street is 42 vehicles, camera_1 predicts 20 vehicles (20/42 = 0.476), camera_2 predicts 32 vehicles (32/42 = 0.762), average for both values is 0.619
Closes #15 (closed)