# SosGetFois

SosGetResultJson is a specific DataSource to parse FOIs response from GetFeatureOfInterest request.

The class inherits directly from DataSource.

# Parser

The parser parses the XML response from the server. The response is normalized according to the specifications of the OGC GetFeatureOfInterestResponse standard.

The parser will return an array of featureMember.

From Server:

The request looks like an XML response of this type:

<?xml version='1.0' encoding='UTF-8'?>
<sos:GetFeatureOfInterestResponse xmlns:sos="http://www.opengis.net/sos/2.0"
                                  xmlns:gml="http://www.opengis.net/gml/3.2"
                                  xmlns:xlink="http://www.w3.org/1999/xlink"
                                  xmlns:sams="http://www.opengis.net/samplingSpatial/2.0"
                                  xmlns:sf="http://www.opengis.net/sampling/2.0">
    <sos:featureMember>
        <sams:SF_SpatialSamplingFeature gml:id="01200000">
            <gml:description>TENMILE RIVER NEAR GAYLORDSVILLE, CT</gml:description>
            <gml:identifier codeSpace="uid">urn:usgs:water:site:01200000</gml:identifier>
            <gml:name>USGS Water Site #01200000</gml:name>
            <sf:type xlink:href="http://www.opengis.net/def/samplingFeatureType/OGC-OM/2.0/SF_SamplingPoint"/>
            <sams:shape>
                <gml:Point gml:id="G1" srsName="http://www.opengis.net/def/crs/EPSG/0/5498" srsDimension="3">
                    <gml:pos>41.65876389 -73.5286833 304.0</gml:pos>
                </gml:Point>
            </sams:shape>
            <sf:sampledFeature xlink:href="urn:usgs:water:region:NY"/>
        </sams:SF_SpatialSamplingFeature>
    </sos:featureMember>
</sos:GetFeatureOfInterestResponse>

After parsing:

[{
  "type": "SF_SpatialSamplingFeature",
  "id": "01200000",
  "description": "TENMILE RIVER NEAR GAYLORDSVILLE, CT",
  "identifier": "urn:usgs:water:site:01200000",
  "name": "USGS Water Site #01200000",
  "shape": {
    "type": "Point",
    "id": "G1",
    "srsName": "http://www.opengis.net/def/crs/EPSG/0/5498",
    "srsDimension": "3",
    "pos": "41.65876389 -73.5286833 304.0"
  },
  "sampledFeature": {
    "href": "urn:usgs:water:region:NY"
  }
}]
API Reference

# Example

import CesiumView from 'osh-js/core/ui/view/map/CesiumView.js';
import SosGetFois from 'osh-js/core/datasource/SosGetFois';
import {
    Cartesian3
} from 'cesium';
import PointMarkerLayer from 'osh-js/core/ui/layer/PointMarkerLayer';

window.CESIUM_BASE_URL = './';

// create data source for Fois
let sosGetFois = new SosGetFois('fois', {
    protocol: 'http',
    service: 'SOS',
    endpointUrl: 'sensiasoft.net:8181/sensorhub/sos',
    batchSize: 50,
    procedureId: 'urn:usgs:water:network'
});

// create Cesium view
let cesiumView = new CesiumView({
    container: "cesium-container",
    autoZoomOnFirstMarker: true,
    layers: [
        new PointMarkerLayer({
            dataSourceId: sosGetFois.id,
            getLocation: (f) => {
                let pos = f.shape.pos.split(" ");
                return {
                    x: parseFloat(pos[1]),
                    y: parseFloat(pos[0])
                }
            },
            getDescription:(f) => {
                let pos = f.shape.pos.split(" ");
                return  f.description + "<br/>" +
                "Latitude: " + pos[0] + "°<br/>" +
                "Longitude: " + pos[1] + "°"
            },
            getMarkerId:(f) => f.id,
            icon: 'images/marker-icon.png',
            iconAnchor: [12, 41],
            getLabel: (f) =>  f.id,
            labelColor: '#ffffff',
            labelSize: 28,
            labelOffset: [0, 10],
        })
    ]
});

cesiumView.viewer.camera.flyTo({
    destination : new Cartesian3(1488411.6251324203,-5268449.4730327735, 4043539.7085447963),
    orientation: {
        direction : new  Cartesian3(-0.3390959920603357,0.8747561701406432,0.3461438298879394),
        up : new Cartesian3(0.040665571671700686, -0.3539702229711658, 0.9343721916508201),
    }
});

sosGetFois.connect();