Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filtering over nested properties #169

Open
Alystrasz opened this issue Dec 3, 2019 · 2 comments
Open

Filtering over nested properties #169

Alystrasz opened this issue Dec 3, 2019 · 2 comments

Comments

@Alystrasz
Copy link

Hello,
I'm trying to filter a thing's locations, expanding its historical locations (since Things(42)/Locations only returns the current location); the objective is to match locations present in a given area.

Here's the request :

v1.0/Things(42)/HistoricalLocations
    ?$expand=Locations
    &$filter=st_within(location, geography'POLYGON ((-4 -11, 4 -11, 4 11, -4 11, -4 -11))')

Unfortunately, it returns { "value": null }.
This is what my Location entities look like:

{
   "@iot.id": 708,
   "@iot.selfLink": "[...]/v1.0/Locations(708)",
   "name": "42",
   "description": "Location of Station 71",
   "encodingType": "application/vnd.geo+json",
   "location": {
      "coordinates": [ 3.128898, 10.095246 ],
      "properties": {
         "height": "5",
         "receptionTime": "1745420000"
      },
      "type": "Point"
   },
   "[email protected]": "[...]/v1.0/Locations(708)/Things",
   "[email protected]": "[...]/v1.0/Locations(708)/HistoricalLocations"
}
  1. How can I geo-filter locations starting from HistoricalLocations?
  2. Is there a way to filter locations based on any of the "properties" (e.g. receptionTime)?
@bertt
Copy link
Contributor

bertt commented Dec 5, 2019

Hi, we did a quick analysis, some remarks:

question 1:

  • we think your current query will not work because the filter is executed on historicallocation. However, the historicallocation has only a pointer to location;
  • a better solution would be filtering on location, something like:
v1.0/Things(42)/HistoricalLocations?$expand=Locations($filter=st_within(location, geography'POLYGON ((-4 -11, 4 -11, 4 11, -4 11, -4 -11))'))

However this does also not correct results. This needs to be further analyzed.

question 2: At the moment filtering locations on properties is not possible. Maybe it's defined in the SensorThings 1.1 spec.

@tebben
Copy link
Contributor

tebben commented Dec 5, 2019

Regarding the solution of bert, the result you will get is all HistoricalLocations with or without expanded locations. What you probably want is relation filtering

v1.0/Things(2704005)/HistoricalLocations?$expand=Locations&$filter=st_within(Locations/location, geography'POLYGON((-4 -11, 4 -11, 4 11, -4 11, -4 -11))')

This will return only the HistoricalLocations with expanded locations that are within your geometry, however relation filtering is not yet implemented in GOST, I hope I have some time to work on this soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants