-
-
Save craigds/dcb5ac1deada075bc70877ea38f03899 to your computer and use it in GitHub Desktop.
basic node-mapnik test for loading a TIF file from a /vsicurl URL
This file contains 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
#!/usr/bin/env node | |
const mapnik = require('mapnik'); | |
const xml = `<?xml version="1.0" encoding="utf-8"?> | |
<!DOCTYPE Map[]> | |
<Map srs="+init=epsg:3857" maximum-extent="-20037508.342789,-20037508.342789,20037508.342789,20037508.342789"> | |
<Parameters> | |
<Parameter name="bounds">-179.99999999999784,-85.05112877980642,179.99999999999784,85.0511287798064</Parameter> | |
<Parameter name="center">172.48834862858251,-43.43721450668898,1</Parameter> | |
<Parameter name="format">png</Parameter> | |
<Parameter name="minzoom">0</Parameter> | |
<Parameter name="maxzoom">21</Parameter> | |
<Parameter name="scale">1</Parameter> | |
<Parameter name="metatile">2</Parameter> | |
</Parameters> | |
<Style name="x" filter-mode="first"> | |
<Rule> | |
<RasterSymbolizer premultiplied="true" opacity="1" scaling="near" /> | |
</Rule> | |
</Style> | |
<Layer name="x" | |
maximum-extent="19188580.25324628,-5388933.385960499,19214050.02096663,-5368595.5793669615" | |
srs="+init=epsg:3857"> | |
<StyleName>x</StyleName> | |
<Datasource> | |
<Parameter name="type"><![CDATA[gdal]]></Parameter> | |
<Parameter name="file"><![CDATA[/vsicurl/https://kx-craig-misc-test-bucket.s3.ap-southeast-2.amazonaws.com/v4-8018-5194.tif]]></Parameter> | |
</Datasource> | |
</Layer> | |
</Map>` | |
mapnik.register_datasource('/app/node_modules/mapnik/lib/binding/lib/mapnik/input/gdal.input'); | |
var map = new mapnik.Map(256, 256); | |
var opts = { strict: false, base: "/unused" }; | |
map.fromString(xml, opts, function (err, map) { | |
if (!err) { | |
console.log("map.fromString succeeded!") | |
} else { | |
console.log(err) | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment