Closed sudhamani1983 closed 6 years ago
I'm not entirely sure what you mean, but you are correct in that the current API does not have a good way of dealing with time intervals. I've also posted this as an issue on the Github account of the SensorThings API, in the issue: https://github.com/opengeospatial/sensorthings/issues/2
Is what you want to do one of the following?
These operators are not part of the standard yet, but we are discussing adding them to the standard. We have already implemented them:
/v1.0/Datastreams(32)/Observations?$filter=overlaps(phenomenontime,2017-08-14T02:45:00.000Z/2017-09-30T01:10:00.000Z)&$select=result,phenomenonTime
/v1.0/Datastreams(32)/Observations?$filter=during(phenomenontime,2017-08-14T02:45:00.000Z/2017-09-30T01:10:00.000Z)&$select=result,phenomenonTime
The lt and gt operators can be used to simulate the first, by doing an inverse query: return all the observations that have a phenomenonTime that is not smaller than the start of the given interval and that is not larger than the end of the given interval.
The during function can be simulated using the lt and gt operators by simply taking all the observations that have a phenomenonTime that is larger than the start of the given interval and that is smaller than the end of the given interval.
It seems like your query is wrong (at least for the result you expect) because you are mixing up time zones (+00 in the query but +08 in the data). So actually, the query is working as expected but I assume you may want to change your query to
http://localhost:8080/SensorThingsService/v1.0/Datastreams(32)/Observations?$filter=phenomenontime ge 2017-08-14T02:45:00.000+08:00 and phenomenontime lt 2017-09-30T01:10:00.000+08:00&$select=result,phenomenonTime
Overlaps function helps for my requirement. Thanks.
We are looking for support to filter Observation for a time interval (phenomeonTimeStart and phenomenonTimeEnd time of an observation).
We need record within the given filter value, but not.
Below is my url: http://localhost:8080/SensorThingsService/v1.0/Datastreams(32)/Observations?$filter=phenomenontime ge 2017-08-14T02:45:00.000Z and phenomenontime lt 2017-09-30T01:10:00.000Z&$select=result,phenomenonTime
Result :
{ "@iot.count": 2, "value": [ { "phenomenonTime": "2017-08-15T03:00:00.000Z/2017-08-15T04:00:00.000Z", "result": 62 }, { "phenomenonTime": "2017-08-15T01:42:00.000Z/2017-08-15T02:55:00.000Z", "result": 67 } ] }
Original Data in Table:
ng…]()
Below Observation records available for Datastream Id 32 : { "phenomenonTime": "2017-09-30T01:00:00.000Z/2017-09-30T02:00:00.000Z", "result": 58 }, { "phenomenonTime": "2017-08-15T03:00:00.000Z/2017-08-15T04:00:00.000Z", "result": 62 }, { "phenomenonTime": "2017-08-15T01:42:00.000Z/2017-08-15T02:55:00.000Z", "result": 67 }, { "phenomenonTime": "2017-08-14T01:42:00.000Z/2017-08-14T02:55:00.000Z", "result": 71 }