diff --git a/.travis.yml b/.travis.yml index 01d59897d9..746ff382c7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,7 +45,7 @@ matrix: env: global: - JOBS: "8" - - MAPNIK_GIT: v3.0.7 + - MAPNIK_GIT: v3.0.7-47-g1455c6b - secure: F42vcZEgWgCMDvQXlmyYmWwFo86fUjlJbsvXEwyliaMfasjCNsbmeILU61aScn8daiCGD+vRUaRlmv+XxUSS2G8FaoI8ZjwgMo2guMwthAQJ1ohTvf4bZI0JqVYKnnZpzhGPv2zD0DTdt31l30qn2GZnnGrF4yFpPU1HW2HcMuE= - secure: WRWrn3KjCaevRo2htdvn26euALTZNCDtcSlQvtH6Bc7yLdhlH5apj+qSuWqlN59f1cprFH+5aQ2zmBkVmAV2DT4IbsfszMIR6k6EetuY6VOugo/qsPW2x/MQbpFgjCbl95bYty4eUH9Bcf70Pz/S+XVewABXHWikJiLUiZBbLyE= diff --git a/appveyor.yml b/appveyor.yml index 0e1d57d4ec..ae85fae2e9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,5 @@ environment: - MAPNIK_GIT: 3.0.7 + MAPNIK_GIT: 3.0.7-48-g9df5486 node_pre_gyp_accessKeyId: secure: 7DrSVc5eIGtmMcki5H+iRft+Tk3MJTwDBQEUuJHWaQ4= node_pre_gyp_secretAccessKey: diff --git a/bin/mapnik-index.js b/bin/mapnik-index.js new file mode 100755 index 0000000000..6d0eedaa82 --- /dev/null +++ b/bin/mapnik-index.js @@ -0,0 +1,29 @@ +#!/usr/bin/env node + +'use strict'; + +var binary = require('node-pre-gyp'), + path = require('path'), + bindingPath = binary.find(path.resolve(__dirname, '..', 'package.json')), + program = path.join(path.dirname(bindingPath), 'mapnik-index'), + spawn = require('child_process').spawn, + fs = require('fs'); + +if (!fs.existsSync(program)) { + // assume it is not packaged but still on PATH + program = 'mapnik-index'; +} + +var proc = spawn(program, process.argv.slice(2)) + .on('error', function(err) { + if (err && err.code == 'ENOENT') { + throw new Error("mapnik-index not found at " + program); + } + throw err; + }) + .on('exit', function(code) { + process.exit(code); + }); + +proc.stdout.pipe(process.stdout); +proc.stderr.pipe(process.stderr); diff --git a/scripts/build_against_sdk.sh b/scripts/build_against_sdk.sh index ba36f2fafb..2e6845af61 100755 --- a/scripts/build_against_sdk.sh +++ b/scripts/build_against_sdk.sh @@ -81,6 +81,8 @@ MODULE_PATH=$(node-pre-gyp reveal module_path ${ARGS}) rm -rf ${MODULE_PATH} npm install --build-from-source ${ARGS} --clang=1 npm ls +# copy mapnik-index +cp ${MAPNIK_SDK}/bin/mapnik-index ${MODULE_PATH} # copy shapeindex cp ${MAPNIK_SDK}/bin/shapeindex ${MODULE_PATH} # copy lib diff --git a/scripts/build_against_sdk_02-copy-deps-to-bindingdir.ps1 b/scripts/build_against_sdk_02-copy-deps-to-bindingdir.ps1 index 8b113b3d5e..791c17f2e5 100644 --- a/scripts/build_against_sdk_02-copy-deps-to-bindingdir.ps1 +++ b/scripts/build_against_sdk_02-copy-deps-to-bindingdir.ps1 @@ -7,6 +7,7 @@ Try{ Write-Output "to: $env:NODEMAPNIK_BINDING_DIR" Copy-Item $env:MAPNIK_SDK\bin\shapeindex.exe $env:NODEMAPNIK_BINDING_DIR\ -ErrorAction Stop + Copy-Item $env:MAPNIK_SDK\bin\mapnik-index.exe $env:NODEMAPNIK_BINDING_DIR\ -ErrorAction Stop $deps = Get-ChildItem -Path $env:MAPNIK_SDK\lib -Filter *.dll | % { $_.FullName } diff --git a/test/mapnik-index.test.js b/test/mapnik-index.test.js new file mode 100644 index 0000000000..cc268b3ff2 --- /dev/null +++ b/test/mapnik-index.test.js @@ -0,0 +1,44 @@ +"use strict"; + +var assert = require('assert'); +var path = require('path'); +var fs = require('fs'); +var os = require('os'); +var crypto = require('crypto'); +var mapnikindex = path.resolve(__dirname, '..', 'bin', 'mapnik-index.js'); + +var file = path.join(__dirname, 'data', 'world_merc.json'); + +var tmpdir = path.join(os.tmpdir(), crypto.randomBytes(8).toString('hex')); +var tmpfile = path.join(tmpdir, 'world_merc.json'); + +var spawn = require('child_process').spawn; + +function copy(done) { + fs.mkdir(tmpdir, function() { + fs.createReadStream(file).pipe(fs.createWriteStream(tmpfile)).on('close', done); + }); +} + +describe('bin/mapnik-index.js', function() { + before(copy); + + it('should create a spatial index', function(done) { + var args = [mapnikindex, '--files', tmpfile]; + spawn(process.execPath, args) + .on('error', function(err) { assert.ifError(err, 'no error'); }) + .on('close', function(code) { + assert.equal(code, 0, 'exit 0'); + + fs.readdir(tmpdir, function(err, files) { + + files = files.filter(function(filename) { + return filename === 'world_merc.json.index'; + }); + + assert.equal(files.length, 1, 'made spatial index'); + done(); + }); + }); + }); +});