@openglobus/og 0.10.3 → 0.10.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.
- package/css/og.css +1 -1
- package/package.json +4 -4
- package/src/og/Extent.js +274 -273
- package/src/og/Globe.js +11 -3
- package/src/og/LonLat.js +148 -147
- package/src/og/camera/PlanetCamera.js +110 -38
- package/src/og/control/EarthNavigation.js +259 -0
- package/src/og/control/MouseNavigation.js +68 -40
- package/src/og/layer/CanvasTiles.js +32 -30
- package/src/og/layer/KML.js +157 -0
- package/src/og/quadTree/Node.js +72 -19
- package/src/og/renderer/RendererEvents.js +21 -16
- package/src/og/scene/Planet.js +7 -2
- package/src/og/segment/Segment.js +2 -4
- package/src/og/utils/FontAtlas.js +1 -0
- package/src/og/{segment → utils}/PlainSegmentWorker.js +425 -407
- package/src/og/webgl/Handler.js +866 -845
package/css/og.css
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
.ogGrabbingPoiner {
|
|
30
|
-
cursor:
|
|
30
|
+
cursor: grabbing !important;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
.ogViewport {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openglobus/og",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.6",
|
|
4
4
|
"description": "[OpenGlobus](http://www.openglobus.org/) is a javascript library designed to display interactive 3d maps and planets with map tiles, imagery and vector data, markers and 3d objects. It uses the WebGL technology, open source and completely free.",
|
|
5
5
|
"directories": {
|
|
6
6
|
"example": "./sandbox"
|
|
@@ -36,12 +36,12 @@
|
|
|
36
36
|
"./entity": "./src/og/entity/index.js",
|
|
37
37
|
"./control": "./src/og/control/index.js",
|
|
38
38
|
"./webgl": "./src/og/webgl/index.js",
|
|
39
|
-
"./scene": "./src/og/scene/index.js"
|
|
39
|
+
"./scene": "./src/og/scene/index.js",
|
|
40
|
+
"./css/og.css": "./css/og.css"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
42
43
|
"@babel/preset-env": "^7.12.17",
|
|
43
44
|
"@rollup/plugin-json": "^4.1.0",
|
|
44
|
-
"enhanced-resolve": "^4.3.0",
|
|
45
45
|
"eslint": "^6.8.0",
|
|
46
46
|
"eslint-config-defaults": "^9.0.0",
|
|
47
47
|
"eslint-config-standard": "^14.1.1",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"jest": "^26.6.3",
|
|
56
56
|
"jsdoc": "^3.6.7",
|
|
57
57
|
"lint-staged": "^11.0.0",
|
|
58
|
-
"local-web-server": "^
|
|
58
|
+
"local-web-server": "^5.1.1",
|
|
59
59
|
"msdf-bmfont-xml": "^2.3.6",
|
|
60
60
|
"postcss": "^8.3.0",
|
|
61
61
|
"prettier": "^2.3.0",
|
package/src/og/Extent.js
CHANGED
|
@@ -14,305 +14,306 @@ import { LonLat } from './LonLat.js';
|
|
|
14
14
|
* @param {og.LonLat} [sw] - South West extent corner coordiantes.
|
|
15
15
|
* @param {og.LonLat} [ne] - North East extent corner coordiantes.
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
export class Extent {
|
|
18
|
+
|
|
19
|
+
constructor(sw, ne) {
|
|
20
|
+
/**
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
this.southWest = sw || new LonLat();
|
|
24
|
+
/**
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
this.northEast = ne || new LonLat();
|
|
28
|
+
}
|
|
29
|
+
|
|
18
30
|
/**
|
|
19
|
-
*
|
|
31
|
+
* Whole mercator extent.
|
|
32
|
+
* @const
|
|
20
33
|
*/
|
|
21
|
-
|
|
34
|
+
static get FULL_MERC() { return new Extent(LonLat.SW_MERC, LonLat.NE_MERC) };
|
|
22
35
|
|
|
23
36
|
/**
|
|
24
|
-
*
|
|
37
|
+
* Degrees extent from north mercator limit to north pole.
|
|
38
|
+
* @const
|
|
25
39
|
*/
|
|
26
|
-
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Whole mercator extent.
|
|
31
|
-
* @const
|
|
32
|
-
*/
|
|
33
|
-
Extent.FULL_MERC = new Extent(LonLat.SW_MERC, LonLat.NE_MERC);
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Degrees extent from north mercator limit to north pole.
|
|
37
|
-
* @const
|
|
38
|
-
*/
|
|
39
|
-
Extent.NORTH_POLE_DEG = new Extent(LonLat.NW_MERC_DEG, new LonLat(180.0, 90.0));
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Degrees extent from south pole to south mercator limit.
|
|
43
|
-
* @const
|
|
44
|
-
*/
|
|
45
|
-
Extent.SOUTH_POLE_DEG = new Extent(new LonLat(-180.0, -90.0), LonLat.SE_MERC_DEG);
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Creates extent instance from values in array.
|
|
49
|
-
* @static
|
|
50
|
-
* @param {Array.<number,number,number,number>} arr - South west and north east longitude and latidudes packed in array.
|
|
51
|
-
* @return {og.Extent} Extent object.
|
|
52
|
-
*/
|
|
53
|
-
Extent.createFromArray = function (arr) {
|
|
54
|
-
return new Extent(new LonLat(arr[0], arr[1]), new LonLat(arr[2], arr[3]));
|
|
55
|
-
};
|
|
40
|
+
static get NORTH_POLE_DEG() { return new Extent(LonLat.NW_MERC_DEG, new LonLat(180.0, 90.0)); }
|
|
56
41
|
|
|
57
|
-
/**
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
*/
|
|
63
|
-
Extent.createByCoordinates = function (arr) {
|
|
64
|
-
var lonmin = math.MAX, lonmax = math.MIN,
|
|
65
|
-
latmin = math.MAX, latmax = math.MIN;
|
|
66
|
-
for (var i = 0; i < arr.length; i++) {
|
|
67
|
-
var vi = arr[i];
|
|
68
|
-
if (vi.lon < lonmin) lonmin = vi.lon;
|
|
69
|
-
if (vi.lon > lonmax) lonmax = vi.lon;
|
|
70
|
-
if (vi.lat < latmin) latmin = vi.lat;
|
|
71
|
-
if (vi.lat > latmax) latmax = vi.lat;
|
|
72
|
-
}
|
|
73
|
-
return new Extent(new LonLat(lonmin, latmin), new LonLat(lonmax, latmax));
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Creates bound extent instance by coordinate array.
|
|
78
|
-
* @static
|
|
79
|
-
* @param {Array.<Array<number,number>>} arr - Coordinate array.
|
|
80
|
-
* @return {og.Extent} Extent object.
|
|
81
|
-
*/
|
|
82
|
-
Extent.createByCoordinatesArr = function (arr) {
|
|
83
|
-
var lonmin = math.MAX, lonmax = math.MIN,
|
|
84
|
-
latmin = math.MAX, latmax = math.MIN;
|
|
85
|
-
for (var i = 0; i < arr.length; i++) {
|
|
86
|
-
var vi = arr[i];
|
|
87
|
-
if (vi[0] < lonmin) lonmin = vi[0];
|
|
88
|
-
if (vi[0] > lonmax) lonmax = vi[0];
|
|
89
|
-
if (vi[1] < latmin) latmin = vi[1];
|
|
90
|
-
if (vi[1] > latmax) latmax = vi[1];
|
|
91
|
-
}
|
|
92
|
-
return new Extent(new LonLat(lonmin, latmin), new LonLat(lonmax, latmax));
|
|
93
|
-
};
|
|
42
|
+
/**
|
|
43
|
+
* Degrees extent from south pole to south mercator limit.
|
|
44
|
+
* @const
|
|
45
|
+
*/
|
|
46
|
+
static get SOUTH_POLE_DEG() { return new Extent(new LonLat(-180.0, -90.0), LonLat.SE_MERC_DEG) };
|
|
94
47
|
|
|
95
|
-
/**
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
*/
|
|
105
|
-
Extent.fromTile = function (x, y, z, width, height) {
|
|
106
|
-
width = width || mercator.POLE_DOUBLE;
|
|
107
|
-
height = height || mercator.POLE_DOUBLE;
|
|
108
|
-
var H = Math.pow(2, z),
|
|
109
|
-
W = Math.pow(2, z),
|
|
110
|
-
lnSize = width / W,
|
|
111
|
-
ltSize = height / H;
|
|
112
|
-
|
|
113
|
-
var left = -width * 0.5 + x * lnSize,
|
|
114
|
-
top = height * 0.5 - y * ltSize,
|
|
115
|
-
bottom = top - ltSize,
|
|
116
|
-
right = left + lnSize;
|
|
117
|
-
|
|
118
|
-
return new Extent(new LonLat(left, bottom), new LonLat(right, top));
|
|
119
|
-
};
|
|
48
|
+
/**
|
|
49
|
+
* Creates extent instance from values in array.
|
|
50
|
+
* @static
|
|
51
|
+
* @param {Array.<number,number,number,number>} arr - South west and north east longitude and latidudes packed in array.
|
|
52
|
+
* @return {og.Extent} Extent object.
|
|
53
|
+
*/
|
|
54
|
+
static createFromArray(arr) {
|
|
55
|
+
return new Extent(new LonLat(arr[0], arr[1]), new LonLat(arr[2], arr[3]));
|
|
56
|
+
};
|
|
120
57
|
|
|
121
|
-
/**
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
this.northEast.lon = lonmax;
|
|
140
|
-
this.northEast.lat = latmax;
|
|
141
|
-
return this;
|
|
142
|
-
};
|
|
58
|
+
/**
|
|
59
|
+
* Creates bound extent instance by coordinate array.
|
|
60
|
+
* @static
|
|
61
|
+
* @param {Array.<og.LonLat>} arr - Coordinate array.
|
|
62
|
+
* @return {og.Extent} Extent object.
|
|
63
|
+
*/
|
|
64
|
+
static createByCoordinates(arr) {
|
|
65
|
+
let lonmin = math.MAX, lonmax = math.MIN,
|
|
66
|
+
latmin = math.MAX, latmax = math.MIN;
|
|
67
|
+
for (let i = 0; i < arr.length; i++) {
|
|
68
|
+
const vi = arr[i];
|
|
69
|
+
if (vi.lon < lonmin) lonmin = vi.lon;
|
|
70
|
+
if (vi.lon > lonmax) lonmax = vi.lon;
|
|
71
|
+
if (vi.lat < latmin) latmin = vi.lat;
|
|
72
|
+
if (vi.lat > latmax) latmax = vi.lat;
|
|
73
|
+
}
|
|
74
|
+
return new Extent(new LonLat(lonmin, latmin), new LonLat(lonmax, latmax));
|
|
75
|
+
};
|
|
143
76
|
|
|
144
|
-
/**
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Creates bound extent instance by coordinate array.
|
|
79
|
+
* @static
|
|
80
|
+
* @param {Array.<Array<number,number>>} arr - Coordinate array.
|
|
81
|
+
* @return {og.Extent} Extent object.
|
|
82
|
+
*/
|
|
83
|
+
static createByCoordinatesArr(arr) {
|
|
84
|
+
let lonmin = math.MAX, lonmax = math.MIN,
|
|
85
|
+
latmin = math.MAX, latmax = math.MIN;
|
|
86
|
+
for (let i = 0; i < arr.length; i++) {
|
|
87
|
+
const vi = arr[i];
|
|
88
|
+
if (vi[0] < lonmin) lonmin = vi[0];
|
|
89
|
+
if (vi[0] > lonmax) lonmax = vi[0];
|
|
90
|
+
if (vi[1] < latmin) latmin = vi[1];
|
|
91
|
+
if (vi[1] > latmax) latmax = vi[1];
|
|
92
|
+
}
|
|
93
|
+
return new Extent(new LonLat(lonmin, latmin), new LonLat(lonmax, latmax));
|
|
94
|
+
};
|
|
156
95
|
|
|
157
|
-
/**
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
96
|
+
/**
|
|
97
|
+
* Creates extent by meractor grid tile coordinates.
|
|
98
|
+
* @static
|
|
99
|
+
* @param {number} x -
|
|
100
|
+
* @param {number} y -
|
|
101
|
+
* @param {number} z -
|
|
102
|
+
* @param {number} width -
|
|
103
|
+
* @param {number} height -
|
|
104
|
+
* @returns {og.Extent} -
|
|
105
|
+
*/
|
|
106
|
+
static fromTile(x, y, z, width, height) {
|
|
107
|
+
width = width || mercator.POLE_DOUBLE;
|
|
108
|
+
height = height || mercator.POLE_DOUBLE;
|
|
109
|
+
const H = Math.pow(2, z),
|
|
110
|
+
W = Math.pow(2, z),
|
|
111
|
+
lnSize = width / W,
|
|
112
|
+
ltSize = height / H;
|
|
113
|
+
|
|
114
|
+
const left = -width * 0.5 + x * lnSize,
|
|
115
|
+
top = height * 0.5 - y * ltSize,
|
|
116
|
+
bottom = top - ltSize,
|
|
117
|
+
right = left + lnSize;
|
|
118
|
+
|
|
119
|
+
return new Extent(new LonLat(left, bottom), new LonLat(right, top));
|
|
120
|
+
};
|
|
169
121
|
|
|
170
|
-
/**
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
122
|
+
/**
|
|
123
|
+
* Sets current bounding extent object by coordinate array.
|
|
124
|
+
* @public
|
|
125
|
+
* @param {Array.<og.LonLat>} arr - Coordinate array.
|
|
126
|
+
* @return {og.Extent} Current extent.
|
|
127
|
+
*/
|
|
128
|
+
setByCoordinates(arr) {
|
|
129
|
+
let lonmin = math.MAX, lonmax = math.MIN,
|
|
130
|
+
latmin = math.MAX, latmax = math.MIN;
|
|
131
|
+
for (let i = 0; i < arr.length; i++) {
|
|
132
|
+
const vi = arr[i];
|
|
133
|
+
if (vi.lon < lonmin) lonmin = vi.lon;
|
|
134
|
+
if (vi.lon > lonmax) lonmax = vi.lon;
|
|
135
|
+
if (vi.lat < latmin) latmin = vi.lat;
|
|
136
|
+
if (vi.lat > latmax) latmax = vi.lat;
|
|
137
|
+
}
|
|
138
|
+
this.southWest.lon = lonmin;
|
|
139
|
+
this.southWest.lat = latmin;
|
|
140
|
+
this.northEast.lon = lonmax;
|
|
141
|
+
this.northEast.lat = latmax;
|
|
142
|
+
return this;
|
|
143
|
+
};
|
|
178
144
|
|
|
179
|
-
/**
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
145
|
+
/**
|
|
146
|
+
* Determines if point inside extent.
|
|
147
|
+
* @public
|
|
148
|
+
* @param {LonLat} lonlat - Coordinate point.
|
|
149
|
+
* @return {boolean} Returns true if point inside extent.
|
|
150
|
+
*/
|
|
151
|
+
isInside(lonlat) {
|
|
152
|
+
const sw = this.southWest,
|
|
153
|
+
ne = this.northEast;
|
|
154
|
+
return lonlat.lon >= sw.lon && lonlat.lon <= ne.lon &&
|
|
155
|
+
lonlat.lat >= sw.lat && lonlat.lat <= ne.lat;
|
|
156
|
+
};
|
|
187
157
|
|
|
188
|
-
/**
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
158
|
+
/**
|
|
159
|
+
* Returns true if two extent overlap each other.
|
|
160
|
+
* @public
|
|
161
|
+
* @param {Extent} e - Another extent.
|
|
162
|
+
* @return {boolean} -
|
|
163
|
+
*/
|
|
164
|
+
overlaps(e) {
|
|
165
|
+
const sw = this.southWest,
|
|
166
|
+
ne = this.northEast;
|
|
167
|
+
return sw.lon <= e.northEast.lon && ne.lon >= e.southWest.lon &&
|
|
168
|
+
sw.lat <= e.northEast.lat && ne.lat >= e.southWest.lat;
|
|
169
|
+
};
|
|
196
170
|
|
|
197
|
-
/**
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
};
|
|
171
|
+
/**
|
|
172
|
+
* Gets extent width.
|
|
173
|
+
* @public
|
|
174
|
+
* @return {number} Extent width.
|
|
175
|
+
*/
|
|
176
|
+
getWidth() {
|
|
177
|
+
return this.northEast.lon - this.southWest.lon;
|
|
178
|
+
};
|
|
206
179
|
|
|
207
|
-
/**
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
180
|
+
/**
|
|
181
|
+
* Gets extent height.
|
|
182
|
+
* @public
|
|
183
|
+
* @return {number} Extent height.
|
|
184
|
+
*/
|
|
185
|
+
getHeight() {
|
|
186
|
+
return this.northEast.lat - this.southWest.lat;
|
|
187
|
+
};
|
|
213
188
|
|
|
214
|
-
/**
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
189
|
+
/**
|
|
190
|
+
* Creates clone instance of the current extent.
|
|
191
|
+
* @public
|
|
192
|
+
* @return {og.Extent} Extent clone.
|
|
193
|
+
*/
|
|
194
|
+
clone() {
|
|
195
|
+
return new Extent(this.southWest.clone(), this.northEast.clone());
|
|
196
|
+
};
|
|
220
197
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
198
|
+
/**
|
|
199
|
+
* Gets the center coordinate of the extent.
|
|
200
|
+
* @public
|
|
201
|
+
* @return {number} Center coordinate.
|
|
202
|
+
*/
|
|
203
|
+
getCenter() {
|
|
204
|
+
const sw = this.southWest, ne = this.northEast;
|
|
205
|
+
return new LonLat(sw.lon + (ne.lon - sw.lon) * 0.5, sw.lat + (ne.lat - sw.lat) * 0.5);
|
|
206
|
+
};
|
|
224
207
|
|
|
225
|
-
/**
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
};
|
|
208
|
+
/**
|
|
209
|
+
* @public
|
|
210
|
+
*/
|
|
211
|
+
getNorthWest() {
|
|
212
|
+
return new LonLat(this.southWest.lon, this.northEast.lat);
|
|
213
|
+
};
|
|
231
214
|
|
|
232
|
-
/**
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
};
|
|
215
|
+
/**
|
|
216
|
+
* @public
|
|
217
|
+
*/
|
|
218
|
+
getNorthEast() {
|
|
219
|
+
return new LonLat(this.northEast.lon, this.northEast.lat);
|
|
220
|
+
};
|
|
238
221
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
};
|
|
222
|
+
getSouthWest() {
|
|
223
|
+
return new LonLat(this.southWest.lon, this.southWest.lat);
|
|
224
|
+
};
|
|
242
225
|
|
|
243
|
-
/**
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
};
|
|
226
|
+
/**
|
|
227
|
+
* @public
|
|
228
|
+
*/
|
|
229
|
+
getSouthEast() {
|
|
230
|
+
return new LonLat(this.northEast.lon, this.southWest.lat);
|
|
231
|
+
};
|
|
249
232
|
|
|
250
|
-
/**
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
};
|
|
233
|
+
/**
|
|
234
|
+
* @public
|
|
235
|
+
*/
|
|
236
|
+
getNorth() {
|
|
237
|
+
return this.northEast.lat;
|
|
238
|
+
};
|
|
256
239
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
* @returns {boolean} -
|
|
261
|
-
*/
|
|
262
|
-
Extent.prototype.equals = function (extent) {
|
|
263
|
-
return this.southWest.lon === extent.southWest.lon && this.southWest.lat === extent.southWest.lat &&
|
|
264
|
-
this.northEast.lon === extent.northEast.lon && this.northEast.lat === extent.northEast.lat;
|
|
265
|
-
};
|
|
240
|
+
getEast() {
|
|
241
|
+
return this.northEast.lon;
|
|
242
|
+
};
|
|
266
243
|
|
|
267
|
-
/**
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
return new Extent(this.southWest.forwardMercator(), this.northEast.forwardMercator());
|
|
274
|
-
};
|
|
244
|
+
/**
|
|
245
|
+
* @public
|
|
246
|
+
*/
|
|
247
|
+
getWest() {
|
|
248
|
+
return this.southWest.lon;
|
|
249
|
+
};
|
|
275
250
|
|
|
276
|
-
/**
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
return new Extent(this.southWest.inverseMercator(), this.northEast.inverseMercator());
|
|
283
|
-
};
|
|
251
|
+
/**
|
|
252
|
+
* @public
|
|
253
|
+
*/
|
|
254
|
+
getSouth() {
|
|
255
|
+
return this.southWest.lat;
|
|
256
|
+
};
|
|
284
257
|
|
|
285
|
-
/**
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
var v = [new LonLat(this.southWest.lon, this.southWest.lat),
|
|
296
|
-
new LonLat(this.southWest.lon, this.northEast.lat),
|
|
297
|
-
new LonLat(this.northEast.lon, this.northEast.lat),
|
|
298
|
-
new LonLat(this.northEast.lon, this.southWest.lat)];
|
|
299
|
-
|
|
300
|
-
for (var i = 0; i < v.length; i++) {
|
|
301
|
-
var coord = ellipsoid.lonLatToCartesian(v[i]);
|
|
302
|
-
var x = coord.x, y = coord.y, z = coord.z;
|
|
303
|
-
if (x < xmin) xmin = x;
|
|
304
|
-
if (x > xmax) xmax = x;
|
|
305
|
-
if (y < ymin) ymin = y;
|
|
306
|
-
if (y > ymax) ymax = y;
|
|
307
|
-
if (z < zmin) zmin = z;
|
|
308
|
-
if (z > zmax) zmax = z;
|
|
309
|
-
}
|
|
258
|
+
/**
|
|
259
|
+
* Returns extents are equals.
|
|
260
|
+
* @param {og.Extent} extent - Extent.
|
|
261
|
+
* @returns {boolean} -
|
|
262
|
+
*/
|
|
263
|
+
equals(extent) {
|
|
264
|
+
return this.southWest.lon === extent.southWest.lon && this.southWest.lat === extent.southWest.lat &&
|
|
265
|
+
this.northEast.lon === extent.northEast.lon && this.northEast.lat === extent.northEast.lat;
|
|
266
|
+
};
|
|
310
267
|
|
|
311
|
-
|
|
312
|
-
|
|
268
|
+
/**
|
|
269
|
+
* Converts extent coordinates to mercator projection coordinates.
|
|
270
|
+
* @public
|
|
271
|
+
* @return {og.Extent} New instance of the current extent.
|
|
272
|
+
*/
|
|
273
|
+
forwardMercator() {
|
|
274
|
+
return new Extent(this.southWest.forwardMercator(), this.northEast.forwardMercator());
|
|
275
|
+
};
|
|
313
276
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
277
|
+
/**
|
|
278
|
+
* Converts extent coordinates from mercator projection to degrees.
|
|
279
|
+
* @public
|
|
280
|
+
* @return {og.Extent} New instance of the current extent.
|
|
281
|
+
*/
|
|
282
|
+
inverseMercator() {
|
|
283
|
+
return new Extent(this.southWest.inverseMercator(), this.northEast.inverseMercator());
|
|
284
|
+
};
|
|
317
285
|
|
|
318
|
-
|
|
286
|
+
/**
|
|
287
|
+
* Gets cartesian bounding bounds of the current ellipsoid.
|
|
288
|
+
* @public
|
|
289
|
+
* @param {og.Ellipsoid} ellipsoid - Ellipsoid.
|
|
290
|
+
* @return {Array.<number,number,number,number,number,number>} Cartesian 3d coordinate array.
|
|
291
|
+
*/
|
|
292
|
+
getCartesianBounds(ellipsoid) {
|
|
293
|
+
let xmin = math.MAX, xmax = math.MIN, ymin = math.MAX,
|
|
294
|
+
ymax = math.MIN, zmin = math.MAX, zmax = math.MIN;
|
|
295
|
+
|
|
296
|
+
const v = [new LonLat(this.southWest.lon, this.southWest.lat),
|
|
297
|
+
new LonLat(this.southWest.lon, this.northEast.lat),
|
|
298
|
+
new LonLat(this.northEast.lon, this.northEast.lat),
|
|
299
|
+
new LonLat(this.northEast.lon, this.southWest.lat)];
|
|
300
|
+
|
|
301
|
+
for (let i = 0; i < v.length; i++) {
|
|
302
|
+
const coord = ellipsoid.lonLatToCartesian(v[i]);
|
|
303
|
+
const x = coord.x, y = coord.y, z = coord.z;
|
|
304
|
+
if (x < xmin) xmin = x;
|
|
305
|
+
if (x > xmax) xmax = x;
|
|
306
|
+
if (y < ymin) ymin = y;
|
|
307
|
+
if (y > ymax) ymax = y;
|
|
308
|
+
if (z < zmin) zmin = z;
|
|
309
|
+
if (z > zmax) zmax = z;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
return [xmin, ymin, zmin, xmax, ymax, zmax];
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
toString() {
|
|
316
|
+
return "[" + this.southWest.lon + ", " + this.southWest.lat + ", " + this.northEast.lon + ", " + this.northEast.lat + "]";
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
}
|
package/src/og/Globe.js
CHANGED
|
@@ -13,6 +13,7 @@ import { isEmpty } from "./utils/shared.js";
|
|
|
13
13
|
|
|
14
14
|
import { EarthCoordinates } from "./control/EarthCoordinates.js";
|
|
15
15
|
import { MouseNavigation } from "./control/MouseNavigation.js";
|
|
16
|
+
import { EarthNavigation } from "./control/EarthNavigation.js";
|
|
16
17
|
import { TouchNavigation } from "./control/TouchNavigation.js";
|
|
17
18
|
import { Sun } from "./control/Sun.js";
|
|
18
19
|
import { ZoomControl } from "./control/ZoomControl.js";
|
|
@@ -81,7 +82,8 @@ class Globe {
|
|
|
81
82
|
* @public
|
|
82
83
|
* @type {Element}
|
|
83
84
|
*/
|
|
84
|
-
this.div =
|
|
85
|
+
this.div =
|
|
86
|
+
document.getElementById(options.target) || document.querySelector(options.target);
|
|
85
87
|
this.div.appendChild(this._canvas);
|
|
86
88
|
this.div.classList.add("ogViewport");
|
|
87
89
|
|
|
@@ -151,7 +153,9 @@ class Globe {
|
|
|
151
153
|
ellipsoid: options.ellipsoid,
|
|
152
154
|
maxGridSize: options.maxGridSize,
|
|
153
155
|
useNightTexture: options.useNightTexture,
|
|
154
|
-
useSpecularTexture: options.useSpecularTexture
|
|
156
|
+
useSpecularTexture: options.useSpecularTexture,
|
|
157
|
+
minAltitude: options.minAltitude,
|
|
158
|
+
maxAltitude: options.maxAltitude
|
|
155
159
|
});
|
|
156
160
|
}
|
|
157
161
|
|
|
@@ -170,7 +174,11 @@ class Globe {
|
|
|
170
174
|
} else {
|
|
171
175
|
this.planet.addControls([
|
|
172
176
|
new ZoomControl(),
|
|
173
|
-
|
|
177
|
+
options.useEarthNavigation
|
|
178
|
+
? new EarthNavigation()
|
|
179
|
+
: new MouseNavigation({
|
|
180
|
+
minSlope: options.minSlope
|
|
181
|
+
}),
|
|
174
182
|
new TouchNavigation(),
|
|
175
183
|
new EarthCoordinates(),
|
|
176
184
|
new ScaleControl(),
|