mapcachetools 2.2.3 → 2.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/mapcache_download.js +10 -6
- package/package.json +1 -1
package/bin/mapcache_download.js
CHANGED
|
@@ -32,7 +32,7 @@ const MAX_LATITUDE = 85.0511287798;
|
|
|
32
32
|
const R_MINOR = 6356752.314245179; // Not used, but kept for completeness.
|
|
33
33
|
|
|
34
34
|
// Default values
|
|
35
|
-
const DEFAULT_PROVIDER = 0; // 0: OSM, 1: Mapbox Satellite, 2: Mapbox Terrain RGB
|
|
35
|
+
const DEFAULT_PROVIDER = 0; // 0: OSM, 1: Mapbox Satellite, 2: Mapbox Terrain RGB, 3: Stadiamaps
|
|
36
36
|
const DEFAULT_CONCURRENCY = 5; // Safe default to avoid rate limits
|
|
37
37
|
const DEFAULT_RETRIES = 3;
|
|
38
38
|
const DEFAULT_ZOUT = 0;
|
|
@@ -98,10 +98,11 @@ function fn_convertFromLngLatToPoints(lat1, lng1, lat2, lng2, zoom) {
|
|
|
98
98
|
point2.x = Math.floor(point2.x / 256);
|
|
99
99
|
point2.y = Math.floor(point2.y / 256);
|
|
100
100
|
|
|
101
|
-
// Ensure point1 is top-left, point2 bottom-right
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
// Ensure point1 is top-left (min x, min y), point2 is bottom-right (max x, max y)
|
|
102
|
+
return [
|
|
103
|
+
{ x: Math.min(point1.x, point2.x), y: Math.min(point1.y, point2.y) },
|
|
104
|
+
{ x: Math.max(point1.x, point2.x), y: Math.max(point1.y, point2.y) }
|
|
105
|
+
];
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
/* ============================================================
|
|
@@ -149,6 +150,9 @@ function getTileUrlAndFilename(i, j, zoom) {
|
|
|
149
150
|
// Mapbox Terrain RGB
|
|
150
151
|
url = `https://api.mapbox.com/v4/mapbox.terrain-rgb/${zoom}/${i}/${j}.png?access_token=${TOKEN}`;
|
|
151
152
|
typePrefix = "terrain";
|
|
153
|
+
} else if (map_provider == 3) {
|
|
154
|
+
url = `https://tiles.stadiamaps.com/tiles/alidade_satellite/${zoom}/${i}/${j}.jpg?api_key=${TOKEN}`;
|
|
155
|
+
typePrefix = "stadiamaps";
|
|
152
156
|
} else {
|
|
153
157
|
// OpenStreetMap
|
|
154
158
|
url = `https://tile.openstreetmap.org/${zoom}/${i}/${j}.png`;
|
|
@@ -266,7 +270,7 @@ function fn_handle_arguments() {
|
|
|
266
270
|
|
|
267
271
|
// Provider and token
|
|
268
272
|
map_provider = myArgs.provider ? parseInt(myArgs.provider) : DEFAULT_PROVIDER;
|
|
269
|
-
if (map_provider === 1 || map_provider === 2) {
|
|
273
|
+
if (map_provider === 1 || map_provider === 2 || map_provider === 3) {
|
|
270
274
|
TOKEN = myArgs.token;
|
|
271
275
|
if (!TOKEN) {
|
|
272
276
|
error = true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mapcachetools",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.6",
|
|
4
4
|
"description": "A Node.js tool to download and cache map tiles (OSM, Mapbox Satellite, Mapbox Terrain RGB) as PNG images for offline use in mapping applications. Use at your own risk and comply with provider terms.",
|
|
5
5
|
"main": "bin/mapcache_download.js",
|
|
6
6
|
"bin": {
|