@koopjs/koop-provider-hub-search-ogc
v1.0.1
Published
A Koop provider plugin to use the Hub Search OGC API as a data source
Downloads
81
Keywords
Readme
Koop Provider Hub Search OGC
This is a Koop provider that extracts datasets from the ArcGIS Hub Search OGC API.
Use - Streaming All Datasets
This provider plugin currently only supports streaming ALL datasets matching a given search query.
Define Search Parameters
To perform a search from an output plugin, attach onto the response.
req.res.locals.siteIdentifier = 'https://my-site.hub.arcgis.com'
Pull the Readable Stream
Then pass the request object to this.model.pullStream
.
const docStream = await this.model.pullStream(req);
Full Example
What you have now is a Node.js Readable
stream. You can pipe the datasets from the readable through a transform stream in order to format them into some other type of output before sending them back to the browser by piping them to the Express.js response. The following simple example also uses the through2
library to conveniently define a transform stream.
async handleRequest (req, res) {
req.res.locals.siteIdentifier = 'my-site.hub.arcgis.com'
const docStream = await this.model.pullStream(req);
docStream
.pipe(through2.obj(function (dataset, enc, callback) {
const transformed = someTranformFunc(dataset);
// the Express.js "res" Writable only accepts strings or Buffers
this.push(JSON.stringify(transformed));
callback();
}))
.pipe(res);
}
Develop
# clone and install dependencies
git clone https://github.com/koopjs/koop-provider-hub-search-ogc
cd koop-provider-hub-search-ogc
npm i
# starts the example Koop app found in ./example-app.
npm run dev
Test
Run the npm t
commmand to spin up the automated tests.