From bc54968eb1585460fc44a24808254a284d08fc77 Mon Sep 17 00:00:00 2001 From: Kogis IWI Date: Fri, 18 Sep 2015 10:06:37 +0200 Subject: [PATCH] Use all url templates provided by terrain config file --- CHANGES.md | 1 + CONTRIBUTORS.md | 1 + Source/Core/CesiumTerrainProvider.js | 3 +-- Specs/Core/CesiumTerrainProviderSpec.js | 23 +++++++++++++++++++ .../MultipleUrls.tile.json | 12 ++++++++++ 5 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 Specs/Data/CesiumTerrainTileJson/MultipleUrls.tile.json diff --git a/CHANGES.md b/CHANGES.md index 3a1e221d9e1a..81263d8a459f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -18,6 +18,7 @@ Change Log * Added a workaround for Chrome 45, where the first character in a label with a small font size would not appear. [#3011](https://github.com/AnalyticalGraphicsInc/cesium/pull/3011) * Fixed issues causing the terrain and sky to disappear when the camera is near the surface. [#2415](https://github.com/AnalyticalGraphicsInc/cesium/issues/2415) and [#2271](https://github.com/AnalyticalGraphicsInc/cesium/issues/2271) * Changed the `ScreenSpaceCameraController.minimumZoomDistance` default from `20.0` to `1.0`. +* Used all the template urls defined in the CesiumTerrain provider.[#3038](https://github.com/AnalyticalGraphicsInc/cesium/pull/3038) ### 1.13 - 2015-09-01 diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 18170a9b08f9..715c683d669c 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -65,5 +65,6 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu * [Stéphane Lozier](https://github.com/slozier) * [Adam Cole](https://github.com/adamdavidcole) * [Tiffany Lu](https://github.com/tiffanylu) +* [Olivier Terral](https://github.com/oterral) Also see [our contributors page](http://cesiumjs.org/contributors.html) for more information. diff --git a/Source/Core/CesiumTerrainProvider.js b/Source/Core/CesiumTerrainProvider.js index 3651e92d9169..abd1781fab93 100644 --- a/Source/Core/CesiumTerrainProvider.js +++ b/Source/Core/CesiumTerrainProvider.js @@ -494,8 +494,7 @@ define([ var tmsY = (yTiles - y - 1); - // Use the first URL template. In the future we should use them all. - var url = urlTemplates[0].replace('{z}', level).replace('{x}', x).replace('{y}', tmsY); + var url = urlTemplates[(x + tmsY + level) % urlTemplates.length].replace('{z}', level).replace('{x}', x).replace('{y}', tmsY); var proxy = this._proxy; if (defined(proxy)) { diff --git a/Specs/Core/CesiumTerrainProviderSpec.js b/Specs/Core/CesiumTerrainProviderSpec.js index 8c7885755bf6..a99d534a2c17 100644 --- a/Specs/Core/CesiumTerrainProviderSpec.js +++ b/Specs/Core/CesiumTerrainProviderSpec.js @@ -354,6 +354,29 @@ defineSuite([ }); describe('requestTileGeometry', function() { + + it('uses multiple urls specified in layer.json', function() { + returnTileJson('Data/CesiumTerrainTileJson/MultipleUrls.tile.json'); + + var provider = new CesiumTerrainProvider({ + url : 'made/up/url' + }); + + return pollToPromise(function() { + return provider.ready; + }).then(function() { + spyOn(loadWithXhr, 'load'); + provider.requestTileGeometry(0, 0, 0); + expect(loadWithXhr.load.calls.mostRecent().args[0]).toContain('foo0.com'); + provider.requestTileGeometry(1, 0, 0); + expect(loadWithXhr.load.calls.mostRecent().args[0]).toContain('foo1.com'); + provider.requestTileGeometry(1, 1, 0); + expect(loadWithXhr.load.calls.mostRecent().args[0]).toContain('foo2.com'); + provider.requestTileGeometry(1, 1, 1); + expect(loadWithXhr.load.calls.mostRecent().args[0]).toContain('foo3.com'); + }); + }); + it('uses the proxy if one is supplied', function() { var baseUrl = 'made/up/url'; diff --git a/Specs/Data/CesiumTerrainTileJson/MultipleUrls.tile.json b/Specs/Data/CesiumTerrainTileJson/MultipleUrls.tile.json new file mode 100644 index 000000000000..9b4ab71a2945 --- /dev/null +++ b/Specs/Data/CesiumTerrainTileJson/MultipleUrls.tile.json @@ -0,0 +1,12 @@ +{ + "tilejson": "2.1.0", + "format" : "heightmap-1.0", + "version" : "1.0.0", + "scheme" : "tms", + "tiles" : [ + "//foo0.com/bar/{z}/{x}/{y}.terrain?v={version}", + "//foo1.com/bar/{z}/{x}/{y}.terrain?v={version}", + "//foo2.com/bar/{z}/{x}/{y}.terrain?v={version}", + "//foo3.com/bar/{z}/{x}/{y}.terrain?v={version}" + ] +}