# SosGetResult
SosGetResult is the generic DataSource to parse JSON data from SOS.
The class inherits directly from TimeSeriesDataSource.
There are not specific properties for this DataSource.
# Parser
Depending on the format, the input could be JSON, binary, xml, etc. data. Whatever the input format, the datasource will format the data in a homogeneous way to be read in the same way by Layers and Views.
# Examples: JSON format
For example, for the application/json:
From Server:
{
"time": "2015-02-16T07:58:52Z",
"location": {
"lat": 43.61759959,
"lon": 1.42376351,
"alt": 195.0
}
}
After parsing:
{
timeStamp: 1424073532000,
data: {
"location": {
"lat": 43.61759959,
"lon": 1.42376351,
"alt": 195.0
}
}
}
API Reference
# Example
import SosGetResult from 'osh-js/core/datasource/sos/SosGetResult.datasource.js';
import {EventType} from 'osh-js/core/event/EventType';
import {Mode} from "osh-js/core/datasource/Mode";
import DataSynchronizer from "osh-js/core/timesync/DataSynchronizer";
const platformLocationDataSource = new SosGetResult('android-GPS', {
endpointUrl: 'sensiasoft.net/sensorhub/sos',
offeringID: 'urn:mysos:solo:nav2',
observedProperty: 'http://www.opengis.net/def/property/OGC/0/PlatformLocation',
startTime: '2015-12-19T21:04:29.231Z',
endTime: '2015-12-19T21:09:19.675Z',
mode: Mode.REPLAY,
tls: true
});
const dataSynchronizer = new DataSynchronizer({
replaySpeed: 3.0,
startTime: '2015-12-19T21:04:29.231Z',
endTime: '2015-12-19T21:09:19.675Z',
dataSources: [platformLocationDataSource]
});
const locationDivElement = document.getElementById('datasource-gps');
platformLocationDataSource.subscribe((message) => locationDivElement.innerText = JSON.stringify(message, null, 2),
[EventType.DATA,EventType.TIME_CHANGED, EventType.STATUS])
dataSynchronizer.connect();
# Examples: Binary format
The underlaying stream is a video binary stream.
The first 8 bytes is the timestamp in millis.
The next 4 bytes define the frame length.
The next bytes are corresponding to a full NAL unit.
|--- 8 bytes timestamp ---|--- 4 bytes frame length ---|--- NAL UNIT ---|
From Server:
[..binary..data..]
After parsing:
{
"timeStamp": 1450559070000,
"data": {
"frameData": {
"data": [..binary..NAL_UNIT...],
"compression": "h264",
},
"roll": 90
}
}
# Example
import SosGetResult from 'osh-js/core/datasource/sos/SosGetResult.datasource.js';
import {EventType} from 'osh-js/core/event/EventType';
import DataSynchronizer from 'osh-js/core/timesync/DataSynchronizer';
import {Mode} from 'osh-js/core/datasource/Mode';
const videoDataSource = new SosGetResult("drone-Video", {
endpointUrl: 'sensiasoft.net/sensorhub/sos',
offeringID: 'urn:mysos:solo:video2',
observedProperty: 'http://sensorml.com/ont/swe/property/VideoFrame',
startTime: '2015-12-19T21:04:29.231Z',
endTime: '2015-12-19T21:09:19.675Z',
mode: Mode.REPLAY,
tls: true
});
const dataSynchronizer = new DataSynchronizer({
replaySpeed: 2,
startTime: '2015-12-19T21:04:29.231Z',
endTime: '2015-12-19T21:09:19.675Z',
dataSources: [videoDataSource]
});
const videoDivElement = document.getElementById('datasource-video');
videoDataSource.subscribe((message) => {
let dataEvent;
for(let i=0;i < message.values.length;i++) {
dataEvent = message.values[i];
dataEvent.data.videoFrame.data = message.values[i].data.videoFrame.data.slice(0,10);
videoDivElement.innerText = JSON.stringify( [dataEvent], null, 2);
}
}, [EventType.DATA])
dataSynchronizer.connect()