node-hgt icon indicating copy to clipboard operation
node-hgt copied to clipboard

tempDir in imagico not set

Open rj76 opened this issue 9 years ago • 4 comments

Hi,

I'm trying to add elevation data to existing geojson objects, but I'm running into a problem I can't seem to be able to solve.

I'm getting this error:

addElevation error [ 'TypeError: path must be a string',
  '    at TypeError (native)',
  '    at Object.fs.unlinkSync (fs.js:883:18)',
  '    at ImagicoElevationDownloader.<anonymous> (/home/richard/workspace/atlas_elevation/node_modules/node-hgt/src/imagico.js:20:16)',
  '    at /home/richard/workspace/atlas_elevation/node_modules/node-hgt/node_modules/promise/lib/core.js:33:15',
  '    at flush (/home/richard/workspace/atlas_elevation/node_modules/node-hgt/node_modules/promise/node_modules/asap/asap.js:27:13)',
  '    at process._tickCallback (node.js:355:11)' ]

The code:

    client.query('SELECT naam, ST_AsGeoJSON(ST_Transform(geometery, 900913), 6) AS geometry FROM table LIMIT 1', function(error, result) {
        if (error) {
            console.log('Error querying', error);
            process.exit();
        }

        dbgeo.parse({ 'data': result.rows }, function(error, geojson) {
            if (error) {
                console.log('dbgeo.parse error', error);
                return;
            }

            addElevation(geojson, new TileSet(__dirname + '/data'), function(error, elevation) {
                if (error) {
                    console.log('addElevation error', error.stack.split("\n"));
                    process.exit();
                    return;
                }
            });
        });

Any ideas?

Cheers, Richard

rj76 avatar Jan 03 '16 14:01 rj76

Haven't seen this before, but you might want to check what os.tmpdir() returns on your system

Which OS and node version are you using?

perliedman avatar Jan 04 '16 14:01 perliedman

Okay, is seems the ST_Transform wasn't done correctly and the coordinates didn't make any sense. I would have thought an exception [1] was thrown in that case :)

[1] https://github.com/perliedman/node-hgt/blob/master/src/imagico.js#L29

Anyway, solved!

rj76 avatar Jan 04 '16 19:01 rj76

Yeah, leaving this open, that error message is hardly helpful in this case!

perliedman avatar Jan 04 '16 20:01 perliedman

Still going to create a pull request for the download/unzip part, and add some tests. But not today :)

rj76 avatar Jan 04 '16 21:01 rj76