tileblaster 1.0.2 → 1.0.3
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/check.js +9 -9
- package/builtins/compress.js +1 -1
- package/package.json +1 -1
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;
|