mirror of
https://github.com/jdejaegh/python-irceline.git
synced 2025-06-27 03:35:56 +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)
|
# (e.g. 5.01 PM, but the most recent data is for 4.00 PM)
|
||||||
if isinstance(timestamp, datetime):
|
if isinstance(timestamp, datetime):
|
||||||
timestamp = timestamp.replace(microsecond=0, second=0, minute=0) - timedelta(hours=1)
|
timestamp = timestamp.replace(microsecond=0, second=0, minute=0) - timedelta(hours=1)
|
||||||
|
timestamp = timestamp.isoformat()
|
||||||
|
key = 'timestamp'
|
||||||
elif isinstance(timestamp, date):
|
elif isinstance(timestamp, date):
|
||||||
timestamp = timestamp - timedelta(days=1)
|
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)
|
coord = self.epsg_transform(position)
|
||||||
querystring = {"service": "WFS",
|
querystring = {"service": "WFS",
|
||||||
|
@ -59,7 +65,7 @@ class IrcelineClient:
|
||||||
"outputFormat": "application/json",
|
"outputFormat": "application/json",
|
||||||
"typeName": ",".join(features),
|
"typeName": ",".join(features),
|
||||||
"cql_filter":
|
"cql_filter":
|
||||||
f"{'timestamp' if isinstance(timestamp, datetime) else 'date'}>='{timestamp.isoformat()}'"
|
f"{key}>='{timestamp}'"
|
||||||
f" AND "
|
f" AND "
|
||||||
f"INTERSECTS(the_geom, POINT ({coord[0]} {coord[1]}))"}
|
f"INTERSECTS(the_geom, POINT ({coord[0]} {coord[1]}))"}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue