istsos-javascript-core

1.0.3 • Public • Published

IstSOS JavaScript Core Library


1. Introduction

IstSOS JavaScript core library is a lightweight easy-to-use javascript library that exposes commincation with the IstSOS WA REST interface.

Developers can use this library to acquire sensor observation data from IstSOS server and publish it on the Web.

2. Installation

Install the library using npm:


npm install istsos-javascript-core --save

Or clone the repository:


git clone https://github.com/istSOS/javascript-core.git

3. Example

Create container object for all servers

var container = new istsos.ServerContainer();

Create istsos.Server object providing appropariate URL and desired name

var server = new istsos.Server({
   name: 'test',
   url: 'http://istsos.org/istsos/'
});

Create istsos.Database object with appropriate database connection parameters

var db = new istsos.Database({
   dbname: 'istsos',
   host: 'localhost',
   user: 'postgres',
   password: 'postgres',
   port: 5432
});

Create istsos.Service object with appropariate name[string], server and database objects

var service = new istsos.Service({
   name: 'demo',
   server: server,
   opt_db: db
});

Create istsos.Offering object with appropriate name, service and activity properties

var offering = new istsos.Offering({
   offeringName: 'temporary',
   service: service,
   active: true
});

Create istsos.Procedure object, representing the sensor object to be used for getting the observation data

var procedure = new istsos.Procedure({
   name: 'BELLINZONA',
   service: service,
   foi_name: 'test',
   epsg: 3857,
   x: 55,
   y: 55,
   z: 55,
   outputs: [],
   sensorType: 'insitu-fixed-point'
});

Create istsos.ObservedProperty objects for the purpose of getting temperature and rainfall observations

var temperature = new istsos.ObservedProperty({
   observedName: 'air-temperature',
   definitionUrn: 'urn:ogc:def:parameter:x-istsos:1.0:meteo:air:temperature',
   service: service,
   constraintType: 'between',
   value: [0, 300],
});

var rainfall = new istsos.ObservedProperty({
   observedName: 'air-rainfall',
   definitionUrn: 'urn:ogc:def:parameter:x-istsos:1.0:meteo:air:rainfall',
   service: service,
   constraintType: 'between',
   value: [0, 50],
});

Create istsos.Date objects, representing the observation data interval

var beginTime = new istsos.Date({
   year: 2014,
   month: 5,
   day: 27,
   hours: 0,
   minutes: 0,
   seconds: 0,
   gmt: 2
});

var endTime = new istsos.Date({
   year: 2014,
   month: 5,
   day: 31,
   hours: 0,
   minutes: 0,
   seconds: 0,
   gmt: 2
});

Perform get observation request

var observations = service.getObservations({
   offering: offering,
   procedures: [procedure],
   observedProperties: [temperature, rainfall]
   begin: beginTime,
   end: endTime
});

Two ways of handling the response:

/* PROMISE WAY */
observations.then(function(result) {    console.log(result)
});

/* EVENT LISTENER WAY */ service.on('GETOBSERVATIONS', function(result) {    console.log(result) });


Readme

Keywords

none

Package Sidebar

Install

npm i istsos-javascript-core

Weekly Downloads

0

Version

1.0.3

License

MIT

Last publish

Collaborators

  • luka-g