@@ -9,6 +9,7 @@ import defineProperties from './defineProperties.js';
9
9
import DeveloperError from './DeveloperError.js' ;
10
10
import Event from './Event.js' ;
11
11
import GeographicTilingScheme from './GeographicTilingScheme.js' ;
12
+ import WebMercatorTilingScheme from './WebMercatorTilingScheme.js' ;
12
13
import getStringFromTypedArray from './getStringFromTypedArray.js' ;
13
14
import HeightmapTerrainData from './HeightmapTerrainData.js' ;
14
15
import IndexDatatype from './IndexDatatype.js' ;
@@ -72,18 +73,11 @@ import TileProviderError from './TileProviderError.js';
72
73
}
73
74
//>>includeEnd('debug');
74
75
75
- this . _tilingScheme = new GeographicTilingScheme ( {
76
- numberOfLevelZeroTilesX : 2 ,
77
- numberOfLevelZeroTilesY : 1 ,
78
- ellipsoid : options . ellipsoid
79
- } ) ;
80
-
81
76
this . _heightmapWidth = 65 ;
82
- this . _levelZeroMaximumGeometricError = TerrainProvider . getEstimatedLevelZeroGeometricErrorForAHeightmap ( this . _tilingScheme . ellipsoid , this . _heightmapWidth , this . _tilingScheme . getNumberOfXTilesAtLevel ( 0 ) ) ;
83
-
84
77
this . _heightmapStructure = undefined ;
85
78
this . _hasWaterMask = false ;
86
79
this . _hasVertexNormals = false ;
80
+ this . _ellipsoid = options . ellipsoid ;
87
81
88
82
/**
89
83
* Boolean flag that indicates if the client should request vertex normals from the server.
@@ -198,6 +192,38 @@ import TileProviderError from './TileProviderError.js';
198
192
var maxZoom = data . maxzoom ;
199
193
overallMaxZoom = Math . max ( overallMaxZoom , maxZoom ) ;
200
194
// Keeps track of which of the availablity containing tiles have been loaded
195
+
196
+ if ( ! data . projection || data . projection === 'EPSG:4326' ) {
197
+ that . _tilingScheme = new GeographicTilingScheme ( {
198
+ numberOfLevelZeroTilesX : 2 ,
199
+ numberOfLevelZeroTilesY : 1 ,
200
+ ellipsoid : that . _ellipsoid
201
+ } ) ;
202
+ } else if ( data . projection === 'EPSG:3857' ) {
203
+ that . _tilingScheme = new WebMercatorTilingScheme ( {
204
+ numberOfLevelZeroTilesX : 1 ,
205
+ numberOfLevelZeroTilesY : 1 ,
206
+ ellipsoid : that . _ellipsoid
207
+ } ) ;
208
+ } else {
209
+ message = 'The projection "' + data . projection + '" is invalid or not supported.' ;
210
+ metadataError = TileProviderError . handleError ( metadataError , that , that . _errorEvent , message , undefined , undefined , undefined , requestLayerJson ) ;
211
+ return ;
212
+ }
213
+
214
+ that . _levelZeroMaximumGeometricError = TerrainProvider . getEstimatedLevelZeroGeometricErrorForAHeightmap (
215
+ that . _tilingScheme . ellipsoid ,
216
+ that . _heightmapWidth ,
217
+ that . _tilingScheme . getNumberOfXTilesAtLevel ( 0 )
218
+ ) ;
219
+ if ( ! data . scheme || data . scheme === 'tms' || data . scheme === 'slippyMap' ) {
220
+ that . _scheme = data . scheme ;
221
+ } else {
222
+ message = 'The scheme "' + data . scheme + '" is invalid or not supported.' ;
223
+ metadataError = TileProviderError . handleError ( metadataError , that , that . _errorEvent , message , undefined , undefined , undefined , requestLayerJson ) ;
224
+ return ;
225
+ }
226
+
201
227
var availabilityTilesLoaded ;
202
228
203
229
// The vertex normals defined in the 'octvertexnormals' extension is identical to the original
@@ -402,7 +428,7 @@ import TileProviderError from './TileProviderError.js';
402
428
} ;
403
429
}
404
430
405
- function createHeightmapTerrainData ( provider , buffer , level , x , y , tmsY ) {
431
+ function createHeightmapTerrainData ( provider , buffer , level , x , y ) {
406
432
var heightBuffer = new Uint16Array ( buffer , 0 , provider . _heightmapWidth * provider . _heightmapWidth ) ;
407
433
return new HeightmapTerrainData ( {
408
434
buffer : heightBuffer ,
@@ -415,7 +441,7 @@ import TileProviderError from './TileProviderError.js';
415
441
} ) ;
416
442
}
417
443
418
- function createQuantizedMeshTerrainData ( provider , buffer , level , x , y , tmsY , layer ) {
444
+ function createQuantizedMeshTerrainData ( provider , buffer , level , x , y , layer ) {
419
445
var littleEndianExtensionSize = layer . littleEndianExtensionSize ;
420
446
var pos = 0 ;
421
447
var cartesian3Elements = 3 ;
@@ -633,9 +659,14 @@ import TileProviderError from './TileProviderError.js';
633
659
return undefined ;
634
660
}
635
661
636
- var yTiles = provider . _tilingScheme . getNumberOfYTilesAtLevel ( level ) ;
637
-
638
- var tmsY = ( yTiles - y - 1 ) ;
662
+ // The TileMapService scheme counts from the bottom left
663
+ var terrainY ;
664
+ if ( ! provider . _scheme || provider . _scheme === 'tms' ) {
665
+ var yTiles = provider . _tilingScheme . getNumberOfYTilesAtLevel ( level ) ;
666
+ terrainY = ( yTiles - y - 1 ) ;
667
+ } else {
668
+ terrainY = y ;
669
+ }
639
670
640
671
var extensionList = [ ] ;
641
672
if ( provider . _requestVertexNormals && layerToUse . hasVertexNormals ) {
@@ -650,7 +681,8 @@ import TileProviderError from './TileProviderError.js';
650
681
651
682
var headers ;
652
683
var query ;
653
- var url = urlTemplates [ ( x + tmsY + level ) % urlTemplates . length ] ;
684
+ var url = urlTemplates [ ( x + terrainY + level ) % urlTemplates . length ] ;
685
+
654
686
var resource = layerToUse . resource ;
655
687
if ( defined ( resource . _ionEndpoint ) && ! defined ( resource . _ionEndpoint . externalType ) ) {
656
688
// ion uses query paremeters to request extensions
@@ -669,7 +701,7 @@ import TileProviderError from './TileProviderError.js';
669
701
version : layerToUse . version ,
670
702
z : level ,
671
703
x : x ,
672
- y : tmsY
704
+ y : terrainY
673
705
} ,
674
706
queryParameters : query ,
675
707
headers : headers ,
@@ -682,9 +714,9 @@ import TileProviderError from './TileProviderError.js';
682
714
683
715
return promise . then ( function ( buffer ) {
684
716
if ( defined ( provider . _heightmapStructure ) ) {
685
- return createHeightmapTerrainData ( provider , buffer , level , x , y , tmsY ) ;
717
+ return createHeightmapTerrainData ( provider , buffer , level , x , y ) ;
686
718
}
687
- return createQuantizedMeshTerrainData ( provider , buffer , level , x , y , tmsY , layerToUse ) ;
719
+ return createQuantizedMeshTerrainData ( provider , buffer , level , x , y , layerToUse ) ;
688
720
} ) ;
689
721
}
690
722
0 commit comments