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

ogr2ogr

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ogr2ogr - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

.github/workflows/main.yml

2

examples/exec.js
const ogr2ogr = require('../')
ogr2ogr('../test/samples/sample.shp.zip').exec(function(er, data) {
ogr2ogr('../test/samples/sample.shp.zip').exec(function (er, data) {
if (er) console.error(er)
console.log(data)
})

@@ -19,5 +19,5 @@ const ogr2ogr = require('../')

ogr.exec(function(er, data) {
ogr.exec(function (er, data) {
if (er) console.error(er)
console.log(data) // reprojected geojson data
})

@@ -6,5 +6,2 @@ const ogr2ogr = require('../')

ogr2ogr(url)
.format('kml')
.stream()
.pipe(process.stdout)
ogr2ogr(url).format('kml').stream().pipe(process.stdout)

@@ -6,5 +6,2 @@ const ogr2ogr = require('../')

ogr2ogr(url)
.format('map')
.stream()
.pipe(process.stdout)
ogr2ogr(url).format('map').stream().pipe(process.stdout)

@@ -6,5 +6,5 @@ const ogr2ogr = require('../')

ogr2ogr(rs, 'ESRI Shapefile').exec(function(er, data) {
ogr2ogr(rs, 'ESRI Shapefile').exec(function (er, data) {
if (er) console.error(er)
console.log(data) // geojson data
})

@@ -8,3 +8,3 @@ const path = require('path')

.options(['--config', 'SHAPE_RESTORE_SHX', 'TRUE'])
.exec(function(er, data) {
.exec(function (er, data) {
if (er) console.error(er)

@@ -11,0 +11,0 @@ console.log(data)

@@ -7,3 +7,3 @@ const path = require('path')

.options(['--config', 'CPL_DEBUG', 'ON'])
.onStderr(function(data) {
.onStderr(function (data) {
console.log(data)

@@ -10,0 +10,0 @@ })

@@ -36,3 +36,3 @@ const path = require('path')

this._onStderr = function() {}
this._onStderr = function () {}
this._driver = {}

@@ -44,3 +44,3 @@ this._args = []

this._testClean = function() {} // testing
this._testClean = function () {} // testing
}

@@ -50,3 +50,3 @@

Ogr2ogr.prototype.format = function(fmt) {
Ogr2ogr.prototype.format = function (fmt) {
let driver = util.getDriver(fmt)

@@ -58,3 +58,3 @@ this._driver = driver

Ogr2ogr.prototype.options = function(arr) {
Ogr2ogr.prototype.options = function (arr) {
this._options = arr

@@ -64,3 +64,3 @@ return this

Ogr2ogr.prototype.env = function(obj) {
Ogr2ogr.prototype.env = function (obj) {
this._env = obj

@@ -70,3 +70,3 @@ return this

Ogr2ogr.prototype.destination = function(str) {
Ogr2ogr.prototype.destination = function (str) {
this._destination = str

@@ -76,3 +76,3 @@ return this

Ogr2ogr.prototype.skipfailures = function() {
Ogr2ogr.prototype.skipfailures = function () {
this._skipfailures = true

@@ -82,3 +82,3 @@ return this

Ogr2ogr.prototype.timeout = function(ms) {
Ogr2ogr.prototype.timeout = function (ms) {
this._timeout = ms

@@ -88,3 +88,3 @@ return this

Ogr2ogr.prototype.project = function(dest, src) {
Ogr2ogr.prototype.project = function (dest, src) {
this._targetSrs = dest

@@ -95,3 +95,3 @@ if (src) this._sourceSrs = src

Ogr2ogr.prototype.onStderr = function(fn) {
Ogr2ogr.prototype.onStderr = function (fn) {
this._onStderr = fn

@@ -101,3 +101,3 @@ return this

Ogr2ogr.prototype.exec = function(cb) {
Ogr2ogr.prototype.exec = function (cb) {
let ogr2ogr = this

@@ -108,7 +108,7 @@ let buf = []

this.stream()
.on('data', function(chunk) {
.on('data', function (chunk) {
buf.push(chunk)
})
.on('error', one)
.on('close', function() {
.on('close', function () {
let data = Buffer.concat(buf)

@@ -126,7 +126,7 @@ if (ogr2ogr._format == 'GeoJSON') {

Ogr2ogr.prototype.stream = function() {
Ogr2ogr.prototype.stream = function () {
return this._run()
}
Ogr2ogr.prototype.promise = function() {
Ogr2ogr.prototype.promise = function () {
let ogr2ogr = this

@@ -137,7 +137,7 @@ let buf = []

this.stream()
.on('data', function(chunk) {
.on('data', function (chunk) {
buf.push(chunk)
})
.on('error', er => reject(er))
.on('close', function() {
.on('error', (er) => reject(er))
.on('close', function () {
let data = Buffer.concat(buf)

@@ -156,3 +156,3 @@ if (ogr2ogr._format == 'GeoJSON') {

Ogr2ogr.prototype._getOrgInPath = function(cb) {
Ogr2ogr.prototype._getOrgInPath = function (cb) {
let ogr2ogr = this

@@ -184,3 +184,3 @@ let one = util.oneCallback(cb)

if (ogr2ogr._isZipIn) {
zip.extract(fpath, function(er2, fpath2) {
zip.extract(fpath, function (er2, fpath2) {
if (er2) return one(er2)

@@ -190,3 +190,3 @@ zip.findOgrFile(fpath2, one)

} else if (ogr2ogr._isCsvIn) {
csv.makeVrt(fpath, function(err, vrt) {
csv.makeVrt(fpath, function (err, vrt) {
if (vrt && /\.vrt$/.test(vrt)) {

@@ -207,7 +207,7 @@ // always set a source srs

Ogr2ogr.prototype._run = function() {
Ogr2ogr.prototype._run = function () {
let ogr2ogr = this
let ostream = new stream.PassThrough()
this._getOrgInPath(function(er, ogrInPath) {
this._getOrgInPath(function (er, ogrInPath) {
if (er) return wrapUp(er)

@@ -237,3 +237,3 @@

s.stderr.setEncoding('ascii')
s.stderr.on('data', function(chunk) {
s.stderr.on('data', function (chunk) {
ogr2ogr._onStderr(chunk)

@@ -246,7 +246,7 @@ if (/Error/i.test(chunk)) {

})
s.on('error', function(err) {
s.on('error', function (err) {
if (errbuf) errbuf += '\n' + err
else errbuf = err
})
s.on('close', function(code) {
s.on('close', function (code) {
clearTimeout(killTimeout)

@@ -258,3 +258,3 @@ one(

killTimeout = setTimeout(function() {
killTimeout = setTimeout(function () {
if (s._handle) {

@@ -277,2 +277,3 @@ ostream.emit(

ostream.emit('error', er)
ostream.emit('close')
return ogr2ogr._clean()

@@ -287,6 +288,7 @@ }

let zs = zip.createZipStream(ogr2ogr._ogrOutPath)
zs.on('error', function(er2) {
zs.on('error', function (er2) {
ostream.emit('error', er2)
ostream.emit('close')
})
zs.on('end', function() {
zs.on('end', function () {
ostream.emit('close')

@@ -301,3 +303,3 @@ ogr2ogr._clean()

Ogr2ogr.prototype._clean = function() {
Ogr2ogr.prototype._clean = function () {
let all = util.allCallback(this._testClean)

@@ -304,0 +306,0 @@

@@ -14,7 +14,7 @@ const fs = require('fs')

let extractHead = function(fpath, cb) {
let extractHead = function (fpath, cb) {
let sf = fs.createReadStream(fpath)
let one = util.oneCallback(cb)
let data = ''
sf.on('data', function(chunk) {
sf.on('data', function (chunk) {
data += chunk

@@ -30,4 +30,4 @@ if (data) {

'end',
util.oneCallback(function() {
CSV.forEach(data.split(/(?:\n|\r\n|\r)/g).shift(), function(head) {
util.oneCallback(function () {
CSV.forEach(data.split(/(?:\n|\r\n|\r)/g).shift(), function (head) {
one(null, head)

@@ -41,8 +41,8 @@ })

exports.makeVrt = function(fpath, cb) {
extractHead(fpath, function(er, headers) {
exports.makeVrt = function (fpath, cb) {
extractHead(fpath, function (er, headers) {
if (er) return cb(er)
let geo = {}
headers.forEach(function(header) {
headers.forEach(function (header) {
let ht = String(header).trim()

@@ -76,3 +76,3 @@ switch (true) {

let vrtPath = util.genTmpPath() + '.vrt'
return fs.writeFile(vrtPath, vrtData, function(er2) {
return fs.writeFile(vrtPath, vrtData, function (er2) {
cb(er2, vrtPath)

@@ -79,0 +79,0 @@ })

@@ -9,3 +9,3 @@ const path = require('path')

exports.tmpl = function(tmpl, data) {
exports.tmpl = function (tmpl, data) {
for (let label in data) {

@@ -18,17 +18,17 @@ tmpl = tmpl.replace('{{' + label + '}}', data[label])

let genInc = Date.now()
let genTmpPath = (exports.genTmpPath = function() {
let genTmpPath = (exports.genTmpPath = function () {
return path.join(tmpdir, 'ogr_' + (genInc++).toString(14))
})
exports.rmParentDir = function(fpath, cb) {
exports.rmParentDir = function (fpath, cb) {
rimraf(path.dirname(fpath), cb)
}
exports.rmDir = function(dpath, cb) {
exports.rmDir = function (dpath, cb) {
rimraf(dpath, cb)
}
exports.rmFile = function(fpath, cb) {
exports.rmFile = function (fpath, cb) {
fs.unlink(fpath, cb)
}
exports.getDriver = function(fmt) {
exports.getDriver = function (fmt) {
for (let i = 0; i < drivers.length; i++) {

@@ -41,3 +41,3 @@ if (drivers[i].format == fmt || drivers[i].aliases.indexOf(fmt) > -1)

exports.writeStream = function(ins, ext, cb) {
exports.writeStream = function (ins, ext, cb) {
let fpath = genTmpPath() + '.' + ext

@@ -50,3 +50,3 @@ let ws = fs.createWriteStream(fpath)

.on('error', one)
.on('finish', function() {
.on('finish', function () {
one(null, fpath)

@@ -56,5 +56,5 @@ })

exports.writeGeoJSON = function(obj, cb) {
exports.writeGeoJSON = function (obj, cb) {
let fpath = genTmpPath() + '.json'
fs.writeFile(fpath, JSON.stringify(obj), function(er) {
fs.writeFile(fpath, JSON.stringify(obj), function (er) {
cb(er, fpath)

@@ -64,5 +64,5 @@ })

exports.oneCallback = function(cb) {
exports.oneCallback = function (cb) {
let called = false
return function(er, data) {
return function (er, data) {
if (called) return

@@ -74,3 +74,3 @@ called = true

exports.allCallback = function(cb) {
exports.allCallback = function (cb) {
let one = exports.oneCallback(cb)

@@ -80,9 +80,9 @@ let expect = 0

setImmediate(function() {
setImmediate(function () {
if (expect == 0) one(null, total)
})
return function() {
return function () {
expect++, total++
return function(er) {
return function (er) {
if (er) return one(er)

@@ -89,0 +89,0 @@ if (--expect == 0) one(null, total)

@@ -8,3 +8,3 @@ const path = require('path')

exports.extract = function(fpath, cb) {
exports.extract = function (fpath, cb) {
let zip = new DecompressZip(fpath)

@@ -15,3 +15,3 @@ let zipPath = util.genTmpPath()

zip
.on('extract', function() {
.on('extract', function () {
one(null, zipPath)

@@ -25,15 +25,15 @@ })

let macosxRe = /__MACOSX/
exports.findOgrFile = function(dpath, cb) {
exports.findOgrFile = function (dpath, cb) {
let finder = findit(dpath)
let found
finder.on('file', function(file) {
finder.on('file', function (file) {
if (!macosxRe.test(file) && validOgrRe.test(path.extname(file)))
found = file
})
finder.on('error', function(er) {
finder.on('error', function (er) {
cb(er)
finder.stop() // prevent multiple callbacks, stop at first error
})
finder.on('end', function() {
finder.on('end', function () {
if (!found) return cb(new Error('No valid files found'))

@@ -44,13 +44,13 @@ cb(null, found)

exports.createZipStream = function(dpath) {
exports.createZipStream = function (dpath) {
let zs = archiver('zip')
fs.readdir(dpath, function(er, files) {
fs.readdir(dpath, function (er, files) {
if (er) return zs.emit('error', er)
files.forEach(function(file) {
files.forEach(function (file) {
let f = fs.createReadStream(path.join(dpath, file))
zs.append(f, {name: file})
})
zs.finalize(function(er2) {
zs.finalize(function (er2) {
if (er2) zs.emit('error', er2)

@@ -57,0 +57,0 @@ })

{
"name": "ogr2ogr",
"version": "2.0.0",
"version": "2.0.1",
"description": "ogr2ogr wrapper w/ multiple format support",

@@ -24,3 +24,3 @@ "keywords": [

"dependencies": {
"archiver": "^3.1.1",
"archiver": "^4.0.1",
"comma-separated-values": "^3.6.0",

@@ -32,7 +32,8 @@ "decompress-zip": "^0.2.2",

"devDependencies": {
"eslint": "^6.8.0",
"eslint": "^7.4.0",
"eslint-config-prettier": "^6.10.0",
"eslint-plugin-prettier": "^3.1.2",
"prettier": "^1.19.1",
"tape": "^4.13.0"
"nyc": "^15.1.0",
"prettier": "^2.0.5",
"tape": "^5.0.1"
},

@@ -39,0 +40,0 @@ "engines": {

@@ -1,8 +0,8 @@

[![Build Status](https://jenkins.adc4gis.com/buildStatus/icon?job=ogr2ogr)](https://jenkins.adc4gis.com/job/ogr2ogr/) [![NPM](https://img.shields.io/npm/v/ogr2ogr.svg)](https://npmjs.com/package/ogr2ogr) ![NPM Downloads](https://img.shields.io/npm/dt/ogr2ogr.svg)
![Build Status](https://github.com/wavded/ogr2ogr/workflows/build/badge.svg?branch=master) [![NPM](https://img.shields.io/npm/v/ogr2ogr.svg)](https://npmjs.com/package/ogr2ogr) ![NPM Downloads](https://img.shields.io/npm/dt/ogr2ogr.svg)
ogr2ogr enables spatial file conversion and reprojection of spatial data through the use of ogr2ogr (gdal) tool
ogr2ogr enables file conversion and re-projection of spatial data through the use of ogr2ogr (gdal) tool
# Requirements
ogr2ogr requires the command line tool _ogr2ogr_ - [gdal install page](http://trac.osgeo.org/gdal/wiki/DownloadingGdalBinaries). It is recommended to use the latest version.
ogr2ogr requires the command line tool _ogr2ogr_ - [gdal install page](http://trac.osgeo.org/gdal/wiki/DownloadingGdalBinaries). We recommended using the latest stable version.

@@ -23,3 +23,3 @@ # Installation

ogr.exec(function(er, data) {
ogr.exec(function (er, data) {
if (er) console.error(er)

@@ -88,3 +88,3 @@ console.log(data)

.options(['--config', 'CPL_DEBUG', 'ON'])
.onStderr(function(data) {
.onStderr(function (data) {
console.log(data)

@@ -91,0 +91,0 @@ })

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