赣州市洪水风险预警系统三维版本
guoshilong
2023-02-27 4d8c6dd77427e8e581fda17b6b65ba86bfb7a815
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import defined from '../Core/defined.js';
import destroyObject from '../Core/destroyObject.js';
import ImageryState from './ImageryState.js';
 
    /**
     * Stores details about a tile of imagery.
     *
     * @alias Imagery
     * @private
     */
    function Imagery(imageryLayer, x, y, level, rectangle) {
        this.imageryLayer = imageryLayer;
        this.x = x;
        this.y = y;
        this.level = level;
        this.request = undefined;
 
        if (level !== 0) {
            var parentX = x / 2 | 0;
            var parentY = y / 2 | 0;
            var parentLevel = level - 1;
            this.parent = imageryLayer.getImageryFromCache(parentX, parentY, parentLevel);
        }
 
        this.state = ImageryState.UNLOADED;
        this.imageUrl = undefined;
        this.image = undefined;
        this.texture = undefined;
        this.textureWebMercator = undefined;
        this.credits = undefined;
        this.referenceCount = 0;
 
        if (!defined(rectangle) && imageryLayer.imageryProvider.ready) {
            var tilingScheme = imageryLayer.imageryProvider.tilingScheme;
            rectangle = tilingScheme.tileXYToRectangle(x, y, level);
        }
 
        this.rectangle = rectangle;
    }
    Imagery.createPlaceholder = function(imageryLayer) {
        var result = new Imagery(imageryLayer, 0, 0, 0);
        result.addReference();
        result.state = ImageryState.PLACEHOLDER;
        return result;
    };
 
    Imagery.prototype.addReference = function() {
        ++this.referenceCount;
    };
 
    Imagery.prototype.releaseReference = function() {
        --this.referenceCount;
 
        if (this.referenceCount === 0) {
            this.imageryLayer.removeImageryFromCache(this);
 
            if (defined(this.parent)) {
                this.parent.releaseReference();
            }
 
            if (defined(this.image) && defined(this.image.destroy)) {
                this.image.destroy();
            }
 
            if (defined(this.texture)) {
                this.texture.destroy();
            }
 
            if (defined(this.textureWebMercator) && this.texture !== this.textureWebMercator) {
                this.textureWebMercator.destroy();
            }
 
            destroyObject(this);
 
            return 0;
        }
 
        return this.referenceCount;
    };
 
    Imagery.prototype.processStateMachine = function(frameState, needGeographicProjection, skipLoading) {
        if (this.state === ImageryState.UNLOADED && !skipLoading) {
            this.state = ImageryState.TRANSITIONING;
            this.imageryLayer._requestImagery(this);
        }
 
        if (this.state === ImageryState.RECEIVED) {
            this.state = ImageryState.TRANSITIONING;
            this.imageryLayer._createTexture(frameState.context, this);
        }
 
        // If the imagery is already ready, but we need a geographic version and don't have it yet,
        // we still need to do the reprojection step. This can happen if the Web Mercator version
        // is fine initially, but the geographic one is needed later.
        var needsReprojection = this.state === ImageryState.READY && needGeographicProjection && !this.texture;
 
        if (this.state === ImageryState.TEXTURE_LOADED || needsReprojection) {
            this.state = ImageryState.TRANSITIONING;
            this.imageryLayer._reprojectTexture(frameState, this, needGeographicProjection);
        }
    };
export default Imagery;