@openglobus/og 0.13.6 → 0.13.7

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.
@@ -185,7 +185,7 @@ class GlobusTerrain extends EmptyTerrain {
185
185
 
186
186
  if (cache) {
187
187
  if (!cache.heights) {
188
- callback(this._geoid.getHeightLonLat(lonLat));
188
+ callback(0);
189
189
  } else {
190
190
  callback(this._getGroundHeightMerc(merc, cache));
191
191
  }
@@ -220,7 +220,7 @@ class GlobusTerrain extends EmptyTerrain {
220
220
  extent: extent
221
221
  };
222
222
  this._elevationCache[tileIndex] = cache;
223
- callback(this._geoid.getHeightLonLat(lonLat));
223
+ callback(0);
224
224
  } else {
225
225
  this._fetchCache[tileIndex] = null;
226
226
  delete this._fetchCache[tileIndex];
@@ -279,10 +279,10 @@ class GlobusTerrain extends EmptyTerrain {
279
279
  h3 = tileData.heights[v3Ind];
280
280
 
281
281
  let v0 = new Vec3(
282
- tileData.extent.southWest.lon + size * j,
283
- h0,
284
- tileData.extent.northEast.lat - size * i - size
285
- ),
282
+ tileData.extent.southWest.lon + size * j,
283
+ h0,
284
+ tileData.extent.northEast.lat - size * i - size
285
+ ),
286
286
  v1 = new Vec3(v0.x + size, h1, v0.z),
287
287
  v2 = new Vec3(v0.x, h2, v0.z + size),
288
288
  v3 = new Vec3(v0.x + size, h3, v0.z + size);
@@ -26,6 +26,8 @@ export class Loader {
26
26
 
27
27
  this._queue = [];//new QueueArray();
28
28
 
29
+ this._senderRequestCounter = [];
30
+
29
31
  this._promises = {
30
32
  'json': r => r.json(),
31
33
  'blob': r => r.blob(),
@@ -36,6 +38,16 @@ export class Loader {
36
38
  }
37
39
 
38
40
  load(params, callback) {
41
+ if (params.sender) {
42
+ if (!this._senderRequestCounter[params.sender._id]) {
43
+ this._senderRequestCounter[params.sender._id] = {
44
+ sender: params.sender,
45
+ counter: 0,
46
+ __requestCounterFrame__: null
47
+ };
48
+ }
49
+ this._senderRequestCounter[params.sender._id].counter++;
50
+ }
39
51
  this._queue.push({ 'params': params, 'callback': callback });
40
52
  this._exec();
41
53
  }
@@ -43,8 +55,8 @@ export class Loader {
43
55
  fetch(params) {
44
56
  return fetch(
45
57
  params.src,
46
- params.options || {})
47
-
58
+ params.options || {}
59
+ )
48
60
  .then(response => {
49
61
  if (!response.ok) {
50
62
  throw Error(`Unable to load '${params.src}'`);
@@ -62,6 +74,33 @@ export class Loader {
62
74
  });
63
75
  }
64
76
 
77
+ _checkLoadend(request, sender) {
78
+ if (request.counter === 0 && sender._planet._terrainCompletedActivated) {
79
+ sender.events.dispatch(sender.events.loadend);
80
+ request.__requestCounterFrame__ = null;
81
+ } else {
82
+ request.__requestCounterFrame__ = requestAnimationFrame(() => {
83
+ this._checkLoadend(request, sender);
84
+ });
85
+ }
86
+ }
87
+
88
+ _handleResponse(q, response) {
89
+ q.callback(response);
90
+ let sender = q.params.sender;
91
+ if (sender && sender.events.loadend.handlers.length) {
92
+ let request = this._senderRequestCounter[sender._id];
93
+ if (request && request.counter > 0) {
94
+ request.counter--;
95
+ cancelAnimationFrame(request.__requestCounterFrame__);
96
+ request.__requestCounterFrame__ = requestAnimationFrame(() => {
97
+ this._checkLoadend(request, sender);
98
+ });
99
+ }
100
+ }
101
+ this._exec();
102
+ }
103
+
65
104
  _exec() {
66
105
 
67
106
  if (this._queue.length > 0 && this._loading < this.MAX_REQUESTS) {
@@ -82,18 +121,15 @@ export class Loader {
82
121
  })
83
122
  .then(data => {
84
123
  this._loading--;
85
- q.callback({ 'status': "ready", 'data': data });
86
- this._exec();
124
+ this._handleResponse(q, { status: "ready", data: data });
87
125
  })
88
126
  .catch(err => {
89
127
  this._loading--;
90
- q.callback({ 'status': "error", 'msg': err.toString() });
91
- this._exec();
128
+ this._handleResponse(q, { status: "error", msg: err.toString() });
92
129
  });
93
130
 
94
131
  } else {
95
- q.callback({ 'status': "abort" });
96
- this._exec();
132
+ this._handleResponse(q, { status: "abort" });
97
133
  }
98
134
  } else if (this._loading === 0) {
99
135
  this.events.dispatch(this.events.loadend);
@@ -101,13 +137,18 @@ export class Loader {
101
137
  }
102
138
 
103
139
  abort() {
104
- //this._queue.each(e => e.callback({ 'status': "abort" }));
105
- //this._queue.clear();
106
-
107
140
  for (let i = 0, len = this._queue.length; i < len; i++) {
108
- this._queue[i].callback({ 'status': "abort" });
141
+ let qi = this._queue[i];
142
+ let sender = qi.params.sender;
143
+ if (sender && this._senderRequestCounter[sender._id]) {
144
+ this._senderRequestCounter[sender._id].counter = 0;
145
+ cancelAnimationFrame(this._senderRequestCounter[sender._id].__requestCounterFrame__);
146
+ this._senderRequestCounter[sender._id].__requestCounterFrame__ = null;
147
+ }
148
+ qi.callback({ 'status': "abort" });
109
149
  this._queue[i] = null;
110
150
  }
111
151
  this._queue = [];
152
+ this._loading === 0;
112
153
  }
113
154
  }
@@ -0,0 +1,78 @@
1
+ 'use strict';
2
+
3
+ export const ELL = 0;
4
+ export const MSL = 1;
5
+ export const GND = 2;
6
+
7
+ export const heightMode = {
8
+ "ell": ELL,
9
+ "msl": MSL,
10
+ "gnd": GND
11
+ };
12
+
13
+ const KM_to_M = 1000.0;
14
+ const M_to_KM = 1.0 / KM_to_M;
15
+ const FT_to_M = 0.3048;
16
+ const M_to_FT = 1.0 / FT_to_M;
17
+ const MS_to_KMH = 3.6;
18
+ const KMH_to_MS = 1.0 / MS_to_KMH;
19
+ const MS_to_FTS = 3.28084;
20
+ const FT_to_KM = FT_to_M * M_to_KM;
21
+ const KM_to_FT = 1.0 / FT_to_KM;
22
+
23
+ export const m = 0;
24
+ export const km = 1;
25
+ export const ft = 2;
26
+ export const s = 3;
27
+ export const h = 4;
28
+ export const ms = 5;
29
+ export const kmh = 6;
30
+ export const fts = 7;
31
+
32
+ const DEFAULT_NAN = "--";
33
+
34
+ const _abbr = ["m", "km", "ft", "s", "h", "m/s", "km/h", "ft/s"];
35
+
36
+ export const _tenth = [0, 2, 0, 0, 0, 0, 0, 0];
37
+
38
+ let _convFn = [];
39
+
40
+ _convFn[m] = [];
41
+ _convFn[m][m] = (v) => v;
42
+ _convFn[m][km] = (v) => v * M_to_KM;
43
+ _convFn[m][ft] = (v) => v * M_to_FT;
44
+
45
+ _convFn[ft] = [];
46
+ _convFn[ft][m] = (v) => v * FT_to_M;
47
+ _convFn[ft][km] = (v) => v * FT_to_KM;
48
+ _convFn[ft][ft] = (v) => v;
49
+
50
+ _convFn[km] = [];
51
+ _convFn[km][m] = (v) => v * KM_to_M;
52
+ _convFn[km][km] = (v) => v;
53
+ _convFn[km][ft] = (v) => v * KM_to_FT;
54
+
55
+ _convFn[ms] = [];
56
+ _convFn[ms][ms] = (v) => v;
57
+ _convFn[ms][kmh] = (v) => v * MS_to_KMH;
58
+ _convFn[ms][fts] = (v) => v * MS_to_FTS;
59
+
60
+ _convFn[kmh] = [];
61
+ _convFn[kmh][ms] = (v) => v * KMH_to_MS;
62
+ _convFn[kmh][kmh] = (v) => v;
63
+ //_convFn[kmh][fts] = (v) => v * KMH_to_FTS;
64
+
65
+ export function convert(from, to, val) {
66
+ return _convFn[from][to](val);
67
+ }
68
+
69
+ export function convertExt(isNotNaN, unitFrom, unitTo, val, fixed) {
70
+ if (isNotNaN) {
71
+ return convert(unitFrom, unitTo, val).toFixed(fixed || _tenth[unitTo]);
72
+ }
73
+ return DEFAULT_NAN;
74
+ }
75
+
76
+ export function toString(u) {
77
+ return _abbr[u];
78
+ }
@@ -1,47 +1,44 @@
1
- export function earthCoordinates(options: any): EarthCoordinates;
2
1
  /**
3
2
  * Control displays mouse or screen center Earth coordinates.
4
3
  * @class
5
- * @extends {Control}
4
+ * @extends {og.control.Control}
6
5
  * @param {Object} [options] - Options:
7
6
  * @param {Boolean} [options.center] - Earth coordiantes by screen center otherwise mouse pointer. False is default.
8
7
  * @param {Boolean} [options.type] - Coordinates shown: 0 - is decimal degrees, 1 - degrees, 2 - mercator geodetic coordinates.
9
8
  */
10
- export class EarthCoordinates extends Control {
9
+ export class EarthCoordinates {
10
+ constructor(options: any);
11
11
  /**
12
12
  * Display type.
13
13
  * @private
14
14
  * @type {Boolean}
15
15
  */
16
- private _displayType;
17
- /**
18
- * Current coordinates type converter.
19
- * @private
20
- * @function
21
- */
22
- private _converter;
23
- /**
24
- * Display dom element.
25
- * @private
26
- * @type {Object}
27
- */
28
- private _display;
29
- _center: any;
30
- _centerDiv: HTMLDivElement;
16
+ private _type;
17
+ _TYPE_FUNC: ((ll: any) => void)[];
18
+ _showFn: any;
31
19
  /**
32
20
  * Current position.
33
21
  * @public
34
- * @type {Vec3}
35
- */
36
- public position: Vec3;
37
- /**
38
- * Sets coordinates capturing type.
39
- * @public
40
- * @param {Boolean} center - True - capture screen center, false - mouse pointer.
22
+ * @type {og.Vec3}
41
23
  */
42
- public setCenter(center: boolean): void;
43
- _showPosition(): void;
44
- _grabCoordinates(): void;
45
- _onMouseMove(): void;
24
+ public _lonLat: og.Vec3;
25
+ _latSideEl: Element;
26
+ _lonSideEl: Element;
27
+ _latValEl: Element;
28
+ _lonValEl: Element;
29
+ _heightEl: Element;
30
+ _altUnitVal: any;
31
+ _heightModeVal: any;
32
+ _altUnit: any;
33
+ _heightMode: any;
34
+ _centerMode: any;
35
+ _SHOW_DECIMAL(ll: any): void;
36
+ _SHOW_DEGREE(ll: any): void;
37
+ _createCenterEl(): HTMLDivElement;
38
+ _updateUnits(): void;
39
+ _refreshCoordinates(): void;
40
+ oninit(): void;
41
+ _el: HTMLDivElement;
42
+ _grabCoordinates(px: any): void;
43
+ _showHeight(): Promise<void>;
46
44
  }
47
- import { Control } from "./Control.js";
@@ -259,6 +259,9 @@ export class Planet extends RenderNode {
259
259
  _initialized: boolean;
260
260
  always: any[];
261
261
  _renderCompleted: boolean;
262
+ _renderCompletedActivated: boolean;
263
+ _terrainCompleted: boolean;
264
+ _terrainCompletedActivated: boolean;
262
265
  /**
263
266
  * Add the given control to the renderer of the planet scene.
264
267
  * @param {control.Control} control - Control.
@@ -266,7 +269,6 @@ export class Planet extends RenderNode {
266
269
  addControl(control: control.Control): void;
267
270
  get lodSize(): number;
268
271
  setLodSize(currentLodSize: any, minLodSize: any, maxLodSize: any): void;
269
- _renderCompletedActivated: boolean;
270
272
  /**
271
273
  * Add the given controls array to the renderer of the planet.
272
274
  * @param {Array.<control.Control>} cArr - Control array.
@@ -566,6 +568,8 @@ export class Planet extends RenderNode {
566
568
  */
567
569
  public stopFlying(): void;
568
570
  getEntityTerrainPoint(entity: any, res: any): any;
571
+ getHeightDefault(lonLat: any): Promise<any>;
572
+ getHeightAboveELL(lonLat: any): Promise<any>;
569
573
  }
570
574
  import { RenderNode } from "./RenderNode.js";
571
575
  import { PlanetCamera } from "../camera/PlanetCamera.js";
@@ -72,4 +72,5 @@ export class EmptyTerrain {
72
72
  * @abstract
73
73
  */
74
74
  public clearCache(): void;
75
+ getHeightAsync(lonLat: any, callback: any): boolean;
75
76
  }
@@ -48,7 +48,6 @@ export class GlobusTerrain extends EmptyTerrain {
48
48
  * @returns {string} - Url query string.
49
49
  */
50
50
  private _urlRewriteCallback;
51
- getHeightAsync(lonLat: any, callback: any, zoom: any): boolean;
52
51
  getTileCache(lonLat: any, z: any): any;
53
52
  _getGroundHeightMerc(merc: any, tileData: any): number;
54
53
  /**
@@ -4,6 +4,7 @@ export class Loader {
4
4
  events: Events;
5
5
  _loading: number;
6
6
  _queue: any[];
7
+ _senderRequestCounter: any[];
7
8
  _promises: {
8
9
  json: (r: any) => any;
9
10
  blob: (r: any) => any;
@@ -19,6 +20,8 @@ export class Loader {
19
20
  status: string;
20
21
  msg: any;
21
22
  }>;
23
+ _checkLoadend(request: any, sender: any): void;
24
+ _handleResponse(q: any, response: any): void;
22
25
  _exec(): Promise<void>;
23
26
  abort(): void;
24
27
  }
@@ -0,0 +1,20 @@
1
+ export function convert(from: any, to: any, val: any): any;
2
+ export function convertExt(isNotNaN: any, unitFrom: any, unitTo: any, val: any, fixed: any): any;
3
+ export function toString(u: any): string;
4
+ export const ELL: 0;
5
+ export const MSL: 1;
6
+ export const GND: 2;
7
+ export namespace heightMode {
8
+ export { ELL as ell };
9
+ export { MSL as msl };
10
+ export { GND as gnd };
11
+ }
12
+ export const m: 0;
13
+ export const km: 1;
14
+ export const ft: 2;
15
+ export const s: 3;
16
+ export const h: 4;
17
+ export const ms: 5;
18
+ export const kmh: 6;
19
+ export const fts: 7;
20
+ export const _tenth: number[];