Closed 1a57danc3 closed 3 years ago
For all the servers providing ESPG:3857 (Web Mercator) tiles, all you need is to change the lines (what happened to don't reat yourself?) at https://github.com/derekhe/msfs2020-google-map/blob/f244a00b06657090fbaff6f3362bf2a0527629c3/offline-cache.py#L35 and https://github.com/derekhe/msfs2020-google-map/blob/f244a00b06657090fbaff6f3362bf2a0527629c3/server.py#L108
If you want Chinese sources like Baidu and Tianditu requiring coordinate-system conversion, see cntms
.
It should be ok. If you have credentials for mapbox, please change the code as your need.
@derekhe @Artoria2e5
Mapbox Tile URL Templates
https://api.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}.png?sku={yourSKUToken}&access_token={yourToken}
SKU Token and Access Token can apply mapbox free plan, 200,000 free tile requests per day.
This tool might be a GUI program(Use PyQt
or PyInstaller
package code to .exe file, to avoid user install python environment), and able to configure tile URL templates just like QGIS
Google Map Satellite
https://mt1.google.com/vt/lyrs=s&x={x}&y={y}&z={z}
Google Map Hybrid
https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}
Bing Map Satellite http://ecn.t3.tiles.virtualearth.net/tiles/a{q}.jpeg?g=1
Google Map https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}
OpenTopoMap
https://tile.opentopomap.org/{z}/{x}/{y}.png
OpenStreetMap
For China, google map is best :) I have use PyInstaller to create a exe file, but it reports virus when I update load to flightsim website. So I only give source code for that user. I recommended to use the exe file I made in release page.
I find a way to access Google Map satellite tile picture, avoid use local proxy.
Use Cloudflare Works service as reverse proxy
const config = {
basic: {
upstream: 'https://mt3.google.com',
mobileRedirect: 'https://mt3.google.com',
},
firewall: {
blockedRegion: [],
blockedIPAddress: [],
scrapeShield: true,
},
routes: {
},
optimization: {
cacheEverything: false,
cacheTtl: 5,
mirage: true,
polish: 'off',
minify: {
javascript: true,
css: true,
html: true,
},
},
};
async function isMobile(userAgent) {
const agents = ['Android', 'iPhone', 'SymbianOS', 'Windows Phone', 'iPad', 'iPod'];
return agents.any((agent) => userAgent.indexOf(agent) > 0);
}
async function fetchAndApply(request) {
const region = request.headers.get('cf-ipcountry') || '';
const ipAddress = request.headers.get('cf-connecting-ip') || '';
const userAgent = request.headers.get('user-agent') || '';
if (region !== '' && config.firewall.blockedRegion.includes(region.toUpperCase())) {
return new Response(
'Access denied: booster.js is not available in your region.',
{
status: 403,
},
);
} if (ipAddress !== '' && config.firewall.blockedIPAddress.includes(ipAddress)) {
return new Response(
'Access denied: Your IP address is blocked by booster.js.',
{
status: 403,
},
);
}
const requestURL = new URL(request.url);
let upstreamURL = null;
if (userAgent && isMobile(userAgent) === true) {
upstreamURL = new URL(config.basic.mobileRedirect);
} else if (region && region.toUpperCase() in config.routes) {
upstreamURL = new URL(config.routes[region.toUpperCase()]);
} else {
upstreamURL = new URL(config.basic.upstream);
}
requestURL.protocol = upstreamURL.protocol;
requestURL.host = upstreamURL.host;
requestURL.pathname = upstreamURL.pathname + requestURL.pathname;
let newRequest;
if (request.method === 'GET' || request.method === 'HEAD') {
newRequest = new Request(requestURL, {
cf: {
cacheEverything: config.optimization.cacheEverything,
cacheTtl: config.optimization.cacheTtl,
mirage: config.optimization.mirage,
polish: config.optimization.polish,
minify: config.optimization.minify,
scrapeShield: config.firewall.scrapeShield,
},
method: request.method,
headers: request.headers,
});
} else {
const requestBody = await request.text();
newRequest = new Request(requestURL, {
cf: {
cacheEverything: config.optimization.cacheEverything,
cacheTtl: config.optimization.cacheTtl,
mirage: config.optimization.mirage,
polish: config.optimization.polish,
minify: config.optimization.minify,
scrapeShield: config.firewall.scrapeShield,
},
method: request.method,
headers: request.headers,
body: requestBody,
});
}
const fetchedResponse = await fetch(newRequest);
const modifiedResponseHeaders = new Headers(fetchedResponse.headers);
if (modifiedResponseHeaders.has('x-pjax-url')) {
const pjaxURL = new URL(modifiedResponseHeaders.get('x-pjax-url'));
pjaxURL.protocol = requestURL.protocol;
pjaxURL.host = requestURL.host;
pjaxURL.pathname = pjaxURL.path.replace(requestURL.pathname, '/');
modifiedResponseHeaders.set(
'x-pjax-url',
pjaxURL.href,
);
}
return new Response(
fetchedResponse.body,
{
headers: modifiedResponseHeaders,
status: fetchedResponse.status,
statusText: fetchedResponse.statusText,
},
);
}
// eslint-disable-next-line no-restricted-globals
addEventListener('fetch', (event) => {
event.respondWith(fetchAndApply(event.request));
});
https://{yourDomain}/*
And select exist worker script
CNAME record target is {workerName}.{yourName}.workers.dev
Origin
https://mt3.google.com/vt/lyrs=s&x=106&y=52&z=7
Reverse Proxied
For China, google map is best :) I have use PyInstaller to create a exe file, but it reports virus when I update load to flightsim website. So I only give source code for that user. I recommended to use the exe file I made in release page.
I don't think so.
The new ZSQD is available now.
In Google Map satellite
In Mapbox satellite
Interesting, I see ChengDu is quite old image in mapbox
@derekhe Fine, ╮(╯_╰)╭ If config file can set custom tile URL template, that's good. And add a switch to control local proxy.
Such as :
[proxy]
# if you don't need proxy to access google or you want to use system proxy, please delete the following line
# if you use socks5 proxy, please set proxy value to true, and the url is like socks5h://127.0.0.1:1080
#url = http://192.168.3.191:1082
proxy = true
url = socks5://192.168.3.191:1080
[map]
tile = https://api.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}.png?sku={yourSKUToken}&access_token={yourToken}
[offline]
# use https://www.google.com/maps to pickup
north_west = 46.357879198300516, 83.39287198273128
south_east = 22.89205887817234, 123.91045032827455
# from zoom level to zoom level. Max zoom level should be 18.
range = 5, 12
max_cache_size_G = 20
threads = 200
@derekhe Fine, ╮(╯_╰)╭ If config file can set custom tile URL template, that's good.
Such as :
[map] tile = https://api.mapbox.com/v4/mapbox.satellite/{z}/{x}/{y}.png?sku={yourSKUToken}&access_token={yourToken}
Please pull request :)
Well, I mean, the cntms codebase should have all the features you guys need with respect to configuing URL templates. Just do a refactor, add some header and proxy settings and everything...
Thanks guys for discussion, will close this.
Mapbox satellite data is newest