Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Traffic Simulation DSS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
URBANITE
Open
Traffic Simulation DSS
Commits
6164e046
Commit
6164e046
authored
1 year ago
by
Smerkol, Maj
Browse files
Options
Downloads
Patches
Plain Diff
adds noise pollution KPI
parent
999f3fa6
Branches
master
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/api/geojsons.py
+30
-28
30 additions, 28 deletions
app/api/geojsons.py
with
30 additions
and
28 deletions
app/api/geojsons.py
+
30
−
28
View file @
6164e046
...
@@ -41,13 +41,14 @@ def geojsontest(sim_id):
...
@@ -41,13 +41,14 @@ def geojsontest(sim_id):
app
.
logger
.
debug
(
"
done in %s s
"
,
delta_t
)
app
.
logger
.
debug
(
"
done in %s s
"
,
delta_t
)
app
.
logger
.
debug
(
"
starting write geojson pedestrian trips
"
)
app
.
logger
.
debug
(
"
starting write geojson pedestrian trips
"
)
start_t
=
time
.
time
()
start_t
=
time
.
time
()
pedestrianTravelTime
=
write_geojson_pedestrian_trips
(
pedestrianTravelTime
,
network
,
sim_id
)
pedestrianTravelTime
=
write_geojson_pedestrian_trips
(
pedestrianTravelTime
,
network
,
sim_id
)
delta_t
=
time
.
time
()
-
start_t
delta_t
=
time
.
time
()
-
start_t
app
.
logger
.
info
(
"
written pedestrianTravelTime in %s s
"
,
delta_t
)
app
.
logger
.
info
(
"
written pedestrianTravelTime in %s s
"
,
delta_t
)
return
pedestrianTravelTime
return
pedestrianTravelTime
@app.route
(
"
/dss/geojson/<int:sim_id>/<kpi_name>
"
)
@app.route
(
"
/dss/geojson/<int:sim_id>/<kpi_name>
"
)
def
get_kpi_geojson
(
sim_id
,
kpi_name
):
def
get_kpi_geojson
(
sim_id
,
kpi_name
):
sim_dir
=
utils
.
get_sim_dir_names
([
sim_id
])[
0
]
sim_dir
=
utils
.
get_sim_dir_names
([
sim_id
])[
0
]
...
@@ -82,6 +83,10 @@ def get_kpi_vis_info():
...
@@ -82,6 +83,10 @@ def get_kpi_vis_info():
"
buttonLabel
"
:
"
Pedestrian Travel Time
"
,
"
buttonLabel
"
:
"
Pedestrian Travel Time
"
,
},
},
{
"
buttonValue
"
:
"
dailyInternalTravels
"
,
"
buttonLabel
"
:
"
Internal Trips
"
},
{
"
buttonValue
"
:
"
dailyInternalTravels
"
,
"
buttonLabel
"
:
"
Internal Trips
"
},
{
"
buttonValue
"
:
"
noisePollution
"
,
"
buttonLabel
"
:
"
Noise Pollution
"
,
},
]
]
elif
city
==
"
amsterdam
"
:
elif
city
==
"
amsterdam
"
:
kpi_info
=
[
kpi_info
=
[
...
@@ -94,10 +99,6 @@ def get_kpi_vis_info():
...
@@ -94,10 +99,6 @@ def get_kpi_vis_info():
elif
city
==
"
helsinki
"
:
elif
city
==
"
helsinki
"
:
kpi_info
=
[
kpi_info
=
[
{
"
buttonValue
"
:
"
pollution
"
,
"
buttonLabel
"
:
"
Pollution
"
},
{
"
buttonValue
"
:
"
pollution
"
,
"
buttonLabel
"
:
"
Pollution
"
},
{
"
buttonValue
"
:
"
accousticPollution
"
,
"
buttonLabel
"
:
"
Acoustic Pollution - WIP
"
,
},
{
{
"
buttonValue
"
:
"
congestionsAndBottlenecks
"
,
"
buttonValue
"
:
"
congestionsAndBottlenecks
"
,
"
buttonLabel
"
:
"
Congestions and Bottlenecks
"
,
"
buttonLabel
"
:
"
Congestions and Bottlenecks
"
,
...
@@ -126,7 +127,7 @@ def get_kpi_vis_info():
...
@@ -126,7 +127,7 @@ def get_kpi_vis_info():
{
{
"
buttonValue
"
:
"
dailyInternalTravels
"
,
"
buttonValue
"
:
"
dailyInternalTravels
"
,
"
buttonLabel
"
:
"
Daily Internal Trips
"
,
"
buttonLabel
"
:
"
Daily Internal Trips
"
,
}
}
,
]
]
else
:
else
:
raise
ValueError
(
"
Invalid deploy parameters - city set to %s
"
,
city
)
raise
ValueError
(
"
Invalid deploy parameters - city set to %s
"
,
city
)
...
@@ -157,7 +158,9 @@ def get_kpi_data_and_write(network, events, sim_id):
...
@@ -157,7 +158,9 @@ def get_kpi_data_and_write(network, events, sim_id):
dailyInternalTravels
=
events
.
vehicles_count_per_link
()
dailyInternalTravels
=
events
.
vehicles_count_per_link
()
app
.
logger
.
info
(
"
Vehicles count per link
"
)
app
.
logger
.
info
(
"
Vehicles count per link
"
)
write_geojson_links
(
dailyInternalTravels
,
"
dailyInternalTravels
"
,
network
,
sim_id
)
write_geojson_links
(
dailyInternalTravels
,
"
dailyInternalTravels
"
,
network
,
sim_id
)
app
.
logger
.
info
(
"
written dailyInternalTravels
"
)
app
.
logger
.
info
(
"
written dailyInternalTravels
"
)
elif
network
.
city
==
"
helsinki
"
:
elif
network
.
city
==
"
helsinki
"
:
...
@@ -172,7 +175,9 @@ def get_kpi_data_and_write(network, events, sim_id):
...
@@ -172,7 +175,9 @@ def get_kpi_data_and_write(network, events, sim_id):
# write_geojson(pollution, "pollution", network, sim_id)
# write_geojson(pollution, "pollution", network, sim_id)
# app.logger.info("written emission")
# app.logger.info("written emission")
congestionsAndBottlenecks
=
events
.
get_congested_links
(
rush_hour
)[
"
congested_links
"
]
congestionsAndBottlenecks
=
events
.
get_congested_links
(
rush_hour
)[
"
congested_links
"
]
app
.
logger
.
info
(
"
congestions and bottlenecks
"
)
app
.
logger
.
info
(
"
congestions and bottlenecks
"
)
write_geojson_links
(
write_geojson_links
(
congestionsAndBottlenecks
,
"
congestionsAndBottlenecks
"
,
network
,
sim_id
congestionsAndBottlenecks
,
"
congestionsAndBottlenecks
"
,
network
,
sim_id
...
@@ -183,20 +188,18 @@ def get_kpi_data_and_write(network, events, sim_id):
...
@@ -183,20 +188,18 @@ def get_kpi_data_and_write(network, events, sim_id):
app
.
logger
.
info
(
"
harbour area traffic flow - TODO
"
)
app
.
logger
.
info
(
"
harbour area traffic flow - TODO
"
)
elif
network
.
city
==
"
messina
"
:
elif
network
.
city
==
"
messina
"
:
if
emisson_object
is
not
None
:
if
emisson_object
is
not
None
:
pollution
=
emisson_object
.
total_emissions_by_link
()
pollution
=
emisson_object
.
total_emissions_by_link
()
app
.
logger
.
info
(
"
Emission by link
"
)
app
.
logger
.
info
(
"
Emission by link
"
)
write_geojson_links
(
pollution
,
"
pollution
"
,
network
,
sim_id
)
write_geojson_links
(
pollution
,
"
pollution
"
,
network
,
sim_id
)
app
.
logger
.
info
(
"
written emission
"
)
app
.
logger
.
info
(
"
written emission
"
)
publicTransportUse
=
events
.
public_transport_use_geojson
()
publicTransportUse
=
events
.
public_transport_use_geojson
()
app
.
logger
.
info
(
"
public transport use
"
)
app
.
logger
.
info
(
"
public transport use
"
)
write_geojson_links
(
publicTransportUse
,
"
publicTransportUse
"
,
network
,
sim_id
)
write_geojson_links
(
publicTransportUse
,
"
publicTransportUse
"
,
network
,
sim_id
)
app
.
logger
.
info
(
"
written public transport use
"
)
app
.
logger
.
info
(
"
written public transport use
"
)
averageSpeedOfPublicTransport
=
events
.
average_bus_speed_geojson
()
averageSpeedOfPublicTransport
=
events
.
average_bus_speed_geojson
()
app
.
logger
.
info
(
"
average speed of public transport
"
)
app
.
logger
.
info
(
"
average speed of public transport
"
)
write_geojson_links
(
write_geojson_links
(
...
@@ -206,7 +209,6 @@ def get_kpi_data_and_write(network, events, sim_id):
...
@@ -206,7 +209,6 @@ def get_kpi_data_and_write(network, events, sim_id):
sim_id
,
sim_id
,
)
)
app
.
logger
.
info
(
"
written averageSpeedOfPublicTransport
"
)
app
.
logger
.
info
(
"
written averageSpeedOfPublicTransport
"
)
numberOfBikeTrips
=
events
.
vehicles_count_per_link
(
only
=
"
bike
"
)
numberOfBikeTrips
=
events
.
vehicles_count_per_link
(
only
=
"
bike
"
)
app
.
logger
.
info
(
"
number of bike trips
"
)
app
.
logger
.
info
(
"
number of bike trips
"
)
...
@@ -220,7 +222,9 @@ def get_kpi_data_and_write(network, events, sim_id):
...
@@ -220,7 +222,9 @@ def get_kpi_data_and_write(network, events, sim_id):
dailyInternalTravels
=
events
.
vehicles_count_per_link
()
dailyInternalTravels
=
events
.
vehicles_count_per_link
()
app
.
logger
.
info
(
"
daily internal travels
"
)
app
.
logger
.
info
(
"
daily internal travels
"
)
write_geojson_links
(
dailyInternalTravels
,
"
dailyInternalTravels
"
,
network
,
sim_id
)
write_geojson_links
(
dailyInternalTravels
,
"
dailyInternalTravels
"
,
network
,
sim_id
)
app
.
logger
.
info
(
"
written dailyInternalTravels
"
)
app
.
logger
.
info
(
"
written dailyInternalTravels
"
)
elif
network
.
city
==
"
amsterdam
"
:
elif
network
.
city
==
"
amsterdam
"
:
...
@@ -245,7 +249,9 @@ def get_kpi_data_and_write(network, events, sim_id):
...
@@ -245,7 +249,9 @@ def get_kpi_data_and_write(network, events, sim_id):
write_geojson_links
(
bike_intensity
,
"
bikeIntensity
"
,
network
,
sim_id
)
write_geojson_links
(
bike_intensity
,
"
bikeIntensity
"
,
network
,
sim_id
)
app
.
logger
.
info
(
"
written bikeIntensity
"
)
app
.
logger
.
info
(
"
written bikeIntensity
"
)
bike_congestion
=
events
.
get_congested_links
(
rush_hour
,
vehicle_mode
=
"
bicycle
"
)[
"
congested_links
"
]
bike_congestion
=
events
.
get_congested_links
(
rush_hour
,
vehicle_mode
=
"
bicycle
"
)[
"
congested_links
"
]
app
.
logger
.
info
(
"
bikeCongestion
"
)
app
.
logger
.
info
(
"
bikeCongestion
"
)
write_geojson_links
(
bike_congestion
,
"
bikeCongestion
"
,
network
,
sim_id
)
write_geojson_links
(
bike_congestion
,
"
bikeCongestion
"
,
network
,
sim_id
)
app
.
logger
.
info
(
"
written bikeCongestion
"
)
app
.
logger
.
info
(
"
written bikeCongestion
"
)
...
@@ -285,32 +291,28 @@ def write_geojson_pedestrian_trips(kpi_data, network, sim_id):
...
@@ -285,32 +291,28 @@ def write_geojson_pedestrian_trips(kpi_data, network, sim_id):
# crs_transformer = Transformer.from_crs("epsg:2062", "epsg:4326")
# crs_transformer = Transformer.from_crs("epsg:2062", "epsg:4326")
for
element
in
kpi_data
:
for
element
in
kpi_data
:
if
element
[
"
average_time
"
]
<
3600.
:
continue
if
element
[
"
average_time
"
]
<
3600.0
:
continue
s_link
=
network
.
get_link
(
element
[
"
start_link
"
])
s_link
=
network
.
get_link
(
element
[
"
start_link
"
])
s_nodes
=
[
network
.
get_node
(
s_link
[
"
from
"
]),
network
.
get_node
(
s_link
[
"
to
"
])
]
s_nodes
=
[
network
.
get_node
(
s_link
[
"
from
"
]),
network
.
get_node
(
s_link
[
"
to
"
])]
s_point
=
(
s_point
=
(
(
float
(
s_nodes
[
0
][
"
x
"
])
+
float
(
s_nodes
[
1
][
"
x
"
]))
/
2.
,
(
float
(
s_nodes
[
0
][
"
x
"
])
+
float
(
s_nodes
[
1
][
"
x
"
]))
/
2.
0
,
(
float
(
s_nodes
[
0
][
"
y
"
])
+
float
(
s_nodes
[
1
][
"
y
"
]))
/
2.
(
float
(
s_nodes
[
0
][
"
y
"
])
+
float
(
s_nodes
[
1
][
"
y
"
]))
/
2.
0
,
)
)
s_point
=
tuple
(
reversed
(
crs_transformer
.
transform
(
*
s_point
)))
s_point
=
tuple
(
reversed
(
crs_transformer
.
transform
(
*
s_point
)))
e_link
=
network
.
get_link
(
element
[
"
end_link
"
])
e_link
=
network
.
get_link
(
element
[
"
end_link
"
])
e_nodes
=
[
network
.
get_node
(
e_link
[
"
from
"
]),
network
.
get_node
(
e_link
[
"
to
"
])]
e_nodes
=
[
network
.
get_node
(
e_link
[
"
from
"
]),
network
.
get_node
(
e_link
[
"
to
"
])]
e_point
=
(
e_point
=
(
(
float
(
e_nodes
[
0
][
"
x
"
])
+
float
(
e_nodes
[
1
][
"
x
"
]))
/
2.
,
(
float
(
e_nodes
[
0
][
"
x
"
])
+
float
(
e_nodes
[
1
][
"
x
"
]))
/
2.
0
,
(
float
(
e_nodes
[
0
][
"
y
"
])
+
float
(
e_nodes
[
1
][
"
y
"
]))
/
2.
(
float
(
e_nodes
[
0
][
"
y
"
])
+
float
(
e_nodes
[
1
][
"
y
"
]))
/
2.
0
,
)
)
e_point
=
tuple
(
reversed
(
crs_transformer
.
transform
(
*
e_point
)))
e_point
=
tuple
(
reversed
(
crs_transformer
.
transform
(
*
e_point
)))
data
[
"
features
"
].
append
(
data
[
"
features
"
].
append
(
{
{
"
type
"
:
"
Feature
"
,
"
type
"
:
"
Feature
"
,
"
properties
"
:
{
"
properties
"
:
{
"
long pedestrian trip
"
:
element
[
"
average_time
"
]
/
(
60
)},
"
long pedestrian trip
"
:
element
[
"
average_time
"
]
/
(
60
)
"
geometry
"
:
{
"
type
"
:
"
LineString
"
,
"
coordinates
"
:
[
s_point
,
e_point
]},
},
"
geometry
"
:
{
"
type
"
:
"
LineString
"
,
"
coordinates
"
:
[
s_point
,
e_point
]
}
}
}
)
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment