Monday, December 16, 2013

node-mapnik on windows

1) Cleaning up mess
npm cache clean if encounter issues despite changes

2) binding.gyp

2a) From the dos command prompt, running npm install
set protobuf_src=
eg set protobuf_src=x:\progra~1\protobuf\src
set cairo_src=
eg set cairo_src=x:\progra~1\cairo\src

2b) Modifying binding.gyp in directory node-mapnik
from
 'conditions': [
      ['OS=="win"', {
        'variables': {
          'PROTOBUF_INCLUDES%':'C:/dev2/protobuf/vsprojects/include',
          'PROTOBUF_LIBS%':'C:/dev2/protobuf/vsprojects/Release',
          'PROTOBUF_LIBRARY%':'libprotobuf-lite.lib',
to
 'conditions': [
      ['OS=="win"', {
        'variables': {
          'CAIRO_INCLUDES%':'$(CAIRO_SRC)',
          'PROTOBUF_INCLUDES%':'$(PROTOBUF_SRC)',
          'PROTOBUF_LIBS%':'$(PROTOBUF_SRC)/../vsprojects/Release',
          'PROTOBUF_LIBRARY%':'libprotobuf-lite.lib',

2c) from
'conditions': [
        ['OS=="win"', {
            'include_dirs':[
                '<!@(mapnik-config --includes)',
                '<!@(mapnik-config --dep-includes)',
                '<@(PROTOBUF_INCLUDES)'
              ],

to
'conditions': [
        ['OS=="win"', {
            'include_dirs':[
                '<!@(mapnik-config --includes)',
                '<!@(mapnik-config --dep-includes)',
                '<@(PROTOBUF_INCLUDES)',
                '<@(CAIRO_INCLUDES)'
              ],


3) As advised in binding.gyp, make changes to .node-gyp\*\common.gypi under user directory
xp - c:\documents and settings\username\...
win7 - c:\users\username\...


see https://groups.google.com/forum/?fromgroups=#!topic/gyp-developer/p98GJxYJuH4
see https://github.com/TooTallNate/node-gyp/issues/26


4)  Testing
npm install -g mocha
npm install sphericalmercator

Grab a copy of GDAL for windows from http://www.gisinternals.com/sdk/
sdkshell.bat to set the environment for
4a) PROJ_LIB
4b) GDAL_DATA


mocha -R spec to list details