fsai-data-sdk

1.0.2 • Public • Published

Foresight AI Data SDK for Javascript

Installation

npm install fsai-data-sdk

Usage

Get Data

Get data at a specific location

    const { DatasetService } = require('fsai-data-sdk');
    
    const datasetService = new DatasetService({
      apiKey: process.env.API_KEY, secret: process.env.SECRET,
    });
    const datasets = await datasetService.getDataAt({ lng: -122.1598309, lat: 37.4358347, radius: 2000 }, ['SEMANTIC_2D', 'DYNAMIC_OBJECTS']);
    console.log(datasets);
    const exampleDataset = datasets[0];
    console.log(exampleDataset);
    const exampleSemantic2D = await exampleDataset.layers.semantic2D.get();
    console.log(exampleSemantic2D);
    const exampleDynamicObject = await exampleDataset.layers.dynamicObjects[0].get();
    console.log(exampleDynamicObject);
    

The getDataAt function returns a list of Dataset. Each Dataset object contains the data layers:

  • semantic2d: a DataGetter object to get the semantic 2d json data of the area.
  • dynamicObjects: a list of DataGetter object to get the dynamic object data.

DataGetter class

Because the data layers are normally large, they can't be returned directly in the getting data calls. The SDK wrap the data layer in the DataGetter class which provides a get function to fetch the data and return the actual data of the layer.

See also

Package Sidebar

Install

npm i fsai-data-sdk

Weekly Downloads

9

Version

1.0.2

License

MIT

Unpacked Size

32.9 kB

Total Files

20

Last publish

Collaborators

  • phandinhloc