Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Tesi
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marco Aceti
Tesi
Commits
b6759d92
Verified
Commit
b6759d92
authored
Apr 21, 2023
by
Marco Aceti
Browse files
Options
Downloads
Patches
Plain Diff
Add marker in trajectories map
parent
67d136ad
No related branches found
No related tags found
No related merge requests found
Pipeline
#2809
passed
Apr 21, 2023
Stage: test
Stage: lint
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/analysis/assets/train-marker.svg
+10
-0
10 additions, 0 deletions
src/analysis/assets/train-marker.svg
src/analysis/trajectories_map.py
+58
-25
58 additions, 25 deletions
src/analysis/trajectories_map.py
with
68 additions
and
25 deletions
src/analysis/assets/train-marker.svg
0 → 100644
+
10
−
0
View file @
b6759d92
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg
version=
"1.1"
id=
"svg4619"
inkscape:version=
"0.91+devel+osxmenu r12911"
sodipodi:docname=
"triangle-15.svg"
xmlns:cc=
"http://creativecommons.org/ns#"
xmlns:dc=
"http://purl.org/dc/elements/1.1/"
xmlns:inkscape=
"http://www.inkscape.org/namespaces/inkscape"
xmlns:rdf=
"http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:sodipodi=
"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:svg=
"http://www.w3.org/2000/svg"
xmlns=
"http://www.w3.org/2000/svg"
xmlns:xlink=
"http://www.w3.org/1999/xlink"
x=
"0px"
y=
"0px"
width=
"15px"
height=
"15px"
viewBox=
"0 0 15 15"
style=
"enable-background:new 0 0 15 15;"
xml:space=
"preserve"
>
<path
id=
"path21090-9"
inkscape:connector-curvature=
"0"
sodipodi:nodetypes=
"sscsssscss"
d=
"M7.5385,2
C7.2437,2,7.0502,2.1772,6.9231,2.3846l-5.8462,9.5385C1,12,1,12.1538,1,12.3077C1,12.8462,1.3846,13,1.6923,13h11.6154
C13.6923,13,14,12.8462,14,12.3077c0-0.1538,0-0.2308-0.0769-0.3846L8.1538,2.3846C8.028,2.1765,7.7882,2,7.5385,2z"
/>
</svg>
This diff is collapsed.
Click to expand it.
src/analysis/trajectories_map.py
+
58
−
25
View file @
b6759d92
import
itertools
import
logging
import
pathlib
import
typing
as
t
import
webbrowser
from
collections
import
defaultdict
...
...
@@ -47,6 +48,9 @@ for k in _color_map:
COLOR_MAP
[
k
]
=
_color_map
[
k
]
ASSETS_PATH
=
pathlib
.
Path
(
"
./src/analysis/assets/
"
).
resolve
()
def
fill_time
(
start
:
datetime
,
end
:
datetime
)
->
t
.
Generator
[
datetime
,
None
,
None
]:
"""
Generate a consecutive list of times between the
'
start
'
and
'
end
'
period.
...
...
@@ -101,13 +105,8 @@ def train_stop_geojson(st: pd.DataFrame, train: pd.DataFrame) -> list[dict]:
# The station location can't be retrieved
continue
prev_time
:
datetime
|
None
=
prev
.
departure_expected
if
prev
.
departure_actual
:
prev_time
=
prev
.
departure_actual
curr_time
:
datetime
|
None
=
curr
.
arrival_expected
if
curr
.
arrival_actual
:
curr_time
=
curr
.
arrival_actual
prev_time
:
datetime
|
None
=
prev
.
departure_actual
or
prev
.
departure_expected
curr_time
:
datetime
|
None
=
curr
.
arrival_actual
or
curr
.
arrival_expected
# Sanity check: _time must be not null
if
not
prev_time
or
not
curr_time
:
...
...
@@ -123,7 +122,8 @@ def train_stop_geojson(st: pd.DataFrame, train: pd.DataFrame) -> list[dict]:
continue
for
timestamp
in
fill_time
(
prev_time
,
curr_time
):
ret
.
append
(
ret
.
extend
(
[
{
"
type
"
:
"
Feature
"
,
"
geometry
"
:
{
...
...
@@ -143,7 +143,40 @@ def train_stop_geojson(st: pd.DataFrame, train: pd.DataFrame) -> list[dict]:
else
MIN_WEIGHT
,
},
},
}
},
{
"
type
"
:
"
Feature
"
,
"
geometry
"
:
{
"
type
"
:
"
Point
"
,
"
coordinates
"
:
(
curr_st
.
longitude
,
curr_st
.
latitude
),
},
"
properties
"
:
{
"
icon
"
:
"
marker
"
,
"
iconstyle
"
:
{
"
iconUrl
"
:
str
(
ASSETS_PATH
/
"
train-marker.svg
"
),
"
iconSize
"
:
[
24
,
24
],
"
fillOpacity
"
:
1
,
},
"
tooltip
"
:
(
f
"
<b>
{
curr
.
client_code
}
</b> ∙ <b>
{
curr
.
category
}
</b> <b>
{
curr
.
number
}
</b>
"
f
"
<dd>
{
prev_st
.
long_name
}
"
f
"
{
f
'
(
{
round
(
prev
.
departure_delay
,
1
)
:
+
g
}
min
)
'
if not np.isnan(prev.departure_delay) else
''
}
"
f
"
→
"
f
"
{
curr_st
.
long_name
}
"
f
"
{
f
'
(
{
round
(
prev
.
arrival_delay
,
1
)
:
+
g
}
min
)
'
if not np.isnan(prev.arrival_delay) else
''
}
"
),
"
name
"
:
""
,
"
times
"
:
[
timestamp
.
isoformat
()],
"
style
"
:
{
"
color
"
:
COLOR_MAP
[
curr
.
client_code
],
"
weight
"
:
int
(
curr
.
crowding
/
10
)
if
not
np
.
isnan
(
curr
.
crowding
)
and
curr
.
crowding
>
MIN_WEIGHT
*
10
else
MIN_WEIGHT
,
},
},
},
]
)
return
ret
...
...
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