@openglobus/og 0.13.5 → 0.13.6

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.
@@ -1,148 +1,161 @@
1
- /**
2
- * @module og/terrainProvider/EmptyTerrain
3
- */
4
-
5
- "use strict";
6
-
7
- import { binarySearchFast } from "../utils/shared.js";
8
-
9
- /**
10
- * Class represents terrain provider without elevation data.
11
- * @class
12
- */
13
- class EmptyTerrain {
14
- constructor(options = {}) {
15
- this.equalizeVertices = false;
16
-
1
+ /**
2
+ * @module og/terrainProvider/EmptyTerrain
3
+ */
4
+
5
+ "use strict";
6
+
7
+ import { binarySearchFast } from "../utils/shared.js";
8
+ import { Geoid } from "./Geoid.js";
9
+
10
+ /**
11
+ * Class represents terrain provider without elevation data.
12
+ * @class
13
+ */
14
+ class EmptyTerrain {
15
+ constructor(options = {}) {
16
+ this.equalizeVertices = false;
17
+
17
18
  this.equalizeNormals = false;
18
19
 
19
- this.isEmpty = true;
20
-
21
- /**
22
- * Provider name is "empty"
23
- * @public
24
- * @type {string}
25
- */
26
- this.name = "empty";
27
-
28
- /**
29
- * Minimal z-index value for segment elevation data handling.
30
- * @public
31
- * @type {number}
32
- */
33
- this.minZoom = 1000000;
34
-
35
- /**
36
- * Maximal z-index value for segment elevation data handling.
37
- * @public
38
- * @type {number}
39
- */
40
- this.maxZoom = 21;
41
-
42
- /**
43
- * @public
44
- * @type {Array.<number>}
45
- */
46
- this.gridSizeByZoom = options.gridSizeByZoom || [
47
- 32, 16, 16, 8, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
48
- ];
49
- //this.gridSizeByZoom = options.gridSizeByZoom || [32, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2];
50
-
51
- this._maxNodeZoom = this.gridSizeByZoom.length - 1;
52
-
53
- /**
54
- * Elevation grid size. Currend is 2x2 is the smallest grid size.
55
- * @public
56
- * @type {number}
57
- */
58
- this.plainGridSize = 2;
59
-
60
- /**
61
- * Planet node.
62
- * @protected
63
- * @type {Planet}
64
- */
65
- this._planet = null;
66
-
67
- this._geoid = null;
68
-
69
- // const _ellToAltFn = [
70
- // (lon, lat, alt, callback) => callback(alt),
71
- // (lon, lat, alt, callback) => callback(alt - this._geoid.getHeight(lon, lat)),
72
- // (lon, lat, alt, callback) => {
73
-
74
- // let x = mercator.getTileX(lon, zoom),
75
- // y = mercator.getTileY(lat, zoom);
76
-
77
- // let mslAlt = alt - this._geoid.getHeight(lon, lat);
78
-
79
- // if (true) {
80
-
81
- // } else {
82
-
83
- // }
84
-
85
- // return callback(mslAlt);
86
- // },
87
- // ];
88
- }
89
-
90
- static checkNoDataValue(noDataValues, value) {
91
- return binarySearchFast(noDataValues, value) !== -1;
92
- }
93
-
94
- isBlur() {
95
- return false;
96
- }
97
-
98
- set maxNodeZoom(val) {
99
- if (val > this.gridSizeByZoom.length - 1) {
100
- val = this.gridSizeByZoom.length - 1;
101
- }
102
- this._maxNodeZoom = val;
103
- }
104
-
105
- get maxNodeZoom() {
106
- return this._maxNodeZoom;
107
- }
108
-
109
- set geoid(geoid) {
110
- this._geoid = geoid;
111
- }
112
-
113
- get geoid() {
114
- return this._geoid;
115
- }
116
-
117
- /**
118
- * Loads or creates segment elevation data.
119
- * @public
120
- * @virtual
121
- * @param {Segment} segment - Segment to create elevation data.
122
- */
123
- handleSegmentTerrain(segment) {
124
- segment.terrainIsLoading = false;
125
- segment.terrainReady = true;
126
- segment.terrainExists = true;
127
- }
128
-
129
- isReady() {
130
- return (this._geoid && this._geoid.model) || !this._geoid;
131
- }
132
-
133
- /**
134
- * Abstract function
135
- * @public
136
- * @abstract
137
- */
138
- abortLoading() {}
139
-
140
- /**
141
- * Abstract function
142
- * @public
143
- * @abstract
144
- */
145
- clearCache() {}
146
- }
147
-
148
- export { EmptyTerrain };
20
+ this.isEmpty = true;
21
+
22
+ /**
23
+ * Provider name is "empty"
24
+ * @public
25
+ * @type {string}
26
+ */
27
+ this.name = "empty";
28
+
29
+ /**
30
+ * Minimal z-index value for segment elevation data handling.
31
+ * @public
32
+ * @type {number}
33
+ */
34
+ this.minZoom = 1000000;
35
+
36
+ /**
37
+ * Maximal z-index value for segment elevation data handling.
38
+ * @public
39
+ * @type {number}
40
+ */
41
+ this.maxZoom = 21;
42
+
43
+ /**
44
+ * @public
45
+ * @type {Array.<number>}
46
+ */
47
+ this.gridSizeByZoom = options.gridSizeByZoom || [
48
+ 32, 16, 16, 8, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2
49
+ ];
50
+ //this.gridSizeByZoom = options.gridSizeByZoom || [32, 16, 16, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2];
51
+
52
+ this._maxNodeZoom = this.gridSizeByZoom.length - 1;
53
+
54
+ /**
55
+ * Elevation grid size. Currend is 2x2 is the smallest grid size.
56
+ * @public
57
+ * @type {number}
58
+ */
59
+ this.plainGridSize = 2;
60
+
61
+ /**
62
+ * Planet node.
63
+ * @protected
64
+ * @type {Planet}
65
+ */
66
+ this._planet = null;
67
+
68
+ this._geoid =
69
+ options.geoid ||
70
+ new Geoid({
71
+ src: options.geoidSrc || null
72
+ });
73
+
74
+ this._isReady = false;
75
+
76
+ // const _ellToAltFn = [
77
+ // (lon, lat, alt, callback) => callback(alt),
78
+ // (lon, lat, alt, callback) => callback(alt - this._geoid.getHeight(lon, lat)),
79
+ // (lon, lat, alt, callback) => {
80
+
81
+ // let x = mercator.getTileX(lon, zoom),
82
+ // y = mercator.getTileY(lat, zoom);
83
+
84
+ // let mslAlt = alt - this._geoid.getHeight(lon, lat);
85
+
86
+ // if (true) {
87
+
88
+ // } else {
89
+
90
+ // }
91
+
92
+ // return callback(mslAlt);
93
+ // },
94
+ // ];
95
+ }
96
+
97
+ static checkNoDataValue(noDataValues, value) {
98
+ return binarySearchFast(noDataValues, value) !== -1;
99
+ }
100
+
101
+ isBlur() {
102
+ return false;
103
+ }
104
+
105
+ set maxNodeZoom(val) {
106
+ if (val > this.gridSizeByZoom.length - 1) {
107
+ val = this.gridSizeByZoom.length - 1;
108
+ }
109
+ this._maxNodeZoom = val;
110
+ }
111
+
112
+ get maxNodeZoom() {
113
+ return this._maxNodeZoom;
114
+ }
115
+
116
+ set geoid(geoid) {
117
+ this._geoid = geoid;
118
+ }
119
+
120
+ get geoid() {
121
+ return this._geoid;
122
+ }
123
+
124
+ getGeoid() {
125
+ return this._geoid;
126
+ }
127
+
128
+ /**
129
+ * Loads or creates segment elevation data.
130
+ * @public
131
+ * @virtual
132
+ * @param {Segment} segment - Segment to create elevation data.
133
+ */
134
+ handleSegmentTerrain(segment) {
135
+ segment.terrainIsLoading = false;
136
+ segment.terrainReady = true;
137
+ segment.terrainExists = true;
138
+ }
139
+
140
+ isReady() {
141
+ return this._isReady;
142
+ }
143
+
144
+ /**
145
+ * Abstract function
146
+ * @public
147
+ * @abstract
148
+ */
149
+ abortLoading() {
150
+ }
151
+
152
+ /**
153
+ * Abstract function
154
+ * @public
155
+ * @abstract
156
+ */
157
+ clearCache() {
158
+ }
159
+ }
160
+
161
+ export { EmptyTerrain };