The goal of this PR is twofold:
(1) To make it possible to use the application and CLI to fetch tiles from an online source, in addition to a local source.
(2) To use this new functionality to fetch tiles from the Bing Maps (VirtualEarth) API.
Updated the CLI to take additional parameters: the user can now specify if they are providing their own style or not, and if not, which online source they wish to use, and any API key associated with that online source. They may also specify an additional overlay source, which must be a GeoJSON object.
In render.js:
In initiateRendering (formerly "renderMbtiles"), if no style is provided by the user, set up a temp dir, call a downloadRemoteTiles function to download tiles to there, save the overlay GeoJSON if provided, and construct a style using a generateStyle function.
In constructMBTiles (formerly "generateMBTiles"), incorporate any metadata found in a metadata.json file (which typically accompanies XYZ tiles generated through QGIS and other sources, including this app). Also, delete the tempDir if found.
I created a file generate_resources.js with the specific concern of generating resources, and moved the existing generateJPG function in there. Within this file:
generateStyle generates a stylesheet for use cases where no style is provided; composed of the online source mapped as XYZ tiles, and an additional GeoJSON overlay if provided. (Currently the style for the GeoJSON is hard-coded to be transparent red, per our (CMI) need for visualizing alerts.)
downloadRemoteTiles is an async handler which calls a different function to download tiles, depending on the kind of online source. Thus far, we are only providing support for Bing maps.
downloadNaturalEarthTile is what is used to download content from Bing. This is largely adapted from the approach in GCCD, except that I am also adding here an option to pass an API key to the tile requests.
Updated the readme with new CLI usage, and licensing information.
Small fixes to error handling here and there.
What I'm not doing here
Although the scaffolding is in here for adding a GeoJSON overlay to the map, I have not yet tested this, and the way this works may change depending on the overall architecture of MapPacker.
Adding support for other online sources, such as OSM, Google, Planet. Those will come in follow-on PRs.
Closes #3.
Goal
The goal of this PR is twofold: (1) To make it possible to use the application and CLI to fetch tiles from an online source, in addition to a local source. (2) To use this new functionality to fetch tiles from the Bing Maps (VirtualEarth) API.
Screenshots
node src/cli.js --style "no" --bounds "12.46810,67.61450,15.43150,68.49630" -Z 8 --onlinesource "bing"
)What I changed
render.js
:initiateRendering
(formerly "renderMbtiles"), if no style is provided by the user, set up a temp dir, call adownloadRemoteTiles
function to download tiles to there, save the overlay GeoJSON if provided, and construct a style using agenerateStyle
function.constructMBTiles
(formerly "generateMBTiles"), incorporate any metadata found in a metadata.json file (which typically accompanies XYZ tiles generated through QGIS and other sources, including this app). Also, delete the tempDir if found.generate_resources.js
with the specific concern of generating resources, and moved the existinggenerateJPG
function in there. Within this file:generateStyle
generates a stylesheet for use cases where no style is provided; composed of the online source mapped as XYZ tiles, and an additional GeoJSON overlay if provided. (Currently the style for the GeoJSON is hard-coded to be transparent red, per our (CMI) need for visualizing alerts.)downloadRemoteTiles
is an async handler which calls a different function to download tiles, depending on the kind of online source. Thus far, we are only providing support for Bing maps.downloadNaturalEarthTile
is what is used to download content from Bing. This is largely adapted from the approach in GCCD, except that I am also adding here an option to pass an API key to the tile requests.What I'm not doing here