mapbox/node-srs

visual studio 2014 test failures

springmeyer opened this issue · 9 comments

From https://ci.appveyor.com/project/Mapbox/node-srs/build/1.0.11/job/erhhc66r9j5g5ax4#L710.

It looks like the data files are not being loaded correctly when osr is compiled with visual studio 2014.

 maryland ESRI variant
621    √ detects proj if parsed as ESRI:: 
622 
623  GeoJSON
624ERROR 4: Unable to open EPSG support file gcs.csv.
625Try setting the GDAL_DATA environment variable to point to the
626directory containing EPSG csv files.
627ERROR 4: Unable to open EPSG support file gcs.csv.
628Try setting the GDAL_DATA environment variable to point to the
629directory containing EPSG csv files.
630    1) should detect mercator
631
    √ should detect wgs84 
632    √ should detect wgs84 2 
633    √ should detect with no ext 
634 
635  throws on invalid input
636    √ detects proj if parsed as ESRI:: 
637    √ init=epsg:3857 
638    √ +init=epsg 
639ERROR 4: Unable to open EPSG support file gcs.csv.
640Try setting the GDAL_DATA environment variable to point to the
641directory containing EPSG csv files.
642ERROR 4: Unable to open EPSG support file gcs.csv.
643Try setting the GDAL_DATA environment variable to point to the
644directory containing EPSG csv files.
645    √ +init=epsg:500 
646 
647  qgis qpj format
648    √ detects custom grids inside qgis transverse mercator projection 
649 
650  OSGB 1936
651    √ should report that it was parsed as esri if ESRI:: was manually prepended 
652    √ should detect OGC format for OSGB 1936 / British National Grid 
653    √ should detect correct proj4 for ESRI format for OSGB 1936 / British National Grid 
654    √ should detect correct srid for ESRI format for OSGB 1936 / British National Grid 
655 
656  Mercator
657    √ should detect non-spherical mercator 
658    √ should detect qgis/ogr wkt 
659    √ should detect qgis/ogr wkt 
660    √ should detect sr-org produced by older ogr version 
661    √ should detect sr-ogr6 
662    √ should detect http://prj2epsg.org/epsg/3857 
663    √ should detect +over stripped 
664    √ should detect proj 3857 
665    √ should detect 900913 
666    √ should detect esri 900913 
667    √ should detect esri 900913 hint 
668    √ should detect esri webmerc 
669    √ should detect esri webmerc hint 
670    √ should detect esri webmerc aux 
671    √ should detect webmerc aux hint 
672    √ should detect esri webmerc aux2 
673    √ should detect esri webmerc aux2 hint 
674    √ should detect osm_landusages 
675    √ should detect bogus proj 1 
676    √ should detect bogus proj 2 
677    √ should detect sr.org mercator1sp 
678    √ should detect sr.org messed up mercator2sp 
679    √ should detect openstreetmapdata.com as 3857 
680    √ should detect +init=epsg:3857 as 3857 
681    √ should detect +init=esri:102100 as 3857 
682    √ should detect +init=esri:102113 as 3857 
683    √ should detect +init=epsg:3785 as 3857 
684    √ should detect +init=osgeo:41001 as 3857 
685 
686  WGS84
687    √ should detect wgs84 proj4 init detection 
688    √ should detect wgs84 proj4 literal from gdal trunk detection 
689    √ should detect wgs84 proj4 literal +datum will trigger addition to towgs detection 
690    √ should detect wgs84 wkt detection 
691ERROR 4: Unable to open EPSG support file gcs.csv.
692Try setting the GDAL_DATA environment variable to point to the
693directory containing EPSG csv files.
694ERROR 4: Unable to open EPSG support file gcs.csv.
695Try setting the GDAL_DATA environment variable to point to the
696directory containing EPSG csv files.
697    2) should detect wgs84 epsg detection
698    √ should detect wgs84 common name detection 
699    √ should detect wgs84 proj4 literal no datum detection 
700    √ should detect wgs84 wkt from prj file 
701    √ should detect wgs84 wkt from another prj file 
702 
703  #split_proj
704    √ splits on spaces 
705 
706  Version check
707    √ test version updated for release 
708 
709 
710�[92m  51 passing (140ms)
711  2 failing
712 
713  1) GeoJSON should detect mercator:
714     Error: OGR Error type #1 problem occured importing from srs wkt: epsg:900913.
715
716      at Error (native)
717      at Object.parse (C:\projects\node-srs\lib\srs.js:83:22)
718      at Context.<anonymous> (C:\projects\node-srs\test\geojson.test.js:8:24)
719      at callFn (C:\projects\node-srs\node_modules\mocha\lib\runnable.js:250:21)
720      at Test.Runnable.run (C:\projects\node-srs\node_modules\mocha\lib\runnable.js:243:7)
721      at Runner.runTest (C:\projects\node-srs\node_modules\mocha\lib\runner.js:373:10)
722      at C:\projects\node-srs\node_modules\mocha\lib\runner.js:451:12
723      at next (C:\projects\node-srs\node_modules\mocha\lib\runner.js:298:14)
724      at C:\projects\node-srs\node_modules\mocha\lib\runner.js:308:7
725      at next (C:\projects\node-srs\node_modules\mocha\lib\runner.js:246:23)
726      at Immediate._onImmediate (C:\projects\node-srs\node_modules\mocha\lib\runner.js:275:5)
727      at processImmediate [as _immediateCallback] (timers.js:374:17)
728
729  2) WGS84 should detect wgs84 epsg detection:
730     Error: OGR Error type #1 problem occured importing from srs wkt: EPSG:4326.
731
732      at Error (native)
733      at Object.parse (C:\projects\node-srs\lib\srs.js:83:22)
734      at Context.<anonymous> (C:\projects\node-srs\test\shapefile.4326.test.js:33:26)
735      at callFn (C:\projects\node-srs\node_modules\mocha\lib\runnable.js:250:21)
736      at Test.Runnable.run (C:\projects\node-srs\node_modules\mocha\lib\runnable.js:243:7)
737      at Runner.runTest (C:\projects\node-srs\node_modules\mocha\lib\runner.js:373:10)
738      at C:\projects\node-srs\node_modules\mocha\lib\runner.js:451:12
739      at next (C:\projects\node-srs\node_modules\mocha\lib\runner.js:298:14)
740      at C:\projects\node-srs\node_modules\mocha\lib\runner.js:308:7
741      at next (C:\projects\node-srs\node_modules\mocha\lib\runner.js:246:23)
742      at Immediate._onImmediate (C:\projects\node-srs\node_modules\mocha\lib\runner.js:275:5)
743      at processImmediate [as _immediateCallback] (timers.js:374:17)
744
745 

noticing that if I build locally with:

npm install --build-from-source --msvs_version=2013 --toolset=v140

Then all tests pass (note: this is using the pre-built node.exe, which of course is bad).

hmm, all tests pass locally for me too, even with visual studio 2014 compiled node:

..\v0.10.33-nodecpp11\Release\node.exe node_modules\mocha\bin\mocha

Okay, after actually clearing the .node-gyp directory and re-installing using --dist-url I can trigger the problem.

npm install --build-from-source --msvs_version=2013 --toolset=v140 --dist-url=https://s3.amazonaws.com/mapbox/node-cpp11 --target=0.10.33
..\v0.10.33-nodecpp11\Release\node.exe node_modules\mocha\bin\mocha
 51 passing (93ms)
 2 failing

 1) GeoJSON should detect mercator:
    Error: OGR Error type #1 problem occured importing from srs wkt: epsg:900913.

     at Object.parse (c:\code\node-srs\lib\srs.js:87:22)
     at Context.<anonymous> (c:\code\node-srs\test\geojson.test.js:8:24)
     at callFn (c:\code\node-srs\node_modules\mocha\lib\runnable.js:250:21)
     at Test.Runnable.run (c:\code\node-srs\node_modules\mocha\lib\runnable.js:243:7)
     at Runner.runTest (c:\code\node-srs\node_modules\mocha\lib\runner.js:373:10)
     at c:\code\node-srs\node_modules\mocha\lib\runner.js:451:12
     at next (c:\code\node-srs\node_modules\mocha\lib\runner.js:298:14)
     at c:\code\node-srs\node_modules\mocha\lib\runner.js:308:7
     at next (c:\code\node-srs\node_modules\mocha\lib\runner.js:246:23)
     at Object._onImmediate (c:\code\node-srs\node_modules\mocha\lib\runner.js:275:5)
     at processImmediate [as _immediateCallback] (timers.js:345:15)

 2) WGS84 should detect wgs84 epsg detection:
    Error: OGR Error type #1 problem occured importing from srs wkt: EPSG:4326.

     at Object.parse (c:\code\node-srs\lib\srs.js:87:22)
     at Context.<anonymous> (c:\code\node-srs\test\shapefile.4326.test.js:33:26)
     at callFn (c:\code\node-srs\node_modules\mocha\lib\runnable.js:250:21)
     at Test.Runnable.run (c:\code\node-srs\node_modules\mocha\lib\runnable.js:243:7)
     at Runner.runTest (c:\code\node-srs\node_modules\mocha\lib\runner.js:373:10)
     at c:\code\node-srs\node_modules\mocha\lib\runner.js:451:12
     at next (c:\code\node-srs\node_modules\mocha\lib\runner.js:298:14)
     at c:\code\node-srs\node_modules\mocha\lib\runner.js:308:7
     at next (c:\code\node-srs\node_modules\mocha\lib\runner.js:246:23)
     at Object._onImmediate (c:\code\node-srs\node_modules\mocha\lib\runner.js:275:5)
     at processImmediate [as _immediateCallback] (timers.js:345:15)

Tests all still pass with this build if I just run the tests with npm test (which uses the pre-built node.js).

Noting that srs.parse('+init=epsg:4326'); works while srs.parse('EPSG:4326'); or srs.parse('epsg:4326'); fail which seems to indicate a problem loading the data files from the GDAL_DATA environment variable.

After much debugging I've found that getenv is failing right here:

pszResult = getenv( pszKey );
and null is returned rather than the correct path to GDAL_DATA. The getenv call does work if GDAL_DATA is set in the environment before node.exe starts but does not work when it is set here
process.env.GDAL_DATA = path.join(__dirname, 'srs_data');

I've found that node/src/node.cc uses SetEnvironmentVariableW instead of setenv on windows and I've confirmed that this appears to be the mismatch. Calling GetEnvironmentVariableA returns the right value (set in lib/srs.js).

fixed, whew. Will track back later on and try to figure out what is different about visual studio 2014 runtimes where getenv seems to not talk to SetEnvironmentVariable (mapbox/node#1).

more proper fix landed in #50