itowns
itowns copied to clipboard
Sources with multiple sub-domains are not working
Context
Sub-domains URL was added last year (#1189), to allow better load balancing on servers. While tests were added, we didn't test it with a real use case. You can try it with the following source:
const tmsSource = new itowns.TMSSource({
url: 'https://${u:a|b|c|d}.data.osmbuildings.org/0.2/anonymous/tile/15/${x}/${y}.json',
tileMatrixSet: 'PM',
isInverted: true,
projection: 'EPSG:4326',
format: 'application/json',
});
Expected Behavior
This should work.
Actual Behavior
It doesn't. Instead, it stops here, and throws this error: Uncaught TypeError: Failed to construct 'URL': Invalid URL.
Possible Cause/Fix/Solution
Change the way the host is read, by adding either a queue by subdomain(a.server.geo, b.server.geo and c.server.geo for ${u:a|b|c}.server.geo), or a host minus the subdomain, as a general queue (server.geo for ${u:a|b|c}.server.geo)