2016-04-14 5 views
2

SensorThingsAPI(https://en.wikipedia.org/wiki/SensorThings_API)から$ expandパラメータの結果を切り捨てようとしています。

http://example.org/v1.0/Things?$expand=Datastreams  

ただし、$ topはクエリのトランク(例:Things)のみを制限します。 $ expandの 'leaves'の結果を切り捨てる方法はありますか?

答えて

1

この場合、サーバー側ページネーションは$expandの 'leaves'を制御する必要があります。

たとえば、応答ごとのエンティティ100とエンティティ(またはコレクション)が100を超える場合、サービスはサービス定義の順序に従って上位100個のエンティティを返します。 A @iot.nextLinkも返されるので、クライアントは次の100個のエンティティ(次のページ)をフェッチする方法を知ることができます。 http://scratchpad.sensorup.com/OGCSensorThings/v1.0/Datastreams?$expand=Observations

次JSON:Datastreamsを取得するために、一例として、例えば、nextLinkを上記のクエリを使用すると、あなたは$拡大の例のリターンを表示するには、このOGC SensorThingsサンドボックスを使用することができます

[email protected]:"http://URL_to_retrieve_the_next_page/"

になりますhttp://scratchpad.sensorup.com/OGCSensorThings/v1.0/Datastreams?$expand=Observations$expandと次のクエリの例の応答を示す

{ 
 
    "@iot.count": 1, 
 
    "value": [{ 
 
    "@iot.id": 8, 
 
    "@iot.selfLink": "http://scratchpad.sensorup.com/OGCSensorThings/v1.0/Datastreams(8)", 
 
    "description": "Daily Water level", 
 
    "observationType": "http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_Observation", 
 
    "unitOfMeasurement": { 
 
     "symbol": "m", 
 
     "name": "meter", 
 
     "definition": "https://en.wikipedia.org/wiki/Metre" 
 
    }, 
 
    "[email protected]": "http://scratchpad.sensorup.com/OGCSensorThings/v1.0/Datastreams(8)/Observations?$top=3&$skip=3", 
 
    "[email protected]": 1826, 
 
    "Observations": [{ 
 
     "@iot.id": 1835, 
 
     "@iot.selfLink": "http://scratchpad.sensorup.com/OGCSensorThings/v1.0/Observations(1835)", 
 
     "phenomenonTime": "2015-12-30T16:00:00.000Z", 
 
     "result": "1375.44", 
 
     "resultTime": null, 
 
     "[email protected]": "http://scratchpad.sensorup.com/OGCSensorThings/v1.0/Observations(1835)/Datastream", 
 
     "[email protected]": "http://scratchpad.sensorup.com/OGCSensorThings/v1.0/Observations(1835)/FeatureOfInterest" 
 
    }], 
 
    "[email protected]": "http://scratchpad.sensorup.com/OGCSensorThings/v1.0/Datastreams(8)/ObservedProperty", 
 
    "[email protected]": "http://scratchpad.sensorup.com/OGCSensorThings/v1.0/Datastreams(8)/Sensor", 
 
    "[email protected]": "http://scratchpad.sensorup.com/OGCSensorThings/v1.0/Datastreams(8)/Thing" 
 
    },{},{}] 
 
}