This commit is contained in:
Jules 2024-06-16 13:27:09 +02:00
parent 8b00d85957
commit e146c8359e
Signed by: jdejaegh
GPG key ID: 99D6D184CA66933A

View file

@ -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]}))"}