gost / server

GOST - Go implementation of OGC SensorThings API
MIT License
61 stars 19 forks source link

Filter Bonus test #118

Closed bertt closed 6 years ago

bertt commented 7 years ago

from spec (example 24 - sample request 4 from http://docs.opengeospatial.org/is/15-078r6/15-078r6.html):

"returns Things that have any observations of a feature of interest with a unique identifier equals to ’FOI_1’ in June 2010."

$ curl http://example.org/v1.0/Things?$expand= Datastreams/Observations/FeatureOfInterest&$filter=Datastreams/Observations/FeatureOfInterest/id eq ‘FOI_1’ and Datastreams/Observations/resultTime ge 2010-06-01T00:00:00Z and Datastreams/Observations/resultTime le 2010-07-01T00:00:00Z 

does it work?

tebben commented 6 years ago

Errors in test url

new url v1.0/Things?$expand=Datastreams/Observations/FeatureOfInterest&$filter=Datastreams/Observations/FeatureOfInterest/id eq 1 and Datastreams/Observations/resultTime ge 2010-06-01T00:00:00Z and Datastreams/Observations/resultTime le 2010-07-01T00:00:00Z

error

{
   "error": {
      "status": "Internal Server Error",
      "code": 500,
      "message": [
         "Error executing query pq: column \"resulttime\" does not exist"
      ]
   }
}

Looking at the generated query it seems that filters after "and" are not removed correctly after moving them to the correct entity when using / (relations), working on it.

tebben commented 6 years ago

Should work now.

Start GOST with empty database and download bonus.sh and make it executable

sudo chmod +x bonus.sh

Run script to add test data, the script assumes GOST runs on localhost:8080/v1.0

./bonus.sh

Request Things that have any observations of a feature of interest with a name equals to ’test foi 2’ in June 2010

http://localhost:8080/v1.0/Things?$expand=Datastreams/Observations/FeatureOfInterest&$filter=Datastreams/Observations/FeatureOfInterest/name eq 'test foi 2' and Datastreams/Observations/resultTime ge 2010-06-01T00:00:00Z and Datastreams/Observations/resultTime le 2010-07-01T00:00:00Z

Expected result: Thing 1 with expanded Datastream 1 with expanded Observations 3 and 4 both with expanded FOI 2

bertt commented 6 years ago

first test passed!

tebben commented 6 years ago

Updated bonus.sh

Request Things that have any observations of a feature of interest with a name equals to ’test foi 2’ in June 2010 with the following entities expanded Datastreams/Observations/FeatureOfInterest

http://localhost:8080/v1.0/Things?$expand=Datastreams/Observations/FeatureOfInterest&$filter=Datastreams/Observations/FeatureOfInterest/name eq 'test foi 2' and Datastreams/Observations/resultTime ge 2010-06-01T00:00:00Z and Datastreams/Observations/resultTime le 2010-07-01T00:00:00Z

Expected result:

Thing 1
    - Datastream 1
        - Observation 3
        - Observation 4
Thing 3
    - Datastream 4
        - Observation 8
        - Observation 9

Request Things that have any observations of a feature of interest with a name equals to ’test foi 2’ in June 2010 with no entities expanded

http://localhost:8080/v1.0/Things?$filter=Datastreams/Observations/FeatureOfInterest/name eq 'test foi 2' and Datastreams/Observations/resultTime ge 2010-06-01T00:00:00Z and Datastreams/Observations/resultTime le 2010-07-01T00:00:00Z

Expected result:

Thing 1
Thing 3
bertt commented 6 years ago

tested again works allright! let's close this issue.