Skip to content

Dynamic Spatial Queries

ebiiii edited this page Dec 15, 2014 · 1 revision

Dynamic Spatial Queries (experimental)

The /dynamicgeodata web call allows making basic spatial queries for moving sensors. The virtual sensor description file should contain fields for dynamic coordinates in its output structure. The recognized field names are latitude, longitude and altitude.

<output-structure>
   <field name="light" type="double" />
   <field name="temperature" type="double" />
   <field name="packet_type" type="double" />
   <field name="latitude" type="double" />
   <field name="longitude" type="double" />
   <field name="altitude" type="double" />
</output-structure>

Parameters:

  • env: Envelope of the geographical area comprising the sensors to query. The envelope is specified in Well Known Text WKT format. For example, POLYGON ((0 0, 0 100, 100 100, 100 0, 0 0))
  • field: Field to query. For example, temperature.
  • timed: Timestamp to use in queries, expressed in milliseconds as Unix timestamp. Use keyword latest for latest timestamp.
  • format: csv, json, or xml. (optional, default value is csv)
  • username: (Optional) Username. Used with ACL-enabled GSN instances.
  • password: (Optional) Password for username to access sensor data.
  • debug: Flag for debug mode (true, or false). Debug mode returns additional information. (optional, default value is false)

Examples

Examples 1: Selecting latest measurements for field temperature for all sensors within the geographical area defined by the polygon (0 0, 0 100, 100 100, 100 0, 0 0), output as CSV

  • Parameters:

    • env: POLYGON((0 0, 0 100, 100 100, 100 0, 0 0))
    • field: temperature
    • timed: latest
    • format: csv
    • Complete URL: http://localhost:22001/dynamicgeodata?field=temperature&timed=latest&env=POLYGON((0 0, 0 100, 100 100, 100 0, 0 0))&format=csv
  • Result:

# name, lat, lon, timed, temperature
sensor1, 1.113, 0.305, 1312966147198, 21.3
sensor2, 1.322, 0.512, 1312966147396, 23.2
sensor4, 5.622, 0.904, 1312966146726, 22.2
sensor3, 7.123, 0.889, 1312966147564, 22.3

Examples 2: Selecting measurements for field light at timestamp (1312974685306) for all sensors within the geographical area defined by the polygon (0 0, 0 100, 100 100, 100 0, 0 0), output as XML

  • Parameters:

    • env: POLYGON((0 0, 0 100, 100 100, 100 0, 0 0))
    • field: light
    • timed: 1312974685306
    • format: xml
    • Complete URL: http://localhost:22001/dynamicgeodata?field=light&timed=1312974685306&env=POLYGON((0 0, 0 100, 100 100, 100 0, 0 0))&format=xml
  • Result:

<geodata>
	<sensor name="sensor2" latitude="2.861" longitude="0.082" timed="1312974685306" field="light">286.1</sensor>
	<sensor name="sensor3" latitude="3.873" longitude="0.624" timed="1312974685306" field="light">387.3</sensor>
	<sensor name="sensor1" latitude="6.784" longitude="0.933" timed="1312974685306" field="light">678.4</sensor>
	<sensor name="sensor4" latitude="8.557" longitude="0.143" timed="1312974685306" field="light">855.7</sensor>
</geodata>

Examples 3: Same as previous, output as JSON, useful when used from Javascript * http://localhost:22001/dynamicgeodata?field=light&timed=1312974685306&env=POLYGON((0 0, 0 100, 100 100, 100 0, 0 0))&format=json

[{"timed":1312974685306,"name":"sensor1","ongitude":0.847,"latitude":3.147,"light":314.7},
{"timed":1312974685306,"name":"sensor2","longitude":0.197,"latitude":6.747,"light":674.7},
{"timed":1312974685306,"name":"sensor3","longitude":0.131,"latitude":7.053,"light":705.3},
{"timed":1312974685306,"name":"sensor4","longitude":0.701,"latitude":9.097,"light":909.7}]
Clone this wiki locally