Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

geocodejson-stream

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

geocodejson-stream

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

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

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)

FAQs

Package last updated on 10 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc