fsai-data-sdk
v1.0.2
Published
Foresight Data Portal for Javascript
Downloads
4
Maintainers
Readme
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
SDK for Javascript: https://github.com/ForesightAI/fsai_data_sdk_python
Rest API: https://data.foresight.ai/docs/public/api/