Merge branch 'master' of https://github.com/maptiler/tileserver-gl
This commit is contained in:
+20
-2
@@ -22,10 +22,28 @@ function tileToLat(tileY, zoom) {
|
|||||||
return (180.0 / Math.PI) * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n)));
|
return (180.0 / Math.PI) * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n)));
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getPublicUrl = (publicUrl, req) => publicUrl || `${req.protocol}://${req.headers.host}/`;
|
/**
|
||||||
|
* Generate new URL object
|
||||||
|
* @param req
|
||||||
|
* @params {object} req - Express request
|
||||||
|
* @returns {URL} object
|
||||||
|
*/
|
||||||
|
const getUrlObject = (req) => {
|
||||||
|
const urlObject = new URL(`${req.protocol}://${req.headers.host}/`);
|
||||||
|
// support overriding hostname by sending X-Forwarded-Host http header
|
||||||
|
urlObject.hostname = req.hostname;
|
||||||
|
return urlObject;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getPublicUrl = (publicUrl, req) => {
|
||||||
|
if (publicUrl) {
|
||||||
|
return publicUrl;
|
||||||
|
}
|
||||||
|
return getUrlObject(req).toString();
|
||||||
|
};
|
||||||
|
|
||||||
export const getTileUrls = (req, domains, path, format, publicUrl, aliases) => {
|
export const getTileUrls = (req, domains, path, format, publicUrl, aliases) => {
|
||||||
|
const urlObject = getUrlObject(req);
|
||||||
if (domains) {
|
if (domains) {
|
||||||
if (domains.constructor === String && domains.length > 0) {
|
if (domains.constructor === String && domains.length > 0) {
|
||||||
domains = domains.split(',');
|
domains = domains.split(',');
|
||||||
|
|||||||
Reference in New Issue
Block a user