geojson-stream-whatwg

1.0.1 • Public • Published

geojson-stream-whatwg

Stream features into and out of GeoJSON objects and Feature Collections. Little more than @streamparser/json with pre-filled settings.

This package is a simple rewrite of Tom MacWrights geojson-stream build on the Streams API.

Installation

npm install geojson-stream-whatwg

API

geojsonStream.stringify()

Returns a transform stream that accepts GeoJSON Feature objects and emits a stringified FeatureCollection.

geojsonStream.parse()

Returns a transform stream that accepts a GeoJSON FeatureCollection as a stream and emits Feature objects.

Example

const response = await fetch('https://example.com/buildings.geojson');
const readableStream = response.body
  .pipeThrough(new TextDecoderStream())
  .pipeThrough(geojsonStream.parse())

  for await (const feature of readStream) {
    console.log(feature)
  }  

Please consult the test file located at test/basic.mjs for more examples.

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i geojson-stream-whatwg

Weekly Downloads

5

Version

1.0.1

License

MIT

Unpacked Size

129 kB

Total Files

12

Last publish

Collaborators

  • chrispahm