diff --git a/Source/Scene/CesiumTerrainProvider.js b/Source/Scene/CesiumTerrainProvider.js index dc61ff92351d..44ead31016a8 100644 --- a/Source/Scene/CesiumTerrainProvider.js +++ b/Source/Scene/CesiumTerrainProvider.js @@ -120,9 +120,11 @@ define([ return; } + var baseUri = new Uri(metadataUrl); + that._tileUrlTemplates = data.tiles; for (var i = 0; i < that._tileUrlTemplates.length; ++i) { - that._tileUrlTemplates[i] = Uri.resolve(that._tileUrlTemplates[i], metadataUrl).replace('{version}', data.version); + that._tileUrlTemplates[i] = new Uri(that._tileUrlTemplates[i]).resolve(baseUri).toString().replace('{version}', data.version); } that._availableTiles = data.available; diff --git a/Source/ThirdParty/Uri.js b/Source/ThirdParty/Uri.js index 167f88ca954c..08bcb5d2d8d1 100644 --- a/Source/ThirdParty/Uri.js +++ b/Source/ThirdParty/Uri.js @@ -242,19 +242,20 @@ define(function() { this.path = output.join('/'); }; - /** - * Resolves a relative URI against an absolute base URI. - * Convenience method. - * @param {String} uri the relative URI to resolve - * @param {String} baseURI the base URI (must be absolute) to resolve against - */ - URI.resolve = function(sURI, sBaseURI) { - var uri = cache[sURI] || (cache[sURI] = new URI(sURI)); - var baseURI = cache[sBaseURI] || (cache[sBaseURI] = new URI(sBaseURI)); - return uri.resolve(baseURI).toString(); - }; + // We don't like this function because it builds up a cache that is never cleared. +// /** +// * Resolves a relative URI against an absolute base URI. +// * Convenience method. +// * @param {String} uri the relative URI to resolve +// * @param {String} baseURI the base URI (must be absolute) to resolve against +// */ +// URI.resolve = function(sURI, sBaseURI) { +// var uri = cache[sURI] || (cache[sURI] = new URI(sURI)); +// var baseURI = cache[sBaseURI] || (cache[sBaseURI] = new URI(sBaseURI)); +// return uri.resolve(baseURI).toString(); +// }; - var cache = {}; +// var cache = {}; /** * Serialises the URI to a string.