Skip to content

Commit 927dd15

Browse files
authored
feat(response): assert all timestamps are without time zone
because they are always in UTC anyway closes #103
1 parent bcf2ad7 commit 927dd15

39 files changed

+129
-69
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- start and end timestamp meta information of the client are now datetime objects
88
- accept shapely Polygon and MultiPolygon for `bpolys` input parameter
99
- if a request fails a bash script containing the respective `curl` command is logged (if possible). This allows for easier debugging and sharing of failed requests.
10+
- timestamps are converted without timezone information. Deviates from Ohsome API [(Issue #318)](https://github.com/GIScience/ohsome-api/issues/318)
1011

1112
### Changed
1213

ohsome/response.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,30 +112,30 @@ def _as_geodataframe(
112112

113113
if "@validFrom" in features.columns:
114114
features["@validFrom"] = pd.to_datetime(
115-
features["@validFrom"], format="%Y-%m-%dT%H:%M:%SZ"
115+
features["@validFrom"].str.replace("Z", ""), format="ISO8601"
116116
)
117117
features["@validTo"] = pd.to_datetime(
118-
features["@validTo"], format="%Y-%m-%dT%H:%M:%SZ"
118+
features["@validTo"].str.replace("Z", ""), format="ISO8601"
119119
)
120120
if multi_index:
121121
features = features.set_index(["@osmId", "@validFrom", "@validTo"])
122122
elif "@snapshotTimestamp" in features.columns:
123123
features["@snapshotTimestamp"] = pd.to_datetime(
124-
features["@snapshotTimestamp"], format="%Y-%m-%dT%H:%M:%SZ"
124+
features["@snapshotTimestamp"].str.replace("Z", ""), format="ISO8601"
125125
)
126126
if multi_index:
127127
features = features.set_index(["@osmId", "@snapshotTimestamp"])
128128
elif (
129129
"timestamp" in features.columns and "groupByBoundaryId" in features.columns
130130
):
131131
features["timestamp"] = pd.to_datetime(
132-
features["timestamp"], format="%Y-%m-%dT%H:%M:%SZ"
132+
features["timestamp"].str.replace("Z", ""), format="ISO8601"
133133
)
134134
if multi_index:
135135
features = features.set_index(["groupByBoundaryId", "timestamp"])
136136
elif "@timestamp" in features.columns:
137137
features["@timestamp"] = pd.to_datetime(
138-
features["@timestamp"], format="%Y-%m-%dT%H:%M:%SZ"
138+
features["@timestamp"].str.replace("Z", ""), format="ISO8601"
139139
)
140140
if multi_index:
141141
features = features.set_index(["@timestamp"])
@@ -200,12 +200,12 @@ def _format_timestamp(self, result_df: DataFrame) -> None:
200200
"""
201201
if "timestamp" in result_df.columns:
202202
result_df["timestamp"] = pd.to_datetime(
203-
result_df["timestamp"], format="ISO8601"
203+
result_df["timestamp"].str.replace("Z", ""), format="ISO8601"
204204
)
205205
else:
206206
result_df["fromTimestamp"] = pd.to_datetime(
207-
result_df["fromTimestamp"], format="ISO8601"
207+
result_df["fromTimestamp"].str.replace("Z", ""), format="ISO8601"
208208
)
209209
result_df["toTimestamp"] = pd.to_datetime(
210-
result_df["toTimestamp"], format="ISO8601"
210+
result_df["toTimestamp"].str.replace("Z", ""), format="ISO8601"
211211
)

ohsome/test/cassettes/test_client/test_check_time_parameter_datetime.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ interactions:
4343
Content-Type:
4444
- application/json
4545
Date:
46-
- Fri, 17 Nov 2023 15:37:04 GMT
46+
- Wed, 29 Nov 2023 13:54:48 GMT
4747
Keep-Alive:
4848
- timeout=5, max=100
4949
Server:

ohsome/test/cassettes/test_client/test_check_time_parameter_list.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ interactions:
4444
Content-Type:
4545
- application/json
4646
Date:
47-
- Fri, 17 Nov 2023 15:37:04 GMT
47+
- Wed, 29 Nov 2023 13:54:48 GMT
4848
Keep-Alive:
4949
- timeout=5, max=100
5050
Server:

ohsome/test/cassettes/test_client/test_end_timestamp_as_time_input.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
interactions:
22
- request:
3-
body: bcircles=0%3A8.678770065307615%2C49.414435400453954%2C100%7C1%3A8.697137832641602%2C49.41007968889129%2C150&time=2023-11-11T22%3A00%3A00&filter=amenity%3Drestaurant+and+type%3Away
3+
body: bcircles=0%3A8.678770065307615%2C49.414435400453954%2C100%7C1%3A8.697137832641602%2C49.41007968889129%2C150&time=2023-11-25T13%3A00%3A00&filter=amenity%3Drestaurant+and+type%3Away
44
headers:
55
Accept:
66
- '*/*'
@@ -20,7 +20,7 @@ interactions:
2020
body:
2121
string: "{\n \"attribution\" : {\n \"url\" : \"https://ohsome.org/copyrights\",\n
2222
\ \"text\" : \"\xA9 OpenStreetMap contributors\"\n },\n \"apiVersion\"
23-
: \"1.10.1\",\n \"result\" : [ {\n \"timestamp\" : \"2023-11-11T22:00:00Z\",\n
23+
: \"1.10.1\",\n \"result\" : [ {\n \"timestamp\" : \"2023-11-25T13:00:00Z\",\n
2424
\ \"value\" : 0.0\n } ]\n}"
2525
headers:
2626
Access-Control-Allow-Credentials:
@@ -42,7 +42,7 @@ interactions:
4242
Content-Type:
4343
- application/json
4444
Date:
45-
- Fri, 17 Nov 2023 15:37:06 GMT
45+
- Wed, 29 Nov 2023 13:54:48 GMT
4646
Keep-Alive:
4747
- timeout=5, max=100
4848
Server:

ohsome/test/cassettes/test_client/test_format_bboxes_dataframe.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ interactions:
4242
Content-Type:
4343
- application/json
4444
Date:
45-
- Fri, 17 Nov 2023 15:37:13 GMT
45+
- Wed, 29 Nov 2023 13:54:53 GMT
4646
Keep-Alive:
4747
- timeout=5, max=100
4848
Server:

ohsome/test/cassettes/test_client/test_format_bboxes_list.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ interactions:
4242
Content-Type:
4343
- application/json
4444
Date:
45-
- Fri, 17 Nov 2023 15:37:13 GMT
45+
- Wed, 29 Nov 2023 13:54:53 GMT
4646
Keep-Alive:
4747
- timeout=5, max=100
4848
Server:
@@ -99,7 +99,7 @@ interactions:
9999
Content-Type:
100100
- application/json
101101
Date:
102-
- Fri, 17 Nov 2023 15:37:14 GMT
102+
- Wed, 29 Nov 2023 13:54:53 GMT
103103
Keep-Alive:
104104
- timeout=5, max=100
105105
Server:
@@ -156,7 +156,7 @@ interactions:
156156
Content-Type:
157157
- application/json
158158
Date:
159-
- Fri, 17 Nov 2023 15:37:14 GMT
159+
- Wed, 29 Nov 2023 13:54:55 GMT
160160
Keep-Alive:
161161
- timeout=5, max=100
162162
Server:
@@ -213,7 +213,7 @@ interactions:
213213
Content-Type:
214214
- application/json
215215
Date:
216-
- Fri, 17 Nov 2023 15:37:16 GMT
216+
- Wed, 29 Nov 2023 13:54:55 GMT
217217
Keep-Alive:
218218
- timeout=5, max=100
219219
Server:
@@ -270,7 +270,7 @@ interactions:
270270
Content-Type:
271271
- application/json
272272
Date:
273-
- Fri, 17 Nov 2023 15:37:16 GMT
273+
- Wed, 29 Nov 2023 13:54:55 GMT
274274
Keep-Alive:
275275
- timeout=5, max=100
276276
Server:

ohsome/test/cassettes/test_client/test_format_bcircles_dataframe.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ interactions:
4545
Content-Type:
4646
- application/json
4747
Date:
48-
- Fri, 17 Nov 2023 15:37:06 GMT
48+
- Wed, 29 Nov 2023 13:54:49 GMT
4949
Keep-Alive:
5050
- timeout=5, max=100
5151
Server:

ohsome/test/cassettes/test_client/test_format_bcircles_list.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ interactions:
4242
Content-Type:
4343
- application/json
4444
Date:
45-
- Fri, 17 Nov 2023 15:37:08 GMT
45+
- Wed, 29 Nov 2023 13:54:51 GMT
4646
Keep-Alive:
4747
- timeout=5, max=100
4848
Server:
@@ -102,7 +102,7 @@ interactions:
102102
Content-Type:
103103
- application/json
104104
Date:
105-
- Fri, 17 Nov 2023 15:37:08 GMT
105+
- Wed, 29 Nov 2023 13:54:51 GMT
106106
Keep-Alive:
107107
- timeout=5, max=100
108108
Server:
@@ -159,7 +159,7 @@ interactions:
159159
Content-Type:
160160
- application/json
161161
Date:
162-
- Fri, 17 Nov 2023 15:37:09 GMT
162+
- Wed, 29 Nov 2023 13:54:51 GMT
163163
Keep-Alive:
164164
- timeout=5, max=100
165165
Server:
@@ -216,7 +216,7 @@ interactions:
216216
Content-Type:
217217
- application/json
218218
Date:
219-
- Fri, 17 Nov 2023 15:37:09 GMT
219+
- Wed, 29 Nov 2023 13:54:52 GMT
220220
Keep-Alive:
221221
- timeout=5, max=100
222222
Server:

ohsome/test/cassettes/test_client/test_format_bcircles_pandas.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ interactions:
5151
Content-Type:
5252
- application/json
5353
Date:
54-
- Fri, 17 Nov 2023 15:37:11 GMT
54+
- Wed, 29 Nov 2023 13:54:52 GMT
5555
Keep-Alive:
5656
- timeout=5, max=100
5757
Server:

0 commit comments

Comments
 (0)