diff -Nru node-srs-1.2.0+~2.5.0/debian/changelog node-srs-1.2.0+~2.6.2/debian/changelog --- node-srs-1.2.0+~2.5.0/debian/changelog 2020-11-12 21:33:26.000000000 +0000 +++ node-srs-1.2.0+~2.6.2/debian/changelog 2020-12-15 12:06:22.000000000 +0000 @@ -1,3 +1,20 @@ +node-srs (1.2.0+~2.6.2-1) unstable; urgency=medium + + * Team upload + * New upstream version 1.2.0+~2.6.2 + + -- Xavier Guimard Tue, 15 Dec 2020 13:06:22 +0100 + +node-srs (1.2.0+~2.6.0-1) unstable; urgency=medium + + * Team upload + * Declare compliance with policy 4.5.1 + * Add ctype=nodejs to component(s) + * New upstream version 1.2.0+~2.6.0 + * Refresh patches + + -- Xavier Guimard Mon, 07 Dec 2020 18:23:37 +0100 + node-srs (1.2.0+~2.5.0-1) unstable; urgency=medium * Team upload diff -Nru node-srs-1.2.0+~2.5.0/debian/control node-srs-1.2.0+~2.6.2/debian/control --- node-srs-1.2.0+~2.5.0/debian/control 2020-10-13 10:18:54.000000000 +0000 +++ node-srs-1.2.0+~2.6.2/debian/control 2020-12-15 11:44:40.000000000 +0000 @@ -12,7 +12,7 @@ , mocha , node-gyp , node-nan -Standards-Version: 4.5.0 +Standards-Version: 4.5.1 Vcs-Browser: https://salsa.debian.org/js-team/node-srs Vcs-Git: https://salsa.debian.org/js-team/node-srs.git Homepage: https://github.com/mapbox/node-srs diff -Nru node-srs-1.2.0+~2.5.0/debian/patches/series node-srs-1.2.0+~2.6.2/debian/patches/series --- node-srs-1.2.0+~2.5.0/debian/patches/series 2020-10-01 11:10:02.000000000 +0000 +++ node-srs-1.2.0+~2.6.2/debian/patches/series 2020-12-15 12:04:37.000000000 +0000 @@ -1,7 +1,6 @@ no_pre_gyp.patch use-gdal-next.diff update-python.diff -#node12-compat.diff fix-data-paths.diff fix-test.diff spelling-error.diff diff -Nru node-srs-1.2.0+~2.5.0/debian/patches/spelling-error.diff node-srs-1.2.0+~2.6.2/debian/patches/spelling-error.diff --- node-srs-1.2.0+~2.5.0/debian/patches/spelling-error.diff 2020-10-01 11:10:26.000000000 +0000 +++ node-srs-1.2.0+~2.6.2/debian/patches/spelling-error.diff 2020-12-07 17:21:52.000000000 +0000 @@ -5,7 +5,7 @@ --- a/gdal/src/gdal_dataset.cpp +++ b/gdal/src/gdal_dataset.cpp -@@ -851,7 +851,7 @@ +@@ -893,7 +893,7 @@ #if GDAL_VERSION_MAJOR < 2 if (ds->uses_ogr) { @@ -14,7 +14,7 @@ return; } #endif -@@ -892,7 +892,7 @@ +@@ -936,7 +936,7 @@ #if GDAL_VERSION_MAJOR < 2 if (ds->uses_ogr) { diff -Nru node-srs-1.2.0+~2.5.0/debian/watch node-srs-1.2.0+~2.6.2/debian/watch --- node-srs-1.2.0+~2.5.0/debian/watch 2020-11-12 21:23:21.000000000 +0000 +++ node-srs-1.2.0+~2.6.2/debian/watch 2020-12-07 17:20:28.000000000 +0000 @@ -5,6 +5,7 @@ https://github.com/springmeyer/node-srs/tags .*/archive/v?([\d\.]+).tar.gz group opts=\ +ctype=nodejs,\ component=gdal,\ dversionmangle=auto,\ filenamemangle=s/.*\/v?([\d\.-]+)\.tar\.gz/node-gdal-next-$1.tar.gz/ \ diff -Nru node-srs-1.2.0+~2.5.0/gdal/binding.gyp node-srs-1.2.0+~2.6.2/gdal/binding.gyp --- node-srs-1.2.0+~2.5.0/gdal/binding.gyp 2020-11-12 17:08:08.000000000 +0000 +++ node-srs-1.2.0+~2.6.2/gdal/binding.gyp 2020-12-09 07:13:05.000000000 +0000 @@ -41,6 +41,7 @@ "src/gdal_spatial_reference.cpp", "src/gdal_warper.cpp", "src/gdal_algorithms.cpp", + "src/gdal_memfile.cpp", "src/collections/dataset_bands.cpp", "src/collections/dataset_layers.cpp", "src/collections/layer_features.cpp", diff -Nru node-srs-1.2.0+~2.5.0/gdal/.github/FUNDING.yml node-srs-1.2.0+~2.6.2/gdal/.github/FUNDING.yml --- node-srs-1.2.0+~2.5.0/gdal/.github/FUNDING.yml 1970-01-01 00:00:00.000000000 +0000 +++ node-srs-1.2.0+~2.6.2/gdal/.github/FUNDING.yml 2020-12-09 07:13:05.000000000 +0000 @@ -0,0 +1 @@ +github: contra diff -Nru node-srs-1.2.0+~2.5.0/gdal/lib/gdal.js node-srs-1.2.0+~2.6.2/gdal/lib/gdal.js --- node-srs-1.2.0+~2.5.0/gdal/lib/gdal.js 2020-11-12 17:08:08.000000000 +0000 +++ node-srs-1.2.0+~2.6.2/gdal/lib/gdal.js 2020-12-09 07:13:05.000000000 +0000 @@ -511,11 +511,15 @@ * ``` * var dataset = gdal.open('./data.shp');``` * + * @example + * ``` + * var dataset = gdal.open(fs.readFileSync('./data.shp'));``` + * * @for gdal * @throws Error * @method open * @static - * @param {String} path Path to dataset to open + * @param {String|Buffer} path Path to dataset or in-memory Buffer to open * @param {String} [mode="r"] The mode to use to open the file: `"r"`, `"r+"`, or `"w"` * @param {String|Array} [drivers] Driver name, or list of driver names to attempt to use. * @@ -536,6 +540,14 @@ mode, drivers /* , x_size, y_size, n_bands, datatype, options */ ) { + if (filename instanceof Buffer) { + const buffer = filename + arguments[0] = gdal._getMemFileName(filename) + const ds = gdal.open.apply(gdal, arguments) + ds.buffer = buffer + return ds + } + if (typeof drivers === 'string') { drivers = [ drivers ] } else if (drivers && !Array.isArray(drivers)) { @@ -670,12 +682,16 @@ * * @example * ``` + * var dataset = await gdal.openAsync(await fd.readFile('./data.shp'));``` + * + * @example + * ``` * gdal.openAsync('./data.shp', (err, ds) => {...});``` * * @for gdal * @method openAsync * @static - * @param {String} path Path to dataset to open + * @param {String|Buffer} path Path to dataset or in-memory Buffer to open * @param {String} [mode="r"] The mode to use to open the file: `"r"`, `"r+"`, or `"w"` * @param {String|Array} [drivers] Driver name, or list of driver names to attempt to use. * @@ -704,6 +720,19 @@ _datatype, _options ) { + if (filename instanceof Buffer) { + const buffer = filename + try { + // getMemFileName is always synchronous + arguments[0] = gdal._getMemFileName(filename) + } catch (e) { + return Promise.reject(e) + } + return gdal.openAsync.apply(gdal, arguments).then((ds) => { + ds.buffer = buffer + return ds + }) + } if (typeof drivers === 'string') { drivers = [ drivers ] } else if (drivers && !Array.isArray(drivers)) { diff -Nru node-srs-1.2.0+~2.5.0/gdal/package.json node-srs-1.2.0+~2.6.2/gdal/package.json --- node-srs-1.2.0+~2.5.0/gdal/package.json 2020-11-12 17:08:08.000000000 +0000 +++ node-srs-1.2.0+~2.6.2/gdal/package.json 2020-12-09 07:13:05.000000000 +0000 @@ -1,6 +1,6 @@ { "name": "gdal-next", - "version": "2.5.0", + "version": "2.6.2", "description": "Bindings to GDAL (Geospatial Data Abstraction Library) [Fork]", "license": "Apache-2.0", "url": "http://github.com/contra/node-gdal-next", @@ -43,13 +43,13 @@ "lint:fix": "eslint lib test examples --fix", "install": "node-pre-gyp install --fallback-to-build -j max", "postpublish": "npm run tag && npm run publish-yuidoc", - "tag": "git tag -a \"v$npm_package_version\" -m \"tag version $npm_package_version\" && git push && git dontpush --tags", + "tag": "git tag -a \"v$npm_package_version\" -m \"tag version $npm_package_version\" && git push origin master --tags", "yuidoc": "yuidoc --extension .js,.cpp,.hpp", "publish-yuidoc": "npm run yuidoc && node ./scripts/publish-docs.js" }, "dependencies": { "nan": "^2.14.0", - "node-pre-gyp": "^0.16.0" + "node-pre-gyp": "^0.17.0" }, "bundledDependencies": [ "node-pre-gyp" diff -Nru node-srs-1.2.0+~2.5.0/gdal/README.md node-srs-1.2.0+~2.6.2/gdal/README.md --- node-srs-1.2.0+~2.5.0/gdal/README.md 2020-11-12 17:08:08.000000000 +0000 +++ node-srs-1.2.0+~2.6.2/gdal/README.md 2020-12-09 07:13:05.000000000 +0000 @@ -8,6 +8,8 @@ - GPKG, sqlite, OSM, MBTiles, MVT - Adds `Geometry.fromGeoJson` to parse GeoJSON easily - Adds async support for raster data + opening/parsing files +- Adds support for vsimem files using buffers +- Fixes loads of bugs, performance issues, and more See the [ROADMAP](ROADMAP.md) for more info about the future of this fork. All thanks and credit goes to the original maintainers! diff -Nru node-srs-1.2.0+~2.5.0/gdal/ROADMAP.md node-srs-1.2.0+~2.6.2/gdal/ROADMAP.md --- node-srs-1.2.0+~2.5.0/gdal/ROADMAP.md 2020-11-12 17:08:08.000000000 +0000 +++ node-srs-1.2.0+~2.6.2/gdal/ROADMAP.md 2020-12-09 07:13:05.000000000 +0000 @@ -1,4 +1,4 @@ -# v2.0.0 +# v3.0.0 - Switch from nan to N-API - Normalize the build system for this package to match more recent native modules like node-sqlite @@ -6,10 +6,9 @@ - Improve performance by reducing parse/serialize flows - `Geometry.toObject()` - `Geometry.fromGeoJson()` -- Automate the yuidoc publishing - Build out an async API - Add a streaming API for parsing files - Find a way to keep the dependency source code out of the repository to reduce noise -- Reduce the number of manual patching done in the gdal format gyp files +- Reduce the manual patching done in the gdal format gyp files - Automate dependency updates and prebuilt binaries for new node releases - It would be nice if we had a bot that did this weekly diff -Nru node-srs-1.2.0+~2.5.0/gdal/src/gdal_common.hpp node-srs-1.2.0+~2.6.2/gdal/src/gdal_common.hpp --- node-srs-1.2.0+~2.5.0/gdal/src/gdal_common.hpp 2020-11-12 17:08:08.000000000 +0000 +++ node-srs-1.2.0+~2.6.2/gdal/src/gdal_common.hpp 2020-12-09 07:13:05.000000000 +0000 @@ -308,6 +308,17 @@ } \ var = (*Nan::Utf8String(info[num])) +#define NODE_ARG_BUFFER(num, name, var) \ + if (info.Length() < num + 1) { \ + Nan::ThrowError(name " must be given"); \ + return; \ + } \ + if (!info[num]->IsArrayBuffer()) { \ + Nan::ThrowTypeError(name " must be a buffer"); \ + return; \ + } \ + var = info[num].As(); + // delete callback is in AsyncWorker::~AsyncWorker #define NODE_ARG_CB(num, name, var) \ if (info.Length() < num + 1) { \ diff -Nru node-srs-1.2.0+~2.5.0/gdal/src/gdal_memfile.cpp node-srs-1.2.0+~2.6.2/gdal/src/gdal_memfile.cpp --- node-srs-1.2.0+~2.5.0/gdal/src/gdal_memfile.cpp 1970-01-01 00:00:00.000000000 +0000 +++ node-srs-1.2.0+~2.6.2/gdal/src/gdal_memfile.cpp 2020-12-09 07:13:05.000000000 +0000 @@ -0,0 +1,42 @@ +#include "gdal_memfile.hpp" + +namespace node_gdal { + +std::map Memfile::memfile_collection; + +Memfile::Memfile(void *data, size_t len) : data(data), len(len) { + char _filename[32]; + // The pointer makes for a perfect unique filename + snprintf(_filename, sizeof(_filename), "/vsimem/%p", data); + this->filename = _filename; +} + +void Memfile::weakCallback(const Nan::WeakCallbackInfo &file) { + Memfile *mem = file.GetParameter(); + memfile_collection.erase(mem->data); + VSIUnlink(mem->filename.c_str()); + delete mem; +} + +Memfile *Memfile::get(Local buffer) { + void *data = node::Buffer::Data(buffer); + if (memfile_collection.count(data)) return memfile_collection.find(data)->second; + + size_t len = node::Buffer::Length(buffer); + Memfile *mem = new Memfile(data, len); + + VSILFILE *vsi = VSIFileFromMemBuffer(mem->filename.c_str(), (GByte *)data, len, 0); + if (mem->data == nullptr) { + delete mem; + return nullptr; + } + VSIFCloseL(vsi); + + mem->weakHandle = new Nan::Persistent(buffer); + mem->weakHandle->SetWeak(mem, weakCallback, Nan::WeakCallbackType::kParameter); + + memfile_collection[data] = mem; + return mem; +} + +} // namespace node_gdal diff -Nru node-srs-1.2.0+~2.5.0/gdal/src/gdal_memfile.hpp node-srs-1.2.0+~2.6.2/gdal/src/gdal_memfile.hpp --- node-srs-1.2.0+~2.5.0/gdal/src/gdal_memfile.hpp 1970-01-01 00:00:00.000000000 +0000 +++ node-srs-1.2.0+~2.6.2/gdal/src/gdal_memfile.hpp 2020-12-09 07:13:05.000000000 +0000 @@ -0,0 +1,38 @@ +#ifndef __NODE_GDAL_MEMFILE_H__ +#define __NODE_GDAL_MEMFILE_H__ + +// node +#include +#include +#include + +// nan +#include "nan-wrapper.h" + +// gdal +#include + +#include "utils/obj_cache.hpp" + +using namespace v8; +using namespace node; + +// A vsimem file + +namespace node_gdal { + +class Memfile { + void *data; + size_t len; + Nan::Persistent *weakHandle; + static void weakCallback(const Nan::WeakCallbackInfo &); + + public: + std::string filename; + Memfile(void *, size_t); + static Memfile *get(Local); + void release(); + static std::map memfile_collection; +}; +} // namespace node_gdal +#endif diff -Nru node-srs-1.2.0+~2.5.0/gdal/src/node_gdal.cpp node-srs-1.2.0+~2.6.2/gdal/src/node_gdal.cpp --- node-srs-1.2.0+~2.5.0/gdal/src/node_gdal.cpp 2020-11-12 17:08:08.000000000 +0000 +++ node-srs-1.2.0+~2.6.2/gdal/src/node_gdal.cpp 2020-12-09 07:13:05.000000000 +0000 @@ -56,6 +56,7 @@ #include "gdal_point.hpp" #include "gdal_polygon.hpp" #include "gdal_spatial_reference.hpp" +#include "gdal_memfile.hpp" #include "gdal.hpp" #include "utils/field_types.hpp" @@ -228,6 +229,19 @@ info.GetReturnValue().Set(Nan::New(ptr_manager.isAlive(uid))); } +static NAN_METHOD(getMemfileName) { + Nan::HandleScope scope; + Local buffer; + + NODE_ARG_OBJECT(0, "buffer", buffer); + + Memfile *memfile = Memfile::get(buffer); + if (memfile == nullptr) + Nan::ThrowError("Failed creating in-memory file"); + else + info.GetReturnValue().Set(Nan::New(memfile->filename).ToLocalChecked()); +} + static void Init(Local target, Local, void *) { Nan::SetMethod(target, "open", open); @@ -238,6 +252,7 @@ Nan::SetMethod(target, "setPROJSearchPath", setPROJSearchPath); Nan::SetMethod(target, "_triggerCPLError", ThrowDummyCPLError); // for tests Nan::SetMethod(target, "_isAlive", isAlive); // for tests + Nan::SetMethod(target, "_getMemFileName", getMemfileName); // not a public API Warper::Initialize(target); Algorithms::Initialize(target); diff -Nru node-srs-1.2.0+~2.5.0/gdal/test/api_rasterband-async.test.js node-srs-1.2.0+~2.6.2/gdal/test/api_rasterband-async.test.js --- node-srs-1.2.0+~2.5.0/gdal/test/api_rasterband-async.test.js 2020-11-12 17:08:08.000000000 +0000 +++ node-srs-1.2.0+~2.6.2/gdal/test/api_rasterband-async.test.js 2020-12-09 07:13:05.000000000 +0000 @@ -13,9 +13,7 @@ }) // Not supported on GDAL 1.x -if (gdal.version.split('.')[0] < 2) { - return -} +if (parseFloat(gdal.version) < 2) return describe('gdal.RasterBand', () => { afterEach(gc) diff -Nru node-srs-1.2.0+~2.5.0/gdal/test/open_vsimem.test.js node-srs-1.2.0+~2.6.2/gdal/test/open_vsimem.test.js --- node-srs-1.2.0+~2.5.0/gdal/test/open_vsimem.test.js 1970-01-01 00:00:00.000000000 +0000 +++ node-srs-1.2.0+~2.6.2/gdal/test/open_vsimem.test.js 2020-12-09 07:13:05.000000000 +0000 @@ -0,0 +1,84 @@ +const gdal = require('../lib/gdal.js') +const path = require('path') +const fs = require('fs') +const chai = require('chai') +const chaiAsPromised = require('chai-as-promised') +const assert = chai.assert +chai.use(chaiAsPromised) + +describe('Open', () => { + afterEach(gc) + + describe('vsimem', () => { + let filename, ds, ds2, buffer + + after(() => { + ds.close() + }) + it('should not throw', () => { + filename = path.join(__dirname, 'data/park.geo.json') + buffer = fs.readFileSync(filename) + ds = gdal.open(buffer) + }) + it('should be able to read band count', () => { + assert.equal(ds.layers.count(), 1) + }) + it('should keep the buffer in the dataset', () => { + assert.instanceOf(ds.buffer, Buffer) + assert.equal(ds.buffer, buffer) + }) + it('should throw on an empty buffer', () => { + const buffer = Buffer.alloc(0) + assert.throws(() => gdal.open(buffer)) + }) + it('should throw on an invalid buffer', () => { + const buffer = Buffer.alloc(1024) + assert.throws(() => gdal.open(buffer)) + }) + it('should be shareable across datasets', () => { + const ds2 = gdal.open(buffer) + assert.equal(ds2.buffer, ds.buffer) + ds2.close() + }) + describe('layer', () => { + let layer + before(() => { + layer = ds.layers.get(0) + }) + it('should have all fields defined', () => { + assert.equal(layer.fields.count(), 3) + assert.deepEqual(layer.fields.getNames(), [ + 'kind', + 'name', + 'state' + ]) + }) + }) + }) + describe('vsimem/Async', () => { + // Not supported on GDAL 1.x + if (parseFloat(gdal.version) < 2) return + let filename, ds, buffer + + it('should not throw', () => { + filename = path.join(__dirname, 'data/park.geo.json') + buffer = fs.readFileSync(filename) + ds = gdal.openAsync(buffer) + }) + it('should be able to read band count', () => { + assert.eventually.equal(ds.then((ds) => ds.layers.count()), 1) + }) + it('should keep the buffer in the dataset', () => { + assert.eventually.instanceOf(ds.then((ds) => ds.buffer), Buffer) + assert.eventually.equal(ds.then((ds) => ds.buffer), buffer) + }) + it('should throw on an empty buffer', () => { + buffer = Buffer.alloc(0) + assert.isRejected(gdal.openAsync(buffer)) + }) + it('should throw on an invalid buffer', () => { + buffer = Buffer.alloc(1024) + assert.isRejected(gdal.openAsync(buffer)) + }) + }) +})