perliedman/node-hgt

Multiple Tiles / Zip files

Dave13h opened this issue · 0 comments

Hi,

Great package, very useful. I have a slight issue though, when there are multiple zip files coming from imagico it only seems to process the first one..

https://github.com/perliedman/node-hgt/blob/master/src/imagico.js#L32

Then it throws an error trying to read a file from the 2nd zip file. For example using..

[44.81211, 6.172401], [45.8805, 6.553799].

Two files are returned from imagico..

[{"name":"L31.zip","title":"","link":"http:\/\/www.viewfinderpanoramas.org\/dem3\/L31.zip","date":"2012-08-05","lon_start":"0","lat_start":"44","lon_end":"6","lat_end":"48","type":"2"},{"name":"L32.zip","title":"","link":"http:\/\/www.viewfinderpanoramas.org\/dem3\/L32.zip","date":"2012-08-05","lon_start":"6","lat_start":"44","lon_end":"12","lat_end":"48","type":"2"}]

A quick work around that seems to work is

var last;
for (var z in tileZips) {
    tempPath = path.join(os.tmpdir(), tileZips[z].name);
    stream = fs.createWriteStream(tempPath);
    last = this._download(tileZips[z].link, stream);
}
return last;

I'm sure this isn't the most elegant solution :P