@openglobus/og 0.12.4 → 0.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -2
- package/dist/@openglobus/og.esm.js +2 -2
- package/dist/@openglobus/og.esm.js.map +1 -1
- package/dist/@openglobus/og.umd.js +2 -2
- package/dist/@openglobus/og.umd.js.map +1 -1
- package/package.json +7 -7
- package/src/og/Extent.js +3 -3
- package/src/og/Globe.js +277 -275
- package/src/og/ImageCanvas.js +3 -3
- package/src/og/LonLat.js +9 -9
- package/src/og/QueueArray.js +2 -2
- package/src/og/Rectangle.js +5 -5
- package/src/og/bv/Box.js +1 -1
- package/src/og/bv/Sphere.js +2 -2
- package/src/og/camera/Camera.js +1 -1
- package/src/og/camera/PlanetCamera.js +649 -646
- package/src/og/control/LayerSwitcher.js +1 -1
- package/src/og/control/MouseNavigation.js +22 -13
- package/src/og/control/MouseWheelZoomControl.js +2 -2
- package/src/og/control/ScaleControl.js +1 -1
- package/src/og/control/TouchNavigation.js +319 -319
- package/src/og/control/ZoomControl.js +132 -132
- package/src/og/control/visibleExtent/Segment.js +12 -12
- package/src/og/ellipsoid/Ellipsoid.js +577 -567
- package/src/og/entity/BillboardHandler.js +878 -1051
- package/src/og/entity/Entity.js +1 -1
- package/src/og/entity/EntityCollection.js +847 -857
- package/src/og/entity/GeoObjectHandler.js +2 -2
- package/src/og/entity/LabelHandler.js +887 -1040
- package/src/og/entity/LabelWorker.js +0 -6
- package/src/og/entity/PointCloud.js +495 -495
- package/src/og/entity/Polyline.js +2218 -2222
- package/src/og/entity/RayHandler.js +1 -1
- package/src/og/layer/CanvasTiles.js +6 -3
- package/src/og/layer/GeoImage.js +1 -1
- package/src/og/layer/KML.js +5 -5
- package/src/og/layer/Layer.js +800 -752
- package/src/og/layer/Vector.js +997 -1010
- package/src/og/layer/XYZ.js +359 -357
- package/src/og/math/Line2.js +4 -4
- package/src/og/math/Quat.js +2 -2
- package/src/og/math/Ray.js +2 -2
- package/src/og/math/Vec2.js +524 -524
- package/src/og/math/Vec3.js +900 -900
- package/src/og/math/Vec4.js +261 -261
- package/src/og/math.js +397 -398
- package/src/og/quadTree/EntityCollectionNode.js +389 -387
- package/src/og/renderer/Renderer.js +14 -20
- package/src/og/renderer/RendererEvents.js +1034 -1045
- package/src/og/scene/Planet.js +12 -9
- package/src/og/scene/RenderNode.js +347 -354
- package/src/og/segment/Segment.js +3 -1
- package/src/og/segment/SegmentLonLat.js +1 -4
- package/src/og/shaders/billboard.js +220 -204
- package/src/og/shaders/drawnode.js +607 -603
- package/src/og/shaders/label.js +576 -456
- package/src/og/shaders/polyline.js +365 -361
- package/src/og/terrain/MapboxTerrain.js +1 -1
- package/src/og/utils/FontAtlas.js +209 -200
- package/src/og/utils/GeoImageCreator.js +4 -5
- package/src/og/utils/TextureAtlas.js +4 -4
- package/src/og/utils/VectorTileCreator.js +414 -414
- package/src/og/utils/shared.js +1 -1
- package/src/og/webgl/Handler.js +28 -60
- package/src/og/webgl/Multisample.js +260 -260
- package/src/og/webgl/Program.js +411 -396
- package/types/bv/Box.d.ts +1 -1
- package/types/bv/Sphere.d.ts +1 -1
- package/types/camera/PlanetCamera.d.ts +3 -3
- package/types/control/LayerSwitcher.d.ts +1 -1
- package/types/ellipsoid/Ellipsoid.d.ts +9 -2
- package/types/entity/BillboardHandler.d.ts +0 -4
- package/types/entity/EntityCollection.d.ts +0 -8
- package/types/entity/LabelHandler.d.ts +0 -2
- package/types/entity/Polyline.d.ts +1 -1
- package/types/layer/KML.d.ts +11 -11
- package/types/layer/Layer.d.ts +4 -0
- package/types/layer/Vector.d.ts +1 -8
- package/types/math/Line2.d.ts +4 -4
- package/types/math/Ray.d.ts +2 -2
- package/types/math/Vec2.d.ts +1 -1
- package/types/math/Vec3.d.ts +1 -1
- package/types/math/Vec4.d.ts +2 -2
- package/types/math.d.ts +1 -1
- package/types/renderer/Renderer.d.ts +1 -1
- package/types/renderer/RendererEvents.d.ts +1 -1
- package/types/shaders/label.d.ts +1 -1
- package/types/utils/FontAtlas.d.ts +3 -2
- package/types/utils/TextureAtlas.d.ts +3 -3
- package/types/utils/VectorTileCreator.d.ts +4 -4
- package/types/utils/shared.d.ts +1 -1
- package/types/webgl/Handler.d.ts +6 -31
- package/types/webgl/Program.d.ts +2 -0
package/src/og/layer/Layer.js
CHANGED
|
@@ -1,318 +1,320 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @module og/layer/Layer
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
"use strict";
|
|
6
|
-
|
|
7
|
-
import * as utils from "../utils/shared.js";
|
|
8
|
-
import * as mercator from "../mercator.js";
|
|
9
|
-
import { Events } from "../Events.js";
|
|
10
|
-
import { Extent } from "../Extent.js";
|
|
11
|
-
import { LonLat } from "../LonLat.js";
|
|
12
|
-
import { Material } from "./Material.js";
|
|
13
|
-
import { Vec3 } from "../math/Vec3.js";
|
|
14
|
-
|
|
15
|
-
export const FADING_FACTOR = 0.29;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @classdesc
|
|
19
|
-
* Base class; normally only used for creating subclasses and not instantiated in apps.
|
|
20
|
-
* A visual representation of raster or vector map data well known as a layer.
|
|
21
|
-
* @class
|
|
22
|
-
* @param {String} [name="noname"] - Layer name.
|
|
23
|
-
* @param {Object} [options] - Layer options:
|
|
24
|
-
* @param {number} [options.opacity=1.0] - Layer opacity.
|
|
25
|
-
* @param {number} [options.minZoom=0] - Minimal visibility zoom level.
|
|
26
|
-
* @param {number} [options.maxZoom=0] - Maximal visibility zoom level.
|
|
27
|
-
* @param {string} [options.attribution] - Layer attribution that displayed in the attribution area on the screen.
|
|
28
|
-
* @param {boolean} [options.isBaseLayer=false] - This is a base layer.
|
|
29
|
-
* @param {boolean} [options.visibility=true] - Layer visibility.
|
|
30
|
-
* @param {boolean} [options.isSRGB=false] - Layer image webgl nternal format.
|
|
31
|
-
* @param {Extent} [options.extent=[[-180.0, -90.0], [180.0, 90.0]]] - Visible extent.
|
|
32
|
-
* @param {string} [options.textureFilter="anisotropic"] - Image texture filter. Available values: "nearest", "linear", "mipmap" and "anisotropic".
|
|
33
|
-
*
|
|
34
|
-
* @fires og.Layer#visibilitychange
|
|
35
|
-
* @fires og.Layer#add
|
|
36
|
-
* @fires og.Layer#remove
|
|
37
|
-
* @fires og.layer.Vector#mousemove
|
|
38
|
-
* @fires og.layer.Vector#mouseenter
|
|
39
|
-
* @fires og.layer.Vector#mouseleave
|
|
40
|
-
* @fires og.layer.Vector#lclick
|
|
41
|
-
* @fires og.layer.Vector#rclick
|
|
42
|
-
* @fires og.layer.Vector#mclick
|
|
43
|
-
* @fires og.layer.Vector#ldblclick
|
|
44
|
-
* @fires og.layer.Vector#rdblclick
|
|
45
|
-
* @fires og.layer.Vector#mdblclick
|
|
46
|
-
* @fires og.layer.Vector#lup
|
|
47
|
-
* @fires og.layer.Vector#rup
|
|
48
|
-
* @fires og.layer.Vector#mup
|
|
49
|
-
* @fires og.layer.Vector#ldown
|
|
50
|
-
* @fires og.layer.Vector#rdown
|
|
51
|
-
* @fires og.layer.Vector#mdown
|
|
52
|
-
* @fires og.layer.Vector#lhold
|
|
53
|
-
* @fires og.layer.Vector#rhold
|
|
54
|
-
* @fires og.layer.Vector#mhold
|
|
55
|
-
* @fires og.layer.Vector#mousewheel
|
|
56
|
-
* @fires og.layer.Vector#touchmove
|
|
57
|
-
* @fires og.layer.Vector#touchstart
|
|
58
|
-
* @fires og.layer.Vector#touchend
|
|
59
|
-
* @fires og.layer.Vector#doubletouch
|
|
60
|
-
*/
|
|
61
|
-
class Layer {
|
|
62
|
-
constructor(name, options = {}) {
|
|
63
|
-
/**
|
|
64
|
-
* Layer user name.
|
|
65
|
-
* @public
|
|
66
|
-
* @type {string}
|
|
67
|
-
*/
|
|
68
|
-
this.name = name || "noname";
|
|
69
|
-
|
|
70
|
-
this._labelMaxLetters = options.labelMaxLetters;
|
|
71
|
-
|
|
72
|
-
this.displayInLayerSwitcher =
|
|
73
|
-
options.displayInLayerSwitcher !== undefined ? options.displayInLayerSwitcher : true;
|
|
74
|
-
|
|
75
|
-
this._hasImageryTiles = true;
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Layer global opacity.
|
|
79
|
-
* @public
|
|
80
|
-
* @type {number}
|
|
81
|
-
*/
|
|
82
|
-
this._opacity = options.opacity || 1.0;
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Minimal zoom level when layer is visibile.
|
|
86
|
-
* @public
|
|
87
|
-
* @type {number}
|
|
88
|
-
*/
|
|
89
|
-
this.minZoom = options.minZoom || 0;
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Maximal zoom level when layer is visibile.
|
|
93
|
-
* @public
|
|
94
|
-
* @type {number}
|
|
95
|
-
*/
|
|
96
|
-
this.maxZoom = options.maxZoom || 50;
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Planet node.
|
|
100
|
-
* @protected
|
|
101
|
-
* @type {Planet}
|
|
102
|
-
*/
|
|
103
|
-
this._planet = null;
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Unic identifier.
|
|
107
|
-
* @protected
|
|
108
|
-
* @type {number}
|
|
109
|
-
*/
|
|
110
|
-
this._id = Layer.__layersCounter++;
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Layer attribution.
|
|
114
|
-
* @protected
|
|
115
|
-
* @type {string}
|
|
116
|
-
*/
|
|
117
|
-
this._attribution = options.attribution || "";
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Layer z-index.
|
|
121
|
-
* @protected
|
|
122
|
-
* @type {number}
|
|
123
|
-
*/
|
|
124
|
-
this._zIndex = options.zIndex || 0;
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Base layer type flag.
|
|
128
|
-
* @protected
|
|
129
|
-
* @type {boolean}
|
|
130
|
-
*/
|
|
131
|
-
this._isBaseLayer = options.isBaseLayer || false;
|
|
132
|
-
|
|
133
|
-
this._defaultTextures = options.defaultTextures || [null, null];
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Layer visibility.
|
|
137
|
-
* @protected
|
|
138
|
-
* @type {boolean}
|
|
139
|
-
*/
|
|
140
|
-
this._visibility = options.visibility !== undefined ? options.visibility : true;
|
|
141
|
-
|
|
142
|
-
this._fading = options.fading || false;
|
|
143
|
-
|
|
144
|
-
this._fadingFactor = FADING_FACTOR;
|
|
145
|
-
|
|
146
|
-
if (this._fading) {
|
|
147
|
-
this._fadingOpacity = this._visibility ? this._opacity : 0.0;
|
|
148
|
-
} else {
|
|
149
|
-
this._fadingOpacity = this._opacity;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Height over the ground.
|
|
154
|
-
* @protected
|
|
155
|
-
* @type {number}
|
|
156
|
-
*/
|
|
157
|
-
this._height = options.height || 0;
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Visible degrees extent.
|
|
161
|
-
* @protected
|
|
162
|
-
* @type {Extent}
|
|
163
|
-
*/
|
|
164
|
-
this._extent = null;
|
|
165
|
-
|
|
166
|
-
this.createTexture = null;
|
|
1
|
+
/**
|
|
2
|
+
* @module og/layer/Layer
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
import * as utils from "../utils/shared.js";
|
|
8
|
+
import * as mercator from "../mercator.js";
|
|
9
|
+
import { Events } from "../Events.js";
|
|
10
|
+
import { Extent } from "../Extent.js";
|
|
11
|
+
import { LonLat } from "../LonLat.js";
|
|
12
|
+
import { Material } from "./Material.js";
|
|
13
|
+
import { Vec3 } from "../math/Vec3.js";
|
|
14
|
+
|
|
15
|
+
export const FADING_FACTOR = 0.29;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @classdesc
|
|
19
|
+
* Base class; normally only used for creating subclasses and not instantiated in apps.
|
|
20
|
+
* A visual representation of raster or vector map data well known as a layer.
|
|
21
|
+
* @class
|
|
22
|
+
* @param {String} [name="noname"] - Layer name.
|
|
23
|
+
* @param {Object} [options] - Layer options:
|
|
24
|
+
* @param {number} [options.opacity=1.0] - Layer opacity.
|
|
25
|
+
* @param {number} [options.minZoom=0] - Minimal visibility zoom level.
|
|
26
|
+
* @param {number} [options.maxZoom=0] - Maximal visibility zoom level.
|
|
27
|
+
* @param {string} [options.attribution] - Layer attribution that displayed in the attribution area on the screen.
|
|
28
|
+
* @param {boolean} [options.isBaseLayer=false] - This is a base layer.
|
|
29
|
+
* @param {boolean} [options.visibility=true] - Layer visibility.
|
|
30
|
+
* @param {boolean} [options.isSRGB=false] - Layer image webgl nternal format.
|
|
31
|
+
* @param {Extent} [options.extent=[[-180.0, -90.0], [180.0, 90.0]]] - Visible extent.
|
|
32
|
+
* @param {string} [options.textureFilter="anisotropic"] - Image texture filter. Available values: "nearest", "linear", "mipmap" and "anisotropic".
|
|
33
|
+
*
|
|
34
|
+
* @fires og.Layer#visibilitychange
|
|
35
|
+
* @fires og.Layer#add
|
|
36
|
+
* @fires og.Layer#remove
|
|
37
|
+
* @fires og.layer.Vector#mousemove
|
|
38
|
+
* @fires og.layer.Vector#mouseenter
|
|
39
|
+
* @fires og.layer.Vector#mouseleave
|
|
40
|
+
* @fires og.layer.Vector#lclick
|
|
41
|
+
* @fires og.layer.Vector#rclick
|
|
42
|
+
* @fires og.layer.Vector#mclick
|
|
43
|
+
* @fires og.layer.Vector#ldblclick
|
|
44
|
+
* @fires og.layer.Vector#rdblclick
|
|
45
|
+
* @fires og.layer.Vector#mdblclick
|
|
46
|
+
* @fires og.layer.Vector#lup
|
|
47
|
+
* @fires og.layer.Vector#rup
|
|
48
|
+
* @fires og.layer.Vector#mup
|
|
49
|
+
* @fires og.layer.Vector#ldown
|
|
50
|
+
* @fires og.layer.Vector#rdown
|
|
51
|
+
* @fires og.layer.Vector#mdown
|
|
52
|
+
* @fires og.layer.Vector#lhold
|
|
53
|
+
* @fires og.layer.Vector#rhold
|
|
54
|
+
* @fires og.layer.Vector#mhold
|
|
55
|
+
* @fires og.layer.Vector#mousewheel
|
|
56
|
+
* @fires og.layer.Vector#touchmove
|
|
57
|
+
* @fires og.layer.Vector#touchstart
|
|
58
|
+
* @fires og.layer.Vector#touchend
|
|
59
|
+
* @fires og.layer.Vector#doubletouch
|
|
60
|
+
*/
|
|
61
|
+
class Layer {
|
|
62
|
+
constructor(name, options = {}) {
|
|
63
|
+
/**
|
|
64
|
+
* Layer user name.
|
|
65
|
+
* @public
|
|
66
|
+
* @type {string}
|
|
67
|
+
*/
|
|
68
|
+
this.name = name || "noname";
|
|
69
|
+
|
|
70
|
+
this._labelMaxLetters = options.labelMaxLetters;
|
|
71
|
+
|
|
72
|
+
this.displayInLayerSwitcher =
|
|
73
|
+
options.displayInLayerSwitcher !== undefined ? options.displayInLayerSwitcher : true;
|
|
74
|
+
|
|
75
|
+
this._hasImageryTiles = true;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Layer global opacity.
|
|
79
|
+
* @public
|
|
80
|
+
* @type {number}
|
|
81
|
+
*/
|
|
82
|
+
this._opacity = options.opacity || 1.0;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Minimal zoom level when layer is visibile.
|
|
86
|
+
* @public
|
|
87
|
+
* @type {number}
|
|
88
|
+
*/
|
|
89
|
+
this.minZoom = options.minZoom || 0;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Maximal zoom level when layer is visibile.
|
|
93
|
+
* @public
|
|
94
|
+
* @type {number}
|
|
95
|
+
*/
|
|
96
|
+
this.maxZoom = options.maxZoom || 50;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Planet node.
|
|
100
|
+
* @protected
|
|
101
|
+
* @type {Planet}
|
|
102
|
+
*/
|
|
103
|
+
this._planet = null;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Unic identifier.
|
|
107
|
+
* @protected
|
|
108
|
+
* @type {number}
|
|
109
|
+
*/
|
|
110
|
+
this._id = Layer.__layersCounter++;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Layer attribution.
|
|
114
|
+
* @protected
|
|
115
|
+
* @type {string}
|
|
116
|
+
*/
|
|
117
|
+
this._attribution = options.attribution || "";
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Layer z-index.
|
|
121
|
+
* @protected
|
|
122
|
+
* @type {number}
|
|
123
|
+
*/
|
|
124
|
+
this._zIndex = options.zIndex || 0;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Base layer type flag.
|
|
128
|
+
* @protected
|
|
129
|
+
* @type {boolean}
|
|
130
|
+
*/
|
|
131
|
+
this._isBaseLayer = options.isBaseLayer || false;
|
|
132
|
+
|
|
133
|
+
this._defaultTextures = options.defaultTextures || [null, null];
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Layer visibility.
|
|
137
|
+
* @protected
|
|
138
|
+
* @type {boolean}
|
|
139
|
+
*/
|
|
140
|
+
this._visibility = options.visibility !== undefined ? options.visibility : true;
|
|
141
|
+
|
|
142
|
+
this._fading = options.fading || false;
|
|
143
|
+
|
|
144
|
+
this._fadingFactor = FADING_FACTOR;
|
|
145
|
+
|
|
146
|
+
if (this._fading) {
|
|
147
|
+
this._fadingOpacity = this._visibility ? this._opacity : 0.0;
|
|
148
|
+
} else {
|
|
149
|
+
this._fadingOpacity = this._opacity;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Height over the ground.
|
|
154
|
+
* @protected
|
|
155
|
+
* @type {number}
|
|
156
|
+
*/
|
|
157
|
+
this._height = options.height || 0;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Visible degrees extent.
|
|
161
|
+
* @protected
|
|
162
|
+
* @type {Extent}
|
|
163
|
+
*/
|
|
164
|
+
this._extent = null;
|
|
165
|
+
|
|
166
|
+
this.createTexture = null;
|
|
167
167
|
|
|
168
168
|
this._textureFilter = options.textureFilter ? options.textureFilter.trim().toUpperCase() : "MIPMAP";
|
|
169
169
|
|
|
170
170
|
this._isSRGB = options.isSRGB != undefined ? options.isSRGB : false;
|
|
171
171
|
|
|
172
|
-
this._internalFormat = null;
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Visible mercator extent.
|
|
176
|
-
* @protected
|
|
177
|
-
* @type {Extent}
|
|
178
|
-
*/
|
|
179
|
-
this._extentMerc = null;
|
|
180
|
-
|
|
181
|
-
// Setting the extent up
|
|
182
|
-
this.setExtent(
|
|
183
|
-
utils.createExtent(
|
|
184
|
-
options.extent,
|
|
185
|
-
new Extent(new LonLat(-180, -90), new LonLat(180, 90))
|
|
186
|
-
)
|
|
187
|
-
);
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Layer picking color. Assign when added to the planet.
|
|
191
|
-
* @protected
|
|
192
|
-
* @type {Vec3}
|
|
193
|
-
*/
|
|
194
|
-
this._pickingColor = new Vec3();
|
|
195
|
-
|
|
172
|
+
this._internalFormat = null;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Visible mercator extent.
|
|
176
|
+
* @protected
|
|
177
|
+
* @type {Extent}
|
|
178
|
+
*/
|
|
179
|
+
this._extentMerc = null;
|
|
180
|
+
|
|
181
|
+
// Setting the extent up
|
|
182
|
+
this.setExtent(
|
|
183
|
+
utils.createExtent(
|
|
184
|
+
options.extent,
|
|
185
|
+
new Extent(new LonLat(-180, -90), new LonLat(180, 90))
|
|
186
|
+
)
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Layer picking color. Assign when added to the planet.
|
|
191
|
+
* @protected
|
|
192
|
+
* @type {Vec3}
|
|
193
|
+
*/
|
|
194
|
+
this._pickingColor = new Vec3();
|
|
195
|
+
|
|
196
196
|
this._pickingEnabled = options.pickingEnabled !== undefined ? options.pickingEnabled : true;
|
|
197
197
|
|
|
198
|
-
this._isPreloadDone = false;
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
*
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
*
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
this._fadingFactor = (opacity - this._opacity) / 2.8;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
*
|
|
285
|
-
* @
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
*
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
*
|
|
304
|
-
* @
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
*
|
|
314
|
-
* @
|
|
315
|
-
|
|
198
|
+
this._isPreloadDone = false;
|
|
199
|
+
|
|
200
|
+
this._preLoadZoomLevels = options.preLoadZoomLevels || [0, 1];
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Events handler.
|
|
204
|
+
* @public
|
|
205
|
+
* @type {Events}
|
|
206
|
+
*/
|
|
207
|
+
this.events = new Events(EVENT_NAMES, this);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
static getTMS(x, y, z) {
|
|
211
|
+
return {
|
|
212
|
+
x: x,
|
|
213
|
+
y: (1 << z) - y - 1,
|
|
214
|
+
z: z
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
static getTileIndex(...arr) {
|
|
219
|
+
return arr.join("_");
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
static get __layersCounter() {
|
|
223
|
+
if (!this.__lcounter && this.__lcounter !== 0) {
|
|
224
|
+
this.__lcounter = 0;
|
|
225
|
+
}
|
|
226
|
+
return this.__lcounter;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
static set __layersCounter(n) {
|
|
230
|
+
this.__lcounter = n;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
static get __requestsCounter() {
|
|
234
|
+
return this.__reqcounter;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
static set __requestsCounter(v) {
|
|
238
|
+
this.__reqcounter = v;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Maximum loading queries at one time.
|
|
243
|
+
* @const
|
|
244
|
+
* @type {number}
|
|
245
|
+
*/
|
|
246
|
+
static get MAX_REQUESTS() {
|
|
247
|
+
return 7;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
get instanceName() {
|
|
251
|
+
return "Layer";
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
get rendererEvents() {
|
|
255
|
+
return this.events;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
set opacity(opacity) {
|
|
259
|
+
if (this._fading) {
|
|
260
|
+
if (opacity > this._opacity) {
|
|
261
|
+
this._fadingFactor = (opacity - this._opacity) / 2.8;
|
|
262
|
+
} else if (opacity < this._opacity) {
|
|
263
|
+
this._fadingFactor = (opacity - this._opacity) / 2.8;
|
|
264
|
+
}
|
|
265
|
+
} else {
|
|
266
|
+
this._fadingOpacity = opacity;
|
|
267
|
+
}
|
|
268
|
+
this._opacity = opacity;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
get opacity() {
|
|
272
|
+
return this._opacity;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
set pickingEnabled(picking) {
|
|
276
|
+
this._pickingEnabled = picking ? 1.0 : 0.0;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
get pickingEnabled() {
|
|
280
|
+
return !!this._pickingEnabled;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Returns true if a layer has imagery tiles.
|
|
285
|
+
* @public
|
|
286
|
+
* @virtual
|
|
287
|
+
* @returns {boolean} - Imagery tiles flag.
|
|
288
|
+
*/
|
|
289
|
+
hasImageryTiles() {
|
|
290
|
+
return this._hasImageryTiles;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Gets layer identifier.
|
|
295
|
+
* @public
|
|
296
|
+
* @returns {string} - Layer object id.
|
|
297
|
+
*/
|
|
298
|
+
getID() {
|
|
299
|
+
return this._id;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Compares layers instances.
|
|
304
|
+
* @public
|
|
305
|
+
* @param {Layer} layer - Layer instance to compare.
|
|
306
|
+
* @returns {boolean} - Returns true if the layers is the same instance of the input.
|
|
307
|
+
*/
|
|
308
|
+
isEqual(layer) {
|
|
309
|
+
return layer._id === this._id;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Assign the planet.
|
|
314
|
+
* @protected
|
|
315
|
+
* @virtual
|
|
316
|
+
* @param {Planet} planet - Planet render node.
|
|
317
|
+
*/
|
|
316
318
|
_assignPlanet(planet) {
|
|
317
319
|
// TODO: webgl1
|
|
318
320
|
if (this._isSRGB) {
|
|
@@ -322,455 +324,501 @@ class Layer {
|
|
|
322
324
|
}
|
|
323
325
|
|
|
324
326
|
this.createTexture = planet.renderer.handler.createTexture[this._textureFilter];
|
|
325
|
-
|
|
326
|
-
planet.layers.push(this);
|
|
327
|
-
this._planet = planet;
|
|
328
|
-
this.events.on("visibilitychange", planet._onLayerVisibilityChanged, planet);
|
|
329
|
-
if (this._isBaseLayer && this._visibility) {
|
|
330
|
-
planet.setBaseLayer(this);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
this.
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
327
|
+
|
|
328
|
+
planet.layers.push(this);
|
|
329
|
+
this._planet = planet;
|
|
330
|
+
this.events.on("visibilitychange", planet._onLayerVisibilityChanged, planet);
|
|
331
|
+
if (this._isBaseLayer && this._visibility) {
|
|
332
|
+
planet.setBaseLayer(this);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
if (this._visibility && this.hasImageryTiles()) {
|
|
336
|
+
this._preLoad();
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
planet.events.dispatch(planet.events.layeradd, this);
|
|
340
|
+
this.events.dispatch(this.events.add, planet);
|
|
341
|
+
planet.updateVisibleLayers();
|
|
342
|
+
this._bindPicking();
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Assign picking color to the layer.
|
|
347
|
+
* @protected
|
|
348
|
+
* @virtual
|
|
349
|
+
*/
|
|
350
|
+
_bindPicking() {
|
|
351
|
+
this._planet && this._planet.renderer.assignPickingColor(this);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Adds layer to the planet.
|
|
356
|
+
* @public
|
|
357
|
+
* @param {Planet} planet - Adds layer to the planet.
|
|
358
|
+
*/
|
|
359
|
+
addTo(planet) {
|
|
360
|
+
if (!this._planet) {
|
|
361
|
+
this._assignPlanet(planet);
|
|
362
|
+
}
|
|
363
|
+
return this;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Removes from planet.
|
|
368
|
+
* @public
|
|
369
|
+
* @returns {Layer} -This layer.
|
|
370
|
+
*/
|
|
371
|
+
remove() {
|
|
372
|
+
var p = this._planet;
|
|
373
|
+
if (p) {
|
|
374
|
+
for (var i = 0; i < p.layers.length; i++) {
|
|
375
|
+
if (this.isEqual(p.layers[i])) {
|
|
376
|
+
p.renderer.clearPickingColor(this);
|
|
377
|
+
p.layers.splice(i, 1);
|
|
378
|
+
p.updateVisibleLayers();
|
|
379
|
+
this.clear();
|
|
380
|
+
p.events.dispatch(p.events.layerremove, this);
|
|
381
|
+
this.events.dispatch(this.events.remove, p);
|
|
382
|
+
this._planet = null;
|
|
383
|
+
return this;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
return this;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Clears layer material.
|
|
392
|
+
* @virtual
|
|
393
|
+
*/
|
|
394
|
+
clear() {
|
|
388
395
|
if (this._planet) {
|
|
389
396
|
this._planet._clearLayerMaterial(this);
|
|
390
397
|
this._internalFormat = null;
|
|
391
398
|
this.createTexture = null;
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
/**
|
|
396
|
-
* Returns planet instance.
|
|
397
|
-
* @virtual
|
|
398
|
-
*/
|
|
399
|
-
get planet() {
|
|
400
|
-
return this._planet;
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
/**
|
|
404
|
-
* Sets layer attribution text.
|
|
405
|
-
* @public
|
|
406
|
-
* @param {string} html - HTML code that represents layer attribution, it could be just a text.
|
|
407
|
-
*/
|
|
408
|
-
setAttribution(html) {
|
|
409
|
-
this._attribution = html;
|
|
410
|
-
this._planet && this._planet.updateAttributionsList();
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* Sets height over the ground.
|
|
415
|
-
* @public
|
|
416
|
-
* @param {number} height - Layer height.
|
|
417
|
-
*/
|
|
418
|
-
setHeight(height) {
|
|
419
|
-
this._height = height;
|
|
420
|
-
this._planet && this._planet.updateVisibleLayers();
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
/**
|
|
424
|
-
* Gets layer height.
|
|
425
|
-
* @public
|
|
426
|
-
* @returns {number} -
|
|
427
|
-
*/
|
|
428
|
-
getHeight() {
|
|
429
|
-
return this._height;
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
/**
|
|
433
|
-
* Sets z-index.
|
|
434
|
-
* @public
|
|
435
|
-
* @param {number} zIndex - Layer z-index.
|
|
436
|
-
*/
|
|
437
|
-
setZIndex(zIndex) {
|
|
438
|
-
this._zIndex = zIndex;
|
|
439
|
-
this._planet && this._planet.updateVisibleLayers();
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
/**
|
|
443
|
-
* Gets z-index.
|
|
444
|
-
* @public
|
|
445
|
-
* @returns {number} -
|
|
446
|
-
*/
|
|
447
|
-
getZIndex() {
|
|
448
|
-
return this._zIndex;
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
/**
|
|
452
|
-
* Set zIndex to the maximal value depend on other layers on the planet.
|
|
453
|
-
* @public
|
|
454
|
-
*/
|
|
455
|
-
bringToFront() {
|
|
456
|
-
if (this._planet) {
|
|
457
|
-
var vl = this._planet.visibleTileLayers;
|
|
458
|
-
var l = vl[vl.length - 1];
|
|
459
|
-
if (!l.isEqual(this)) {
|
|
460
|
-
this.setZIndex(l.getZIndex() + 1);
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
/**
|
|
466
|
-
* Returns true if the layer is a base.
|
|
467
|
-
* @public
|
|
468
|
-
* @returns {boolean} - Base layer flag.
|
|
469
|
-
*/
|
|
470
|
-
isBaseLayer() {
|
|
471
|
-
return this._isBaseLayer;
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
/**
|
|
475
|
-
* Sets base layer type true.
|
|
476
|
-
* @public
|
|
477
|
-
* @param {boolean} flag - Base layer flag.
|
|
478
|
-
*/
|
|
479
|
-
setBaseLayer(flag) {
|
|
480
|
-
this._isBaseLayer = flag;
|
|
481
|
-
if (this._planet) {
|
|
482
|
-
if (!flag && this.isEqual(this._planet.baseLayer)) {
|
|
483
|
-
this._planet.baseLayer = null;
|
|
484
|
-
}
|
|
485
|
-
this._planet.updateVisibleLayers();
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
/**
|
|
490
|
-
* Sets layer visibility.
|
|
491
|
-
* @public
|
|
492
|
-
* @virtual
|
|
493
|
-
* @param {boolean} visibility - Layer visibility.
|
|
494
|
-
*/
|
|
495
|
-
setVisibility(visibility) {
|
|
496
|
-
if (visibility !== this._visibility) {
|
|
497
|
-
this._visibility = visibility;
|
|
498
|
-
if (this._planet) {
|
|
499
|
-
if (this._isBaseLayer && visibility) {
|
|
500
|
-
this._planet.setBaseLayer(this);
|
|
501
|
-
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Returns planet instance.
|
|
404
|
+
* @virtual
|
|
405
|
+
*/
|
|
406
|
+
get planet() {
|
|
407
|
+
return this._planet;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Sets layer attribution text.
|
|
412
|
+
* @public
|
|
413
|
+
* @param {string} html - HTML code that represents layer attribution, it could be just a text.
|
|
414
|
+
*/
|
|
415
|
+
setAttribution(html) {
|
|
416
|
+
this._attribution = html;
|
|
417
|
+
this._planet && this._planet.updateAttributionsList();
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Sets height over the ground.
|
|
422
|
+
* @public
|
|
423
|
+
* @param {number} height - Layer height.
|
|
424
|
+
*/
|
|
425
|
+
setHeight(height) {
|
|
426
|
+
this._height = height;
|
|
427
|
+
this._planet && this._planet.updateVisibleLayers();
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/**
|
|
431
|
+
* Gets layer height.
|
|
432
|
+
* @public
|
|
433
|
+
* @returns {number} -
|
|
434
|
+
*/
|
|
435
|
+
getHeight() {
|
|
436
|
+
return this._height;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Sets z-index.
|
|
441
|
+
* @public
|
|
442
|
+
* @param {number} zIndex - Layer z-index.
|
|
443
|
+
*/
|
|
444
|
+
setZIndex(zIndex) {
|
|
445
|
+
this._zIndex = zIndex;
|
|
446
|
+
this._planet && this._planet.updateVisibleLayers();
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
/**
|
|
450
|
+
* Gets z-index.
|
|
451
|
+
* @public
|
|
452
|
+
* @returns {number} -
|
|
453
|
+
*/
|
|
454
|
+
getZIndex() {
|
|
455
|
+
return this._zIndex;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* Set zIndex to the maximal value depend on other layers on the planet.
|
|
460
|
+
* @public
|
|
461
|
+
*/
|
|
462
|
+
bringToFront() {
|
|
463
|
+
if (this._planet) {
|
|
464
|
+
var vl = this._planet.visibleTileLayers;
|
|
465
|
+
var l = vl[vl.length - 1];
|
|
466
|
+
if (!l.isEqual(this)) {
|
|
467
|
+
this.setZIndex(l.getZIndex() + 1);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Returns true if the layer is a base.
|
|
474
|
+
* @public
|
|
475
|
+
* @returns {boolean} - Base layer flag.
|
|
476
|
+
*/
|
|
477
|
+
isBaseLayer() {
|
|
478
|
+
return this._isBaseLayer;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/**
|
|
482
|
+
* Sets base layer type true.
|
|
483
|
+
* @public
|
|
484
|
+
* @param {boolean} flag - Base layer flag.
|
|
485
|
+
*/
|
|
486
|
+
setBaseLayer(flag) {
|
|
487
|
+
this._isBaseLayer = flag;
|
|
488
|
+
if (this._planet) {
|
|
489
|
+
if (!flag && this.isEqual(this._planet.baseLayer)) {
|
|
490
|
+
this._planet.baseLayer = null;
|
|
491
|
+
}
|
|
492
|
+
this._planet.updateVisibleLayers();
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Sets layer visibility.
|
|
498
|
+
* @public
|
|
499
|
+
* @virtual
|
|
500
|
+
* @param {boolean} visibility - Layer visibility.
|
|
501
|
+
*/
|
|
502
|
+
setVisibility(visibility) {
|
|
503
|
+
if (visibility !== this._visibility) {
|
|
504
|
+
this._visibility = visibility;
|
|
505
|
+
if (this._planet) {
|
|
506
|
+
if (this._isBaseLayer && visibility) {
|
|
507
|
+
this._planet.setBaseLayer(this);
|
|
508
|
+
}
|
|
502
509
|
this._planet.updateVisibleLayers();
|
|
503
510
|
if (visibility && !this._isPreloadDone && !this.isVector) {
|
|
504
511
|
this._isPreloadDone = true;
|
|
505
|
-
|
|
506
|
-
this._planet._preLoad();
|
|
512
|
+
this._preLoad();
|
|
507
513
|
}
|
|
508
|
-
}
|
|
509
|
-
this.events.dispatch(this.events.visibilitychange, this);
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
if (
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
/**
|
|
650
|
-
*
|
|
651
|
-
* @event og.Layer#
|
|
652
|
-
*/
|
|
653
|
-
"
|
|
654
|
-
|
|
655
|
-
/**
|
|
656
|
-
*
|
|
657
|
-
* @event og.Layer#
|
|
658
|
-
*/
|
|
659
|
-
"
|
|
660
|
-
|
|
661
|
-
/**
|
|
662
|
-
*
|
|
663
|
-
* @event og.Layer#
|
|
664
|
-
*/
|
|
665
|
-
"
|
|
666
|
-
|
|
667
|
-
/**
|
|
668
|
-
*
|
|
669
|
-
* @event og.Layer#
|
|
670
|
-
*/
|
|
671
|
-
"
|
|
672
|
-
|
|
673
|
-
/**
|
|
674
|
-
*
|
|
675
|
-
* @event og.Layer#
|
|
676
|
-
*/
|
|
677
|
-
"
|
|
678
|
-
|
|
679
|
-
/**
|
|
680
|
-
*
|
|
681
|
-
* @event og.Layer#
|
|
682
|
-
*/
|
|
683
|
-
"
|
|
684
|
-
|
|
685
|
-
/**
|
|
686
|
-
* Mouse
|
|
687
|
-
* @event og.Layer#
|
|
688
|
-
*/
|
|
689
|
-
"
|
|
690
|
-
|
|
691
|
-
/**
|
|
692
|
-
* Mouse
|
|
693
|
-
* @event og.Layer#
|
|
694
|
-
*/
|
|
695
|
-
"
|
|
696
|
-
|
|
697
|
-
/**
|
|
698
|
-
* Mouse
|
|
699
|
-
* @event og.Layer#
|
|
700
|
-
*/
|
|
701
|
-
"
|
|
702
|
-
|
|
703
|
-
/**
|
|
704
|
-
* Mouse
|
|
705
|
-
* @event og.Layer#
|
|
706
|
-
*/
|
|
707
|
-
"
|
|
708
|
-
|
|
709
|
-
/**
|
|
710
|
-
* Mouse
|
|
711
|
-
* @event og.Layer#
|
|
712
|
-
*/
|
|
713
|
-
"
|
|
714
|
-
|
|
715
|
-
/**
|
|
716
|
-
* Mouse
|
|
717
|
-
* @event og.Layer#
|
|
718
|
-
*/
|
|
719
|
-
"
|
|
720
|
-
|
|
721
|
-
/**
|
|
722
|
-
* Mouse
|
|
723
|
-
* @event og.Layer#
|
|
724
|
-
*/
|
|
725
|
-
"
|
|
726
|
-
|
|
727
|
-
/**
|
|
728
|
-
* Mouse
|
|
729
|
-
* @event og.Layer#
|
|
730
|
-
*/
|
|
731
|
-
"
|
|
732
|
-
|
|
733
|
-
/**
|
|
734
|
-
* Mouse
|
|
735
|
-
* @event og.Layer#
|
|
736
|
-
*/
|
|
737
|
-
"
|
|
738
|
-
|
|
739
|
-
/**
|
|
740
|
-
*
|
|
741
|
-
* @event og.Layer#
|
|
742
|
-
*/
|
|
743
|
-
"
|
|
744
|
-
|
|
745
|
-
/**
|
|
746
|
-
*
|
|
747
|
-
* @event og.Layer#
|
|
748
|
-
*/
|
|
749
|
-
"
|
|
750
|
-
|
|
751
|
-
/**
|
|
752
|
-
*
|
|
753
|
-
* @event og.Layer#
|
|
754
|
-
*/
|
|
755
|
-
"
|
|
756
|
-
|
|
757
|
-
/**
|
|
758
|
-
*
|
|
759
|
-
* @event og.Layer#
|
|
760
|
-
*/
|
|
761
|
-
"
|
|
762
|
-
|
|
763
|
-
/**
|
|
764
|
-
*
|
|
765
|
-
* @event og.Layer#
|
|
766
|
-
*/
|
|
767
|
-
"
|
|
768
|
-
|
|
769
|
-
/**
|
|
770
|
-
*
|
|
771
|
-
* @event og.Layer#
|
|
772
|
-
*/
|
|
773
|
-
"
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
514
|
+
}
|
|
515
|
+
this.events.dispatch(this.events.visibilitychange, this);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
_forceMaterialApply(segment) {
|
|
520
|
+
let pm = segment.materials,
|
|
521
|
+
m = pm[this._id];
|
|
522
|
+
|
|
523
|
+
if (!m) {
|
|
524
|
+
m = pm[this._id] = this.createMaterial(segment);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
if (!m.isReady) {
|
|
528
|
+
this._planet._renderCompleted = false;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
this.applyMaterial(m);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
_preLoadRecursive(node, maxZoom) {
|
|
535
|
+
if (node.segment.tileZoom > maxZoom) {
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
if (this._preLoadZoomLevels.includes(node.segment.tileZoom)) {
|
|
539
|
+
this._forceMaterialApply(node.segment);
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
for (let i = 0, len = node.nodes.length; i < len; i++) {
|
|
543
|
+
if (node.nodes[i]) {
|
|
544
|
+
this._preLoadRecursive(node.nodes[i], maxZoom);
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
_preLoad() {
|
|
550
|
+
if (this._planet && this._preLoadZoomLevels.length) {
|
|
551
|
+
|
|
552
|
+
let p = this._planet,
|
|
553
|
+
maxZoom = Math.max(...this._preLoadZoomLevels);
|
|
554
|
+
|
|
555
|
+
this._preLoadRecursive(p._quadTreeSouth, maxZoom);
|
|
556
|
+
this._preLoadRecursive(p._quadTreeNorth, maxZoom);
|
|
557
|
+
this._preLoadRecursive(p._quadTree, maxZoom);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* Gets layer visibility.
|
|
563
|
+
* @public
|
|
564
|
+
* @returns {boolean} - Layer visibility.
|
|
565
|
+
*/
|
|
566
|
+
getVisibility() {
|
|
567
|
+
return this._visibility;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
* Sets visible geographical extent.
|
|
572
|
+
* @public
|
|
573
|
+
* @param {Extent} extent - Layer visible geographical extent.
|
|
574
|
+
*/
|
|
575
|
+
setExtent(extent) {
|
|
576
|
+
var sw = extent.southWest.clone(),
|
|
577
|
+
ne = extent.northEast.clone();
|
|
578
|
+
if (sw.lat < mercator.MIN_LAT) {
|
|
579
|
+
sw.lat = mercator.MIN_LAT;
|
|
580
|
+
}
|
|
581
|
+
if (ne.lat > mercator.MAX_LAT) {
|
|
582
|
+
ne.lat = mercator.MAX_LAT;
|
|
583
|
+
}
|
|
584
|
+
this._extent = extent.clone();
|
|
585
|
+
this._extentMerc = new Extent(sw.forwardMercator(), ne.forwardMercator());
|
|
586
|
+
this._correctFullExtent();
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
/**
|
|
590
|
+
* Gets layer extent.
|
|
591
|
+
* @public
|
|
592
|
+
* @return {Extent} - Layer geodetic extent.
|
|
593
|
+
*/
|
|
594
|
+
getExtent() {
|
|
595
|
+
return this._extent;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* Special correction of the whole globe extent.
|
|
600
|
+
* @protected
|
|
601
|
+
*/
|
|
602
|
+
_correctFullExtent() {
|
|
603
|
+
// var e = this._extent,
|
|
604
|
+
// em = this._extentMerc;
|
|
605
|
+
// var ENLARGE_MERCATOR_LON = og.mercator.POLE + 50000;
|
|
606
|
+
// var ENLARGE_MERCATOR_LAT = og.mercator.POLE + 50000;
|
|
607
|
+
// if (e.northEast.lat === 90.0) {
|
|
608
|
+
// em.northEast.lat = ENLARGE_MERCATOR_LAT;
|
|
609
|
+
// }
|
|
610
|
+
// if (e.northEast.lon === 180.0) {
|
|
611
|
+
// em.northEast.lon = ENLARGE_MERCATOR_LON;
|
|
612
|
+
// }
|
|
613
|
+
// if (e.southWest.lat === -90.0) {
|
|
614
|
+
// em.southWest.lat = -ENLARGE_MERCATOR_LAT;
|
|
615
|
+
// }
|
|
616
|
+
// if (e.southWest.lon === -180.0) {
|
|
617
|
+
// em.southWest.lon = -ENLARGE_MERCATOR_LON;
|
|
618
|
+
// }
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
_refreshFadingOpacity() {
|
|
622
|
+
var p = this._planet;
|
|
623
|
+
if (
|
|
624
|
+
this._visibility &&
|
|
625
|
+
p._viewExtent &&
|
|
626
|
+
p._viewExtent.overlaps(this._extent) &&
|
|
627
|
+
p.maxCurrZoom >= this.minZoom &&
|
|
628
|
+
p.minCurrZoom <= this.maxZoom
|
|
629
|
+
) {
|
|
630
|
+
this._fadingOpacity += this._fadingFactor;
|
|
631
|
+
|
|
632
|
+
if (
|
|
633
|
+
(this._fadingFactor > 0.0 && this._fadingOpacity > this._opacity) ||
|
|
634
|
+
(this._fadingFactor < 0.0 && this._fadingOpacity < this._opacity)
|
|
635
|
+
) {
|
|
636
|
+
this._fadingOpacity = this._opacity;
|
|
637
|
+
}
|
|
638
|
+
return false;
|
|
639
|
+
} else {
|
|
640
|
+
this._fadingOpacity -= FADING_FACTOR;
|
|
641
|
+
|
|
642
|
+
if (this._fadingOpacity < 0.0) {
|
|
643
|
+
this._fadingOpacity = 0.0;
|
|
644
|
+
return !this._visibility;
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
createMaterial(segment) {
|
|
650
|
+
return new Material(segment, this);
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
const EVENT_NAMES = [
|
|
655
|
+
/**
|
|
656
|
+
* Triggered when layer visibilty chanched.
|
|
657
|
+
* @event og.Layer#visibilitychange
|
|
658
|
+
*/
|
|
659
|
+
"visibilitychange",
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* Triggered when layer has added to the planet.
|
|
663
|
+
* @event og.Layer#add
|
|
664
|
+
*/
|
|
665
|
+
"add",
|
|
666
|
+
|
|
667
|
+
/**
|
|
668
|
+
* Triggered when layer has removed from the planet.
|
|
669
|
+
* @event og.Layer#remove
|
|
670
|
+
*/
|
|
671
|
+
"remove",
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* Triggered when mouse moves over the layer.
|
|
675
|
+
* @event og.Layer#mousemove
|
|
676
|
+
*/
|
|
677
|
+
"mousemove",
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* Triggered when mouse has entered over the layer.
|
|
681
|
+
* @event og.Layer#mouseenter
|
|
682
|
+
*/
|
|
683
|
+
"mouseenter",
|
|
684
|
+
|
|
685
|
+
/**
|
|
686
|
+
* Triggered when mouse leaves the layer.
|
|
687
|
+
* @event og.Layer#mouseenter
|
|
688
|
+
*/
|
|
689
|
+
"mouseleave",
|
|
690
|
+
|
|
691
|
+
/**
|
|
692
|
+
* Mouse left button clicked.
|
|
693
|
+
* @event og.Layer#lclick
|
|
694
|
+
*/
|
|
695
|
+
"lclick",
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* Mouse right button clicked.
|
|
699
|
+
* @event og.Layer#rclick
|
|
700
|
+
*/
|
|
701
|
+
"rclick",
|
|
702
|
+
|
|
703
|
+
/**
|
|
704
|
+
* Mouse right button clicked.
|
|
705
|
+
* @event og.Layer#mclick
|
|
706
|
+
*/
|
|
707
|
+
"mclick",
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* Mouse left button double click.
|
|
711
|
+
* @event og.Layer#ldblclick
|
|
712
|
+
*/
|
|
713
|
+
"ldblclick",
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* Mouse right button double click.
|
|
717
|
+
* @event og.Layer#rdblclick
|
|
718
|
+
*/
|
|
719
|
+
"rdblclick",
|
|
720
|
+
|
|
721
|
+
/**
|
|
722
|
+
* Mouse middle button double click.
|
|
723
|
+
* @event og.Layer#mdblclick
|
|
724
|
+
*/
|
|
725
|
+
"mdblclick",
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* Mouse left button up(stop pressing).
|
|
729
|
+
* @event og.Layer#lup
|
|
730
|
+
*/
|
|
731
|
+
"lup",
|
|
732
|
+
|
|
733
|
+
/**
|
|
734
|
+
* Mouse right button up(stop pressing).
|
|
735
|
+
* @event og.Layer#rup
|
|
736
|
+
*/
|
|
737
|
+
"rup",
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* Mouse middle button up(stop pressing).
|
|
741
|
+
* @event og.Layer#mup
|
|
742
|
+
*/
|
|
743
|
+
"mup",
|
|
744
|
+
|
|
745
|
+
/**
|
|
746
|
+
* Mouse left button is just pressed down(start pressing).
|
|
747
|
+
* @event og.Layer#ldown
|
|
748
|
+
*/
|
|
749
|
+
"ldown",
|
|
750
|
+
|
|
751
|
+
/**
|
|
752
|
+
* Mouse right button is just pressed down(start pressing).
|
|
753
|
+
* @event og.Layer#rdown
|
|
754
|
+
*/
|
|
755
|
+
"rdown",
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* Mouse middle button is just pressed down(start pressing).
|
|
759
|
+
* @event og.Layer#mdown
|
|
760
|
+
*/
|
|
761
|
+
"mdown",
|
|
762
|
+
|
|
763
|
+
/**
|
|
764
|
+
* Mouse left button is pressing.
|
|
765
|
+
* @event og.Layer#lhold
|
|
766
|
+
*/
|
|
767
|
+
"lhold",
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
* Mouse right button is pressing.
|
|
771
|
+
* @event og.Layer#rhold
|
|
772
|
+
*/
|
|
773
|
+
"rhold",
|
|
774
|
+
|
|
775
|
+
/**
|
|
776
|
+
* Mouse middle button is pressing.
|
|
777
|
+
* @event og.Layer#mhold
|
|
778
|
+
*/
|
|
779
|
+
"mhold",
|
|
780
|
+
|
|
781
|
+
/**
|
|
782
|
+
* Mouse wheel is rotated.
|
|
783
|
+
* @event og.Layer#mousewheel
|
|
784
|
+
*/
|
|
785
|
+
"mousewheel",
|
|
786
|
+
|
|
787
|
+
/**
|
|
788
|
+
* Triggered when touching moves over the layer.
|
|
789
|
+
* @event og.Layer#touchmove
|
|
790
|
+
*/
|
|
791
|
+
"touchmove",
|
|
792
|
+
|
|
793
|
+
/**
|
|
794
|
+
* Triggered when layer begins to touch.
|
|
795
|
+
* @event og.Layer#touchstart
|
|
796
|
+
*/
|
|
797
|
+
"touchstart",
|
|
798
|
+
|
|
799
|
+
/**
|
|
800
|
+
* Triggered when layer has finished touching.
|
|
801
|
+
* @event og.Layer#touchend
|
|
802
|
+
*/
|
|
803
|
+
"touchend",
|
|
804
|
+
|
|
805
|
+
/**
|
|
806
|
+
* Triggered layer has double touched.
|
|
807
|
+
* @event og.Layer#doubletouch
|
|
808
|
+
*/
|
|
809
|
+
"doubletouch",
|
|
810
|
+
|
|
811
|
+
/**
|
|
812
|
+
* Triggered when touching leaves layer borders.
|
|
813
|
+
* @event og.Layer#touchleave
|
|
814
|
+
*/
|
|
815
|
+
"touchleave",
|
|
816
|
+
|
|
817
|
+
/**
|
|
818
|
+
* Triggered when touch enters over the layer.
|
|
819
|
+
* @event og.Layer#touchenter
|
|
820
|
+
*/
|
|
821
|
+
"touchenter"
|
|
822
|
+
];
|
|
823
|
+
|
|
824
|
+
export { Layer };
|