Skip to content

Commit

Permalink
Support both "times" and "timestamps"
Browse files Browse the repository at this point in the history
The `tracejson` format has some open questions around how to represent start
and end times. Should they also be milliseconds? What should the labels be, etc?
In order to avoid dealing with those issues right now, we return both "times"
and "timestamps". The "times" retain backward compatibility with existing code;
the "timestamps" ensure that it is valid tracejson.

We will revisit this after the paper on mobility standards:
e-mission/e-mission-docs#542 (comment)
  • Loading branch information
shankari committed Aug 2, 2020
1 parent 22c22f6 commit 33b4bf2
Show file tree
Hide file tree
Showing 4 changed files with 829 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,16 +199,19 @@ def point_array_to_line(point_array):
# points_line_string.coordinates = [l.loc.coordinates for l in filtered_section_location_array]
points_line_string.coordinates = []
points_times = []
points_timestamps = []

for l in point_array:
# logging.debug("About to add %s to line_string " % l)
points_line_string.coordinates.append(l.data.loc.coordinates)
points_times.append(int(round(l.data.ts * 1000)))
points_times.append(l.data.ts)
points_timestamps.append(int(round(l.data.ts * 1000)))

points_line_feature = gj.Feature()
points_line_feature.geometry = points_line_string
points_line_feature.properties = {}
points_line_feature.properties["timestamps"] = points_times
points_line_feature.properties["times"] = points_times
points_line_feature.properties["timestamps"] = points_timestamps
return points_line_feature

def trip_to_geojson(trip, tl):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,41 @@
]
},
"properties": {
"times": [
1452970948.0723116,
1452970978.0723116,
1452971008.0723116,
1452971038.0723116,
1452971068.0723116,
1452971098.0723116,
1452971128.0723116,
1452971158.0723116,
1452971188.0723116,
1452971218.0723116,
1452971248.0723116,
1452971278.0723116,
1452971308.0723116,
1452971338.0723116,
1452971368.0723116,
1452971398.0723116,
1452971428.0723116,
1452971458.0723116,
1452971488.0723116,
1452971518.0723116,
1452971548.0723116,
1452971578.0723116,
1452971608.0723116,
1452971638.0723116,
1452971668.0723116,
1452971698.0723116,
1452971728.0723116,
1452971758.0723116,
1452971788.0723116,
1452971818.0723116,
1452971848.0723116,
1452971858.0,
1452971858.0
],
"timestamps": [
1452970948072,
1452970978072,
Expand Down Expand Up @@ -691,6 +726,33 @@
]
},
"properties": {
"times": [
1452971858.0,
1452971858.0,
1452971888.0,
1452971918.0,
1452971948.0,
1452971978.0,
1452972008.0,
1452972038.0,
1452972068.0,
1452972098.0,
1452972128.0,
1452972158.0,
1452972188.0,
1452972218.0,
1452972248.0,
1452972278.0,
1452972308.0,
1452972338.0,
1452972368.0,
1452972398.0,
1452972428.0,
1452972458.0,
1452972488.0,
1452972518.0,
1452972533.0
],
"timestamps": [
1452971858000,
1452971858000,
Expand Down Expand Up @@ -1161,6 +1223,26 @@
]
},
"properties": {
"times": [
1452982929.43532,
1452982959.43532,
1452982989.43532,
1452983019.43532,
1452983049.43532,
1452983079.43532,
1452983109.43532,
1452983139.43532,
1452983169.43532,
1452983199.43532,
1452983229.43532,
1452983259.43532,
1452983289.43532,
1452983319.43532,
1452983349.43532,
1452983379.43532,
1452983409.43532,
1452983423.0
],
"timestamps": [
1452982929435,
1452982959435,
Expand Down Expand Up @@ -1336,6 +1418,24 @@
]
},
"properties": {
"times": [
1452983425,
1452983455,
1452983485,
1452983515,
1452983545,
1452983575,
1452983605,
1452983635,
1452983665,
1452983695,
1452983725,
1452983755,
1452983785,
1452983815,
1452983845,
1452983871
],
"timestamps": [
1452983425000,
1452983455000,
Expand Down Expand Up @@ -1434,4 +1534,4 @@
"id": "5a357edbf6858fe2e1156fac"
}
]
}
}
Loading

0 comments on commit 33b4bf2

Please sign in to comment.