import defaultValue from './defaultValue.js'
|
|
class CustomloadingImg {
|
constructor(options) {
|
this._errorEvent = new global.DC.Namespace.Cesium.Event()
|
this._tileWidth = 256
|
this._tileHeight = 256
|
// this._maximumLevel = 18
|
// this._minimumLevel = 1
|
|
var rectangle = defaultValue(options.rectangle, global.DC.Namespace.Cesium.Rectangle.MAX_VALUE)
|
this._tilingScheme = new global.DC.Namespace.Cesium.GeographicTilingScheme({
|
rectangle: rectangle,
|
numberOfLevelZeroTilesX: 13,
|
numberOfLevelZeroTilesY: 13
|
})
|
|
this._rectangle = this._tilingScheme.rectangle
|
|
var resource = global.DC.Namespace.Cesium.Resource.createIfNeeded(options.url)
|
|
this._resource = resource
|
|
this._tileDiscardPolicy = undefined
|
|
this._credit = undefined
|
|
this._readyPromise = undefined
|
}
|
|
get url () {
|
return this._resource.url
|
}
|
|
get proxy () {
|
return this._resource.proxy
|
}
|
|
get tileWidth () {
|
if (!this.ready) {
|
throw new global.DC.Namespace.Cesium.DeveloperError('tileWidth must not be called before the imagery provider is ready.')
|
}
|
return this._tileWidth
|
}
|
|
get tileHeight () {
|
if (!this.ready) {
|
throw new global.DC.Namespace.Cesium.DeveloperError('tileHeight must not be called before the imagery provider is ready.')
|
}
|
return this._tileHeight
|
}
|
|
get maximumLevel () {
|
if (!this.ready) {
|
throw new global.DC.Namespace.Cesium.DeveloperError('maximumLevel must not be called before the imagery provider is ready.')
|
}
|
return this._maximumLevel
|
}
|
|
get minimumLevel () {
|
if (!this.ready) {
|
throw new global.DC.Namespace.Cesium.DeveloperError('minimumLevel must not be called before the imagery provider is ready.')
|
}
|
return this._minimumLevel
|
}
|
|
get tilingScheme () {
|
if (!this.ready) {
|
throw new global.DC.Namespace.Cesium.DeveloperError('tilingScheme must not be called before the imagery provider is ready.')
|
}
|
return this._tilingScheme
|
}
|
|
get tileDiscardPolicy () {
|
if (!this.ready) {
|
throw new global.DC.Namespace.Cesium.DeveloperError('tileDiscardPolicy must not be called before the imagery provider is ready.')
|
}
|
return this._tileDiscardPolicy
|
}
|
|
get rectangle () {
|
if (!this.ready) {
|
throw new global.DC.Namespace.Cesium.DeveloperError('rectangle must not be called before the imagery provider is ready.')
|
}
|
return this._rectangle
|
}
|
|
get errorEvent () {
|
return this._errorEvent
|
}
|
|
get ready () {
|
return this._resource
|
}
|
|
get readyPromise () {
|
return this._readyPromise
|
}
|
|
get credit () {
|
if (!this.ready) {
|
throw new global.DC.Namespace.Cesium.DeveloperError('credit must not be called before the imagery provider is ready.')
|
}
|
return this._credit
|
}
|
|
requestImage (x, y, level, request) {
|
var r = this._tilingScheme.getNumberOfXTilesAtLevel(level)
|
var c = this._tilingScheme.getNumberOfYTilesAtLevel(level)
|
|
var s = this.url.replace('{x}', x).replace('{y}', y)
|
|
console.log('x:', x, 'y:', y, 'level:', level, 'url:', s)
|
|
return global.DC.Namespace.Cesium.ImageryProvider.loadImage(this, s)
|
}
|
}
|
|
export default CustomloadingImg
|