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

reproject

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reproject - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

test.json

52

cli.js
#!/usr/bin/env node
var geojsonStream = require('geojson-stream'),
es = require('event-stream'),
reproject = require('./'),

@@ -37,16 +38,26 @@ proj4 = require('proj4'),

if ((fromCrs && toCrs) || (!argv.from && !argv.to)) {
((argv._[0] && fs.createReadStream(argv._[0])) || process.stdin).pipe(geojsonStream.parse())
.on('header', openData)
.on('footer', openData)
.on('data', openData)
.on('error', function (err) {
console.error(err);
});
var inputStream = ((argv._[0] && fs.createReadStream(argv._[0])) || process.stdin)
var parser = geojsonStream.parse()
.on('header', handleHeader)
var transformStream = es.mapSync(transform)
var outputStream = geojsonStream.stringify()
inputStream.pipe(parser)
parser.pipe(transformStream)
transformStream.pipe(outputStream)
outputStream.pipe(process.stdout)
}
}
function openData(geojson) {
// geojson-stream will break a FeaturesCollection's features into chunks that are fed to openData;
// single geometries or GeometryCollection will be fed to as "header", so
// we have to handle them here.
function handleHeader(geojson) {
if (geojson && geojson.type !== 'FeatureCollection') {
// If top type isn't FeatureCollection, just transform the whole object in one pass and be done with it;
// if we don't do this, geojson-stream will still output a FeatureCollection header, so the output
// GeoJSON's structure will not match the input's.
process.stdout.write(JSON.stringify(transform(geojson)));
process.exit(0);
}
}
function transform(geojson) {
if (geojson) {

@@ -62,13 +73,9 @@ var isGeomCol = geojson.type === 'GeometryCollection' && geojson.geometries;

geojson = reproject.reproject(geojson, fromCrs, toCrs, crss);
return reproject.reproject(geojson, fromCrs, toCrs, crss);
}
}
outputJson(geojson);
return geojson
}
function outputJson(json) {
console.log(JSON.stringify(json, null, 2));
}
function loadJson(f) {

@@ -98,2 +105,13 @@ var data;

if (!crss[crsName]) {
var proj;
try {
proj = proj4(crsName);
} catch (e) {
// Ok, go on with proj unset.
}
if (proj) {
return cb(proj);
}
if (useSpatialReference) {

@@ -100,0 +118,0 @@ var crsPath = crsName.toLowerCase().replace(':', '/');

@@ -0,0 +0,0 @@ {

@@ -0,0 +0,0 @@ 'use strict';

{
"name": "reproject",
"version": "1.2.1",
"version": "1.2.2",
"description": "Reproject GeoJSON from one projection/CRS to another",

@@ -23,2 +23,3 @@ "repository": "git@github.com:perliedman/reproject.git",

"concat-stream": "^1.5.1",
"event-stream": "^3.3.4",
"geojson-stream": "0.0.1",

@@ -25,0 +26,0 @@ "minimist": "^1.2.0",

@@ -0,0 +0,0 @@ reproject [![Build status](https://travis-ci.org/perliedman/reproject.png)](https://travis-ci.org/perliedman/reproject) [![NPM version](https://badge.fury.io/js/reproject.png)](http://badge.fury.io/js/reproject)

@@ -0,0 +0,0 @@ 'use strict';

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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