Live documentation for the development version.
In order to make data obtained from an OGC SensorThings API service more accessible, this extension provides data in a simple CSV result format. Since many users still like to work with data in spreadsheet applications, the availability of a CSV result format will help convincing people to use the SensorThings API.
The CSV result format can be requested by setting the request parameter
The resulting CSV document must conform to the RFC 4180 specification.
For single-table queries,
ResultFormat=CSV is mostly self-explanatory.
The header line contains the direct field names, with each further line having the data of one entity.
Navigation links are omitted.
Tricky parts are how to handle:
parametersfield: This is a complex property with an unknown set of fields. The only way to deal with this is to include the JSON as is. Proper encoding to CSV needs to happen, since JSON contains both double quotes and commas, same as CSV, but this is covered by RFC 4180 which defines that double quotes are quoted with a double quote.
Datastream/unitOfMeasurement: This is a complex property with three defined fields. The best way seems to be to split this field into three CSV columns:
id,name,unitOfMeasurement/name,unitOfMeasurement/symbol,unitOfMeasurement/definition 1,My Datastream,degree celcius,°C,ucum:Cel 2,My other Datastream,degree celcius,°C,ucum:Cel
The format returned when fetching a list of entities, or a single entity can be the same.
$select request parameter allows control over the fields that are returned.
Future work: selecting sub-properties of complex properties such as
Single table results are a nice start of course, but the power of the SensorThings API lies in its advanced features. One of the great features is $expand, that allows multi-table results.
Expanding relations with a cardinality of 1, such as Observation->Datastream or Datastream->Thing is easy. The fields of the expanded EntityType are added to the header, prefixed with the expanded with the navigation link name.
id,result,phenomenonTime,Datastream/id,Datastream/name 1,2.9,2005-08-03T23:00:00.000Z,1,My Datastream 2,2.8,2005-08-03T23:01:00.000Z,1,My Datastream
This will duplicate some data, but the data would also be duplicated in the normal result format.
Expands of relations with a cardinality of many, such as Thing -> Datastreams, is not allowed, unless the cardinality is reduced to 1 using the
When requesting more than one item in such an expand, the server will respond with the error: 400 Bad Request.
The reason for this is:
MultiDatastreams are not supported (yet) by the CSV result format.
MultiDatastreams bring their own set of complications:
MultiDatastreams/unitOfMeasurementsis an array of objects, each with 3 fields
MultiDatastreams/multiObservationDataTypesis an array of strings
MultiDatastreams/ObservedPropertiesis a navigationList with cardinality many
MultiDatastreams/Observations/resultis an array
These four arrays/lists are of the same length for any given MultiDatastream, but may be of different length for the next MultiDatastream. Furthermore, the order of the items in these lists is important.
Options for dealing with MultiDatastreams are:
The last option essentially breaks Observations of a MultiDatastream back into normal Observations.
The conformance class this extension must register in the SensorThings (v1.1 and up) index document is: