JSPM

geocodejson-stream

0.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q35084F
  • License MIT

Implementation of the GEOCODEJSON [spec](https://github.com/dianashk/geocodejson-spec)

Package Exports

  • geocodejson-stream

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (geocodejson-stream) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

geocodejson-stream

Stream-based utility for consuming and generating GEOJSON files specifically for geocoding needs. see proposed geocodejson spec

NPM

install

npm install geocodejson-stream

usage

stringify(geocoding)

geojson feature objects --> geocodejson-stream.stringify(geocoding) --> text

var fs = require('fs');
var geocodejson = require('geocodejson-stream');

// provide geocoding properties as the first parameter to stringify
var geoStream = GeocodeJsonStream.stringify({ version: '0.0.3', license: 'ODbL' });

geoStream.pipe(fs.createWriteStream('results.geojson');

geoStream.write({ type: 'Feature', properties: { name: 'USA' }, geometry: {...} });
geoStream.write({ type: 'Feature', properties: { name: 'Canada' }, geometry: {...} });

geoStream.end();

will result in...

{
  "type": "FeatureCollection",
  "geocoding": {
    "version": "0.0.3",
    "license": "ODbL"
  },
  "features": [
    { "type": "Feature", "properties": { "name": "USA" }, "geometry": {...} },
    { "type": "Feature", "properties": { "name": "Canada" }, "geometry": {...} }
  ]
}
parse

text --> geocodejson-stream.parse --> geojson feature objects

var fs = require('fs');
var through = require('through2');
var geocodejson = require('geocodejson-stream');

fs.createReadStream('results.geojson') // file contents described in stringify documentation
  .pipe(GeocodeJsonStream.parseGeocoding())
  .pipe(through.obj(function (data, enc, next) {
    console.log(data.properties);
    next();
  }));

will result in...

{ "type": "Feature", "properties": { "name": "USA" }, "geometry": {...} },
{ "type": "Feature", "properties": { "name": "Canada" }, "geometry": {...} }
parseGeocoding

text --> geocodejson-stream.parseGeocoding --> geocoding object

var fs = require('fs');
var through = require('through2');
var geocodejson = require('geocodejson-stream');

fs.createReadStream('results.geojson') // file contents described in stringify documentation
  .pipe(GeocodeJsonStream.parseGeocoding())
  .pipe(through.obj(function (data, enc, next) {
    console.log(data);
    next();
  }));

will result in...

{
  "version": "0.0.3",
  "license": "ODbL"
}

test Build Status

$ npm test

contribute

  • yes please

license

MIT (see LICENSE.md)