mirror of
https://github.com/jdejaegh/python-irceline.git
synced 2025-06-26 19:35:40 +02:00
Refactor
This commit is contained in:
parent
8b00d85957
commit
e146c8359e
1 changed files with 7 additions and 1 deletions
|
@ -49,8 +49,14 @@ class IrcelineClient:
|
|||
# (e.g. 5.01 PM, but the most recent data is for 4.00 PM)
|
||||
if isinstance(timestamp, datetime):
|
||||
timestamp = timestamp.replace(microsecond=0, second=0, minute=0) - timedelta(hours=1)
|
||||
timestamp = timestamp.isoformat()
|
||||
key = 'timestamp'
|
||||
elif isinstance(timestamp, date):
|
||||
timestamp = timestamp - timedelta(days=1)
|
||||
timestamp = timestamp.isoformat()
|
||||
key = 'date'
|
||||
else:
|
||||
raise IrcelineApiError(f"Wrong parameter type for timestamp: {type(timestamp)}")
|
||||
|
||||
coord = self.epsg_transform(position)
|
||||
querystring = {"service": "WFS",
|
||||
|
@ -59,7 +65,7 @@ class IrcelineClient:
|
|||
"outputFormat": "application/json",
|
||||
"typeName": ",".join(features),
|
||||
"cql_filter":
|
||||
f"{'timestamp' if isinstance(timestamp, datetime) else 'date'}>='{timestamp.isoformat()}'"
|
||||
f"{key}>='{timestamp}'"
|
||||
f" AND "
|
||||
f"INTERSECTS(the_geom, POINT ({coord[0]} {coord[1]}))"}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue