node-mapnik-sample-code
node-mapnik-sample-code copied to clipboard
Invalid index file
When running the first example I get the following error. Removing the map.zoomAll(); line allows it to render an image.
I'm not sure if it's the expected output since // expected output: https://github.com/mapnik/node-mapnik-sample-code/blob/master/outputs/map.png is a 404.
node ./render/app.js ./stylesheet.xml map.png
/Users/Steve/Play/mapnik/node-mapnik-sample-code/render/app.js:33
map.renderFileSync(image);
^
Error: Invalid index file
at Error (native)
at Object.<anonymous> (/Users/Steve/Play/mapnik/node-mapnik-sample-code/render/app.js:33:5)
at Module._compile (module.js:398:26)
at Object.Module._extensions..js (module.js:405:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:430:10)
at startup (node.js:141:18)
at node.js:1003:3
mapnik-config --version
3.0.5
node -e "console.log(require('mapnik').version)"
3.4.15
This also happens in the tile examples. When the map.extent = bbox; line is removed it seems to work.
map.zoomAll is critical to rendering the image so removing it just resulted in a empty image. I found this which lead me to removing the .index file from my data. Now I am able to render the map successfully! Sounds like mapnik should handle the index file though?
@almccon and I recently ran into this too. It appears that somewhere in the mapnik-3.4 series the index file format has changed (we were reproducing it with 3.4.16).
We managed to solve it by using the shapeindex alternative that now ships with node-mapnik: node_modules/.bin/mapnik-shapeindex.js
/cc @springmeyer
I've just removed the index file from this repo to ensure that the same code works with all versions of node-mapnik. Sorry about being slow to help troubleshoot here but @mojodna had the right fix. More details at https://github.com/mapnik/node-mapnik/issues/590