Created
April 14, 2016 20:50
-
-
Save yohanboniface/e8f493e96d42cc3d154631b35b836772 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var request = require("request"), | |
mapnik = require('mapnik'), | |
zlib = require('zlib'); | |
request({ | |
uri: "http://vector.mapzen.com/osm/all/17/66388/45097.mvt", | |
// uri: "http://carto.data.gouv.fr/vector/all/17/66386/45096.mvt", | |
encoding: null | |
}, function(error, resp, body) { | |
var info, compression; | |
console.log(resp.headers) | |
if (resp.headers['content-encoding'] === 'gzip') compression = 'gunzip'; | |
else if (resp.headers['content-encoding'] === 'deflate') compression = 'inflate'; | |
else if (body && body[0] === 0x1F && body[1] === 0x8B) compression = 'gunzip'; | |
else if (body && body[0] === 0x78 && body[1] === 0x9C) compression = 'inflate'; | |
if (compression) { | |
zlib[compression](body, function(err, data) { | |
if (err) throw err; | |
info = mapnik.VectorTile.info(data); | |
console.log(info); | |
}); | |
} else { | |
var info = mapnik.VectorTile.info(body); | |
console.log(info); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment