Skip to content

Example Setup: Ingestion via MQTT with UpdateFOI

Jan Speckamp edited this page Mar 6, 2020 · 2 revisions

General

This short tutorial shows how a stream of observation+location data (e.g. live location updates ingested via MQTT) can be imported into the STA via MQTT. It makes use of the 52N-sensorweb-server-sta specific functionality "updateFOI" and "mqttPublishTopics" and "user-defined @iot.ids"

Docker Setup

  • Set required environment variables (see docker-compose.yml in root directory for a default setup)
  • Set environment variable SERVER_FEATURE_PLAINTCP=true to start mqtt broker (or alternatively use websockets via SERVER_FEATURE_PLAINTCP=true)
  • Set environment variable SERVER_FEATURE_UPDATEFOI=true
  • Set environment variable SERVER_FEATURE_MQTTPUBLISHTOPICS=Locations,Observations

Workflows

Workflow "main":

Note: Example payloads are provided below

  1. POST FeatureOfInterest. Set "@iot.id" to a reasonable name (autogenerated uuid will be assigned otherwise).
  2. POST Thing with nested Datastream, Datastream->Sensor, Datastream->ObservedProperty all with specified @iot.id. Specify Thing->properties->"updateFOI" to let STA automatically extend the FOI geometry with given id.
  3. MQTT Publish Location when a new location is present. Set Things->@iot.id to the Id of the Thing from step 2.
  4. MQTT Publish Observation when a new Observation is present. Set FeatureOfInterest->@iot.id and Datastream->@iot.id to the correct values from steps 1&2;

Workflow "new feature":

Note: Example payloads are provided below

  1. POST FeatureOfInterest. Set "@iot.id" to a reasonable name (autogenerated uuid will be assigned otherwise)
  2. PATCH Thing and change properties->updateFOI to new FOI

Example payloads

POST "/FeaturesOfInterest"
{
    "@iot.id": "MSGuenter-Trip-01",
    "name": "MSGuenter-Trip-01",
    "description": "This is the first Forschungstrip of MS Guenther",
    "encodingType": "application/vnd.geo+json",
    "feature": {
        "type": "Feature",
        "geometry": {
            "type": "Point",
            "coordinates": [
                52,
                7
            ]
        }
    }
}
POST "/Things"
{
	"@iot.id": "MSGuenther",
	"description": "This is a Forschungsschiff",
	"name": "MS Guenther",
	"properties": {
		"updateFOI": "MSGuenter-Trip-01"
	},
	"Datastreams": [
		{
			"@iot.id": "MSGuenter-AirTemp",
			"name": "Air Temperature",
			"description": "This Datastreams measures Air Temperature",
			"unitOfMeasurement": {
				"name": "degree Celsius",
				"symbol": "°C",
				"definition": "http://unitsofmeasure.org/ucum.html#para-30"
			},
			"observationType": "http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_Measurement",
			"observedArea": {
				"type": "Polygon",
				"coordinates": [
					[
						[
							100,
							0
						],
						[
							101,
							0
						],
						[
							101,
							1
						],
						[
							100,
							1
						],
						[
							100,
							0
						]
					]
				]
			},
			"phenomenonTime": "2009-01-11T16:22:25.00Z/2011-08-21T08:32:10.00Z",
			"ObservedProperty": {
				"@iot.id": "AirTemp",
				"name": "Air Temperature",
				"definition": "http://sweet.jpl.nasa.gov/ontology/property.owl#AirTemperature",
				"description": "The air temperature is the temperature of the air."
			},
			"Sensor": {
				"@iot.id": "DS18B20",
				"name": "Dallas DS18B20",
				"description": "DS18B20 is an air temperature sensor",
				"encodingType": "application/pdf",
				"metadata": "http://datasheets.maxim-ic.com/en/ds/DS18B20.pdf"
			}
		}
	]
}
PATCH "/Things(MSGuenther)"
	"properties": {
		"updateFOI": "MSGuenter-Trip-02"
	}
MQTT Publish "Locations"
{
	"name": "Location of MS Guenther",
	"description": "Somewhere in the ocean",
	"encodingType": "application/vnd.geo+json",
	"location": {
		"type": "Feature",
		"geometry": {
			"type": "Point",
			"coordinates": [
				10,
				10
			]
		}
	},
	"Things": [
		{
			"@iot.id": "MSGuenther"
		}	
	]
}
MQTT Publish "Observations"
{
	"phenomenonTime": "2013-06-25T03:42:02-06:00",
	"result": 70.5,
	"parameters": [
		{
			"name": "http://www.opengis.net/def/param-name/OGC-OM/2.0/samplingGeometry",
			"value": {"type": "Point","coordinates": [10,10]}
		}		
	],
	"Datastream": {
		"@iot.id": "MSGuenter-AirTemp"
	},
	"FeatureOfInterest": {
		"@iot.id": "MSGuenter-Trip-01"
	}
}