tileblaster 1.0.2 → 1.0.4
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/builtins/cache.js +1 -1
- package/builtins/check.js +9 -9
- package/builtins/compress.js +1 -1
- package/lib/store.js +3 -2
- package/package.json +18 -4
package/builtins/cache.js
CHANGED
|
@@ -14,7 +14,7 @@ module.exports = function({ opts, data, res }, next, skip){
|
|
|
14
14
|
if (!cache.hasOwnProperty(data.map)) {
|
|
15
15
|
|
|
16
16
|
// store instance
|
|
17
|
-
cache.store = this.lib.store({ root: config.paths.data });
|
|
17
|
+
cache.store = this.lib.store({ root: config.paths.data, ext: config.id+".tmp" });
|
|
18
18
|
|
|
19
19
|
// merge opts of all uses of the cache builtin in a map config
|
|
20
20
|
opts = config.maps[data.map].filter(function(use){
|
package/builtins/check.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// check data.params against constraints
|
|
1
|
+
// check data.req.params against constraints
|
|
2
2
|
|
|
3
3
|
const cache = {};
|
|
4
4
|
|
|
@@ -86,28 +86,28 @@ module.exports = function({ req, res, opts, data }, next){
|
|
|
86
86
|
opts = cache[data.map];
|
|
87
87
|
|
|
88
88
|
// check for NaNs
|
|
89
|
-
if (isNaN(data.params.z) || isNaN(data.params.x) || isNaN(data.params.y)) return next(new Error("illegal zxy."));
|
|
89
|
+
if (isNaN(data.req.params.z) || isNaN(data.req.params.x) || isNaN(data.req.params.y)) return next(new Error("illegal zxy."));
|
|
90
90
|
|
|
91
91
|
// check zoom
|
|
92
|
-
if (data.params.z < opts.minZoom || data.params.z > opts.maxZoom) return next(new Error("illegal zoom."));
|
|
92
|
+
if (data.req.params.z < opts.minZoom || data.req.params.z > opts.maxZoom) return next(new Error("illegal zoom."));
|
|
93
93
|
|
|
94
94
|
// check bounds
|
|
95
95
|
if (opts.bounds) {
|
|
96
|
-
if (opts.bounds[data.params.z][0] < opts.bounds[data.params.z][2]) { // check for bounds spanning antimeridian
|
|
96
|
+
if (opts.bounds[data.req.params.z][0] < opts.bounds[data.req.params.z][2]) { // check for bounds spanning antimeridian
|
|
97
97
|
// bounds don't span antimeridian
|
|
98
|
-
if (data.params.x < opts.bounds[data.params.z][0] || data.params.x > opts.bounds[data.params.z][2]) return next(new Error("x is out of bounds."));
|
|
98
|
+
if (data.req.params.x < opts.bounds[data.req.params.z][0] || data.req.params.x > opts.bounds[data.req.params.z][2]) return next(new Error("x is out of bounds."));
|
|
99
99
|
} else {
|
|
100
100
|
// bounds span antimeridian
|
|
101
|
-
if (data.params.x > opts.bounds[data.params.z][0] && data.params.x < opts.bounds[data.params.z][2]) return next(new Error("x is out of bounds, bounds span antimeridian"));
|
|
101
|
+
if (data.req.params.x > opts.bounds[data.req.params.z][0] && data.req.params.x < opts.bounds[data.req.params.z][2]) return next(new Error("x is out of bounds, bounds span antimeridian"));
|
|
102
102
|
}
|
|
103
|
-
if (data.params.y < opts.bounds[data.params.z][1] || data.params.y > opts.bounds[data.params.z][3]) return next(new Error("y is out of bounds."));
|
|
103
|
+
if (data.req.params.y < opts.bounds[data.req.params.z][1] || data.req.params.y > opts.bounds[data.req.params.z][3]) return next(new Error("y is out of bounds."));
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
// check extension
|
|
107
|
-
if (opts.extensions.length > 0 && !opts.extensions.includes(data.params.e) && !opts.extensions.includes(data.params.f)) return next(new Error("illegal extension."));
|
|
107
|
+
if (opts.extensions.length > 0 && !opts.extensions.includes(data.req.params.e) && !opts.extensions.includes(data.req.params.f)) return next(new Error("illegal extension."));
|
|
108
108
|
|
|
109
109
|
// check density
|
|
110
|
-
if (opts.density && !opts.density.includes(data.params.d) && !opts.density.includes(data.params.f)) return next(new Error("illegal density marker."));
|
|
110
|
+
if (opts.density && !opts.density.includes(data.req.params.d) && !opts.density.includes(data.req.params.f)) return next(new Error("illegal density marker."));
|
|
111
111
|
|
|
112
112
|
// all passed
|
|
113
113
|
next();
|
package/builtins/compress.js
CHANGED
|
@@ -80,7 +80,7 @@ module.exports = function({ req, res, opts, data }, next){
|
|
|
80
80
|
}, [])).then(function(){
|
|
81
81
|
|
|
82
82
|
// set tile to best compressed tile client accepts FIXME find by buffer size?
|
|
83
|
-
const bestCompression = (opts.brotli && data.
|
|
83
|
+
const bestCompression = (opts.brotli && data.req.supports.br) ? "br" : (opts.gzip && data.req.supports.gz) ? "gzip" : null;
|
|
84
84
|
if (bestCompression) data.tile = data.tiles.find(function(tile){
|
|
85
85
|
return tile.compression === bestCompression && tile.mimetype === data.tile.mimetype && tile.filetype === data.tile.filetype;
|
|
86
86
|
}) || data.tile;
|
package/lib/store.js
CHANGED
|
@@ -6,10 +6,11 @@ const path = require("node:path");
|
|
|
6
6
|
const xattr = require("fs-xattr");
|
|
7
7
|
const rfc822date = require("./rfc822date");
|
|
8
8
|
|
|
9
|
-
const store = module.exports = function store({ root }){
|
|
9
|
+
const store = module.exports = function store({ root, ext }){
|
|
10
10
|
if (!(this instanceof store)) return new store(...arguments);
|
|
11
11
|
|
|
12
12
|
this.root = path.resolve(process.cwd(), root);
|
|
13
|
+
this.ext = ext || ".tmp";
|
|
13
14
|
this.cache = {}; // FIXME use lru cache
|
|
14
15
|
|
|
15
16
|
return this;
|
|
@@ -79,7 +80,7 @@ store.prototype.put = function(tile, fn){
|
|
|
79
80
|
const self = this;
|
|
80
81
|
|
|
81
82
|
const destfile = path.join(self.root, tile.path);
|
|
82
|
-
const tmpfile = destfile+
|
|
83
|
+
const tmpfile = destfile+self.ext;
|
|
83
84
|
|
|
84
85
|
// check if exists and still valid?
|
|
85
86
|
self.check(destfile, function(err, isValid){
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tileblaster",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "a quick and versatile map tile caching proxy",
|
|
5
5
|
"main": "tileblaster.js",
|
|
6
6
|
"bin": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"fs-xattr": "^0.3.1",
|
|
26
26
|
"klaw": "^4.1.0",
|
|
27
27
|
"minimist": "^1.2.8",
|
|
28
|
-
"node-watch": "^0.7.
|
|
28
|
+
"node-watch": "^0.7.4",
|
|
29
29
|
"phin": "^3.7.0",
|
|
30
30
|
"quu": "^0.4.3"
|
|
31
31
|
},
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"mbg": "^0.0.2",
|
|
36
36
|
"node-liblzma": "^1.1.9",
|
|
37
37
|
"optipng-js": "^0.1.2",
|
|
38
|
-
"pmtiles": "^2.
|
|
38
|
+
"pmtiles": "^2.10.0",
|
|
39
39
|
"sharp": "^0.32.4",
|
|
40
40
|
"versatiles": "^0.3.1",
|
|
41
41
|
"vtt": "^0.0.3"
|
|
@@ -48,6 +48,20 @@
|
|
|
48
48
|
"linux"
|
|
49
49
|
],
|
|
50
50
|
"keywords": [
|
|
51
|
-
"tileblaster",
|
|
51
|
+
"tileblaster",
|
|
52
|
+
"tileserver",
|
|
53
|
+
"map",
|
|
54
|
+
"tiles",
|
|
55
|
+
"tile",
|
|
56
|
+
"mbtiles",
|
|
57
|
+
"versatiles",
|
|
58
|
+
"pmtiles",
|
|
59
|
+
"server",
|
|
60
|
+
"proxy",
|
|
61
|
+
"cache",
|
|
62
|
+
"vectortiles",
|
|
63
|
+
"rastertiles",
|
|
64
|
+
"mvt",
|
|
65
|
+
"pbf"
|
|
52
66
|
]
|
|
53
67
|
}
|