@openglobus/og 0.18.3 → 0.18.5

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.
Files changed (44) hide show
  1. package/README.md +8 -5
  2. package/css/og.css +251 -3
  3. package/lib/@openglobus/og.css +1 -1
  4. package/lib/@openglobus/og.esm.js +1 -1
  5. package/lib/@openglobus/og.esm.js.map +1 -1
  6. package/lib/@openglobus/og.umd.js +1 -1
  7. package/lib/@openglobus/og.umd.js.map +1 -1
  8. package/lib/js/camera/PlanetCamera.d.ts +2 -2
  9. package/lib/js/camera/PlanetCamera.js +3 -2
  10. package/lib/js/control/Atmosphere.js +7 -10
  11. package/lib/js/control/EarthCoordinates.js +2 -2
  12. package/lib/js/control/elevationProfile/ElevationProfile.d.ts +41 -25
  13. package/lib/js/control/elevationProfile/ElevationProfile.js +103 -74
  14. package/lib/js/control/elevationProfile/ElevationProfileButtonsView.d.ts +14 -0
  15. package/lib/js/control/elevationProfile/ElevationProfileButtonsView.js +61 -0
  16. package/lib/js/control/elevationProfile/ElevationProfileControl.d.ts +33 -0
  17. package/lib/js/control/elevationProfile/ElevationProfileControl.js +153 -0
  18. package/lib/js/control/elevationProfile/ElevationProfileLegend.d.ts +20 -0
  19. package/lib/js/control/elevationProfile/ElevationProfileLegend.js +82 -0
  20. package/lib/js/control/elevationProfile/ElevationProfileScene.d.ts +80 -0
  21. package/lib/js/control/elevationProfile/ElevationProfileScene.js +539 -0
  22. package/lib/js/control/elevationProfile/ElevationProfileView.d.ts +63 -0
  23. package/lib/js/control/elevationProfile/ElevationProfileView.js +504 -0
  24. package/lib/js/control/elevationProfile/PointListDialog.d.ts +12 -0
  25. package/lib/js/control/elevationProfile/PointListDialog.js +57 -0
  26. package/lib/js/control/index.d.ts +2 -1
  27. package/lib/js/control/index.js +2 -1
  28. package/lib/js/entity/Polyline.js +1 -1
  29. package/lib/js/layer/GeoImage.js +3 -0
  30. package/lib/js/renderer/Renderer.d.ts +0 -1
  31. package/lib/js/renderer/Renderer.js +3 -28
  32. package/lib/js/renderer/RendererEvents.js +0 -7
  33. package/lib/js/scene/Planet.d.ts +4 -0
  34. package/lib/js/scene/Planet.js +9 -1
  35. package/lib/js/terrain/GlobusTerrain.d.ts +3 -0
  36. package/lib/js/terrain/GlobusTerrain.js +14 -2
  37. package/lib/js/terrain/MapboxTerrain.js +29 -29
  38. package/lib/js/ui/Dialog.js +1 -1
  39. package/lib/js/utils/TerrainWorker.js +1 -1
  40. package/lib/js/utils/shared.d.ts +2 -1
  41. package/lib/js/utils/shared.js +21 -3
  42. package/package.json +1 -1
  43. package/lib/js/shaders/pickingMask.d.ts +0 -2
  44. package/lib/js/shaders/pickingMask.js +0 -22
@@ -0,0 +1,153 @@
1
+ import { Control } from "../Control";
2
+ import { Dialog } from "../../ui/Dialog";
3
+ import { View } from "../../ui/View";
4
+ import { ToggleButton } from "../../ui/ToggleButton";
5
+ import { ElevationProfileView } from "./ElevationProfileView";
6
+ import { ElevationProfileScene } from "./ElevationProfileScene";
7
+ import { throttle } from "../../utils/shared";
8
+ import { ElevationProfileButtonsView } from "./ElevationProfileButtonsView";
9
+ import { PointListDialog } from "./PointListDialog";
10
+ import { ElevationProfileLegend } from "./ElevationProfileLegend";
11
+ const TEMPLATE = `<div class="og-elevationprofile__container">
12
+ <div class="og-elevationprofile__menu"></div>
13
+ <div class="og-elevationprofile__graph"></div>
14
+ </div>`;
15
+ const ICON_BUTTON_SVG = `<svg style="width: 2em; height: 2em;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M128 896v-158.293333l331.946667-191.573334 160.853333 93.866667L896 480V896H128M896 381.44l-275.2 159.146667-160.853333-92.586667L128 640v-94.293333l331.946667-191.573334 160.853333 93.866667L896 288v93.44z" fill="" /></svg>`;
16
+ export class ElevationProfileControl extends Control {
17
+ constructor(options = {}) {
18
+ super({
19
+ name: "ElevationProfileControl",
20
+ ...options
21
+ });
22
+ this._onSceneChange = () => {
23
+ this._collectProfileThrottled();
24
+ };
25
+ this._onElevationProfilePointer = (pointerDistance, tp0, tp1, gp0, gp1, trackPoiIndex, groundPoiIndex, elevation) => {
26
+ let lonLat0 = this._elevationProfileScene.getPointLonLat(trackPoiIndex);
27
+ let lonLat1 = this._elevationProfileScene.getPointLonLat(trackPoiIndex + 1);
28
+ let cart0 = this.planet.ellipsoid.lonLatToCartesian(lonLat0), cart1 = this.planet.ellipsoid.lonLatToCartesian(lonLat1);
29
+ let d = (pointerDistance - tp0[0]) / (tp1[0] - tp0[0]);
30
+ let dir = cart1.sub(cart0);
31
+ this._elevationProfileScene.setPointerCartesian3v(cart0.add(dir.scale(d)), elevation);
32
+ };
33
+ this._onElevationProfileDblClick = (pointerDistance, tp0, tp1, gp0, gp1, trackPoiIndex, groundPoiIndex, elevation) => {
34
+ let lonLat0 = this._elevationProfileScene.getPointLonLat(trackPoiIndex);
35
+ let lonLat1 = this._elevationProfileScene.getPointLonLat(trackPoiIndex + 1);
36
+ let cart0 = this.planet.ellipsoid.lonLatToCartesian(lonLat0), cart1 = this.planet.ellipsoid.lonLatToCartesian(lonLat1);
37
+ let d = (pointerDistance - tp0[0]) / (tp1[0] - tp0[0]);
38
+ let dir = cart1.sub(cart0);
39
+ let poi = cart0.add(dir.scale(d));
40
+ this.planet.camera.flyDistance(poi, this.planet.camera.eye.distance(poi));
41
+ };
42
+ this._onElevationProfileMouseEnter = () => {
43
+ if (this._elevationProfileView.model.pointsReady) {
44
+ this._elevationProfileScene.setPointerVisibility(true);
45
+ }
46
+ };
47
+ this._onElevationProfileMouseLeave = () => {
48
+ };
49
+ this._elevationProfileScene = new ElevationProfileScene();
50
+ this._elevationProfileView = new ElevationProfileView();
51
+ this._elevationProfileLegend = new ElevationProfileLegend();
52
+ this._elevationProfileButtonsView = new ElevationProfileButtonsView({
53
+ model: this._elevationProfileView.model
54
+ });
55
+ this._elevationProfileView.events.on("pointer", this._onElevationProfilePointer);
56
+ this._elevationProfileView.events.on("dblclick", this._onElevationProfileDblClick);
57
+ this._elevationProfileView.events.on("mouseenter", this._onElevationProfileMouseEnter);
58
+ this._elevationProfileView.events.on("mouseleave", this._onElevationProfileMouseLeave);
59
+ this._dialog = new Dialog({
60
+ title: "Elevation Profile",
61
+ visible: false,
62
+ resizable: true,
63
+ useHide: true,
64
+ top: 175,
65
+ left: 65,
66
+ width: 400,
67
+ height: 200,
68
+ minHeight: 100,
69
+ minWidth: 100
70
+ });
71
+ this._graphView = new View({
72
+ template: TEMPLATE
73
+ });
74
+ this._poiListDialog = new PointListDialog({
75
+ model: this._elevationProfileScene
76
+ });
77
+ this._toggleBtn = new ToggleButton({
78
+ classList: ["og-map-button", "og-elevationprofile_button"],
79
+ icon: ICON_BUTTON_SVG
80
+ });
81
+ this._collectProfileThrottled = throttle(() => {
82
+ let points = this._elevationProfileScene.getPointsLonLat();
83
+ this._elevationProfileView.model.collectProfile(points);
84
+ }, 250);
85
+ }
86
+ oninit() {
87
+ this._dialog.appendTo(this.planet.renderer.div);
88
+ this._graphView.appendTo(this._dialog.container);
89
+ this._toggleBtn.appendTo(this.renderer.div);
90
+ this._dialog.events.on("visibility", (v) => {
91
+ this._toggleBtn.setActive(v);
92
+ if (v) {
93
+ this.activate();
94
+ this._elevationProfileView.resize();
95
+ }
96
+ else {
97
+ this.deactivate();
98
+ }
99
+ });
100
+ this._toggleBtn.events.on("change", (isActive) => {
101
+ this._dialog.setVisibility(isActive);
102
+ });
103
+ this._elevationProfileView.appendTo(this._graphView.select(".og-elevationprofile__graph"));
104
+ this._elevationProfileView.model.bindPlanet(this.planet);
105
+ this._elevationProfileView.model.events.on("clear", () => {
106
+ this._elevationProfileScene.clear();
107
+ this._elevationProfileLegend.clear();
108
+ });
109
+ this._elevationProfileView.model.events.on("startcollecting", () => {
110
+ this._elevationProfileScene.setPointerVisibility(false);
111
+ });
112
+ this._elevationProfileView.events.on("tracklength", (length) => {
113
+ this._elevationProfileLegend.setTrackLength(length);
114
+ });
115
+ this._elevationProfileView.events.on("groundlength", (length) => {
116
+ this._elevationProfileLegend.setGroundLength(length);
117
+ });
118
+ this._elevationProfileView.events.on("warninglength", (length) => {
119
+ this._elevationProfileLegend.setWarningLength(length);
120
+ });
121
+ this._elevationProfileView.events.on("collisionlength", (length) => {
122
+ this._elevationProfileLegend.setCollisionLength(length);
123
+ });
124
+ this._poiListDialog.appendTo(this.planet.renderer.div);
125
+ this._poiListDialog.events.on("visibility", (isVisible) => {
126
+ this._elevationProfileButtonsView.pointListBtn.setActive(isVisible, true);
127
+ });
128
+ this._elevationProfileLegend.appendTo(this._graphView.select(".og-elevationprofile__menu"));
129
+ this._elevationProfileButtonsView.appendTo(this._graphView.select(".og-elevationprofile__menu"));
130
+ this._elevationProfileButtonsView.events.on("list", (isActive) => {
131
+ this._poiListDialog.setVisibility(isActive);
132
+ });
133
+ this._elevationProfileButtonsView.events.on("location", (isActive) => {
134
+ this._elevationProfileScene.flyExtent();
135
+ });
136
+ this._elevationProfileButtonsView.events.on("reset", (isActive) => {
137
+ this._elevationProfileScene.setPointerVisibility(false);
138
+ });
139
+ this._elevationProfileScene.events.on("change", this._onSceneChange);
140
+ }
141
+ onactivate() {
142
+ this.renderer.controls.mouseNavigation.deactivateDoubleClickZoom();
143
+ this.planet && this._elevationProfileScene.bindPlanet(this.planet);
144
+ this.renderer && this.renderer.addNode(this._elevationProfileScene);
145
+ }
146
+ ondeactivate() {
147
+ this._poiListDialog.setVisibility(false);
148
+ this._elevationProfileView.model.clear();
149
+ this.renderer.controls.mouseNavigation.activateDoubleClickZoom();
150
+ this.renderer && this.renderer.removeNode(this._elevationProfileScene);
151
+ this._dialog.hide();
152
+ }
153
+ }
@@ -0,0 +1,20 @@
1
+ import { IViewParams, View } from '../../ui/View';
2
+ export interface IElevationProfileLegendParams extends IViewParams {
3
+ }
4
+ export declare class ElevationProfileLegend extends View<null> {
5
+ $groundValue: HTMLElement | null;
6
+ $trackValue: HTMLElement | null;
7
+ $warningValue: HTMLElement | null;
8
+ $collisionValue: HTMLElement | null;
9
+ $trackUnits: HTMLElement | null;
10
+ $groundUnits: HTMLElement | null;
11
+ $warningUnits: HTMLElement | null;
12
+ $collisionUnits: HTMLElement | null;
13
+ constructor(params?: IElevationProfileLegendParams);
14
+ render(params: any): this;
15
+ clear(): void;
16
+ setTrackLength(trackLength: number): void;
17
+ setGroundLength(groundLength: number): void;
18
+ setWarningLength(warningLength: number): void;
19
+ setCollisionLength(collisionLength: number): void;
20
+ }
@@ -0,0 +1,82 @@
1
+ import { View } from '../../ui/View';
2
+ import { distanceFormatExt } from "../../utils/shared";
3
+ const TEMPLATE = `<div class="og-elevationprofile-legend">
4
+ <div class="og-elevationprofile-legend__row og-elevationprofile-legend__track">
5
+ <div class="og-elevationprofile-square"></div>
6
+ <div class="og-elevationprofile-value">0</div>
7
+ <div class="og-elevationprofile-units">m</div>
8
+ </div>
9
+ <div class="og-elevationprofile-legend__row og-elevationprofile-legend__ground">
10
+ <div class="og-elevationprofile-square"></div>
11
+ <div class="og-elevationprofile-value">0</div>
12
+ <div class="og-elevationprofile-units">m</div>
13
+ </div>
14
+ <div class="og-elevationprofile-legend__row og-elevationprofile-legend__warning">
15
+ <div class="og-elevationprofile-square"></div>
16
+ <div class="og-elevationprofile-value">0</div>
17
+ <div class="og-elevationprofile-units">m</div>
18
+ </div>
19
+ <div class="og-elevationprofile-legend__row og-elevationprofile-legend__collision">
20
+ <div class="og-elevationprofile-square"></div>
21
+ <div class="og-elevationprofile-value">0</div>
22
+ <div class="og-elevationprofile-units">m</div>
23
+ </div>
24
+ </div>`;
25
+ export class ElevationProfileLegend extends View {
26
+ constructor(params = {}) {
27
+ super({
28
+ ...params,
29
+ template: TEMPLATE
30
+ });
31
+ this.$groundValue = null;
32
+ this.$trackValue = null;
33
+ this.$warningValue = null;
34
+ this.$collisionValue = null;
35
+ this.$trackUnits = null;
36
+ this.$groundUnits = null;
37
+ this.$warningUnits = null;
38
+ this.$collisionUnits = null;
39
+ }
40
+ render(params) {
41
+ super.render(params);
42
+ this.$trackValue = this.select(".og-elevationprofile-legend__track .og-elevationprofile-value");
43
+ this.$groundValue = this.select(".og-elevationprofile-legend__ground .og-elevationprofile-value");
44
+ this.$warningValue = this.select(".og-elevationprofile-legend__warning .og-elevationprofile-value");
45
+ this.$collisionValue = this.select(".og-elevationprofile-legend__collision .og-elevationprofile-value");
46
+ this.$trackUnits = this.select(".og-elevationprofile-legend__track .og-elevationprofile-units");
47
+ this.$groundUnits = this.select(".og-elevationprofile-legend__ground .og-elevationprofile-units");
48
+ this.$warningUnits = this.select(".og-elevationprofile-legend__warning .og-elevationprofile-units");
49
+ this.$collisionUnits = this.select(".og-elevationprofile-legend__collision .og-elevationprofile-units");
50
+ return this;
51
+ }
52
+ clear() {
53
+ this.$trackValue && (this.$trackValue.innerText = "0");
54
+ this.$trackUnits && (this.$trackUnits.innerText = "m");
55
+ this.$groundValue && (this.$groundValue.innerText = "0");
56
+ this.$groundUnits && (this.$groundUnits.innerText = "m");
57
+ this.$warningValue && (this.$warningValue.innerText = "0");
58
+ this.$warningUnits && (this.$warningUnits.innerText = "m");
59
+ this.$collisionValue && (this.$collisionValue.innerText = "0");
60
+ this.$collisionUnits && (this.$collisionUnits.innerText = "m");
61
+ }
62
+ setTrackLength(trackLength) {
63
+ let dist = distanceFormatExt(trackLength);
64
+ this.$trackValue.innerText = dist[0];
65
+ this.$trackUnits.innerText = dist[1];
66
+ }
67
+ setGroundLength(groundLength) {
68
+ let dist = distanceFormatExt(groundLength);
69
+ this.$groundValue.innerText = dist[0];
70
+ this.$groundUnits.innerText = dist[1];
71
+ }
72
+ setWarningLength(warningLength) {
73
+ let warningDist = distanceFormatExt(warningLength);
74
+ this.$warningValue.innerText = warningDist[0];
75
+ this.$warningUnits.innerText = warningDist[1];
76
+ }
77
+ setCollisionLength(collisionLength) {
78
+ let collisionDist = distanceFormatExt(collisionLength);
79
+ this.$collisionValue.innerText = collisionDist[0];
80
+ this.$collisionUnits.innerText = collisionDist[1];
81
+ }
82
+ }
@@ -0,0 +1,80 @@
1
+ import { Entity } from '../../entity/Entity';
2
+ import { EventsHandler } from '../../Events';
3
+ import { LonLat } from "../../LonLat";
4
+ import { Planet } from "../../scene/Planet";
5
+ import { RenderNode } from '../../scene/RenderNode';
6
+ import { Vector } from '../../layer/Vector';
7
+ import { Vec2 } from '../../math/Vec2';
8
+ import { Vec3 } from '../../math/Vec3';
9
+ import { IMouseState } from "../../renderer/RendererEvents";
10
+ import { Ellipsoid } from "../../ellipsoid/Ellipsoid";
11
+ export interface IElevationProfileSceneParams {
12
+ name?: string;
13
+ planet?: Planet;
14
+ }
15
+ declare class ElevationProfileScene extends RenderNode {
16
+ events: EventsHandler<ElevationProfileSceneEventsList>;
17
+ protected _planet: Planet | null;
18
+ protected _trackLayer: Vector;
19
+ protected _groundPointersLayer: Vector;
20
+ protected _columnPointersLayer: Vector;
21
+ protected _headPointersLayer: Vector;
22
+ protected _heightsLayer: Vector;
23
+ protected _trackEntity: Entity;
24
+ protected _pickedGroundEntity: Entity | null;
25
+ protected _pickedHeadEntity: Entity | null;
26
+ protected _pointerLayer: Vector;
27
+ protected _pointerHeadEntity: Entity;
28
+ protected _pointerLabelEntity: Entity;
29
+ protected _pointerRayEntity: Entity;
30
+ protected _startClickPos: Vec2;
31
+ protected _startEntityPos: Vec2;
32
+ protected _clampToGround: boolean;
33
+ constructor(options?: IElevationProfileSceneParams);
34
+ flyExtent(): void;
35
+ get planet(): Planet | null;
36
+ protected _createGroundPointer(groundCart: Vec3, altitude?: number): {
37
+ headEntity: Entity;
38
+ groundEntity: Entity;
39
+ columnEntity: Entity;
40
+ heightLabelEntity: Entity;
41
+ };
42
+ setPointerCartesian3v(p: Vec3, height: number): void;
43
+ bindPlanet(planet: Planet): void;
44
+ init(): void;
45
+ onremove(): void;
46
+ _activate(): void;
47
+ getPointLonLat(index: number): LonLat | undefined;
48
+ getPointsLonLat(): LonLat[];
49
+ getHeightMSL(lonLat: LonLat): number;
50
+ getHeightELLAsync(lonLat: LonLat): Promise<number>;
51
+ addPointLonLatArrayAsync(lonLatArr: LonLat[], stopPropagation?: boolean): Promise<Entity>[];
52
+ addPointLonLatAsync(lonLat: LonLat, stopPropagation?: boolean): Promise<Entity>;
53
+ addGroundPointLonLatAsync(lonLat: LonLat, altitude?: number, stopPropagation?: boolean): Promise<Entity>;
54
+ addGroundPoint3vAsync(groundPos: Vec3, altitude?: number, stopPropagation?: boolean): Promise<Entity>;
55
+ protected _addPoint(groundPos: Vec3, lonLat: LonLat, altitude: number, stopPropagation?: boolean): Promise<Entity>;
56
+ protected _onLClick: (e: IMouseState) => void;
57
+ protected _onMouseMove: (e: IMouseState) => void;
58
+ setHeadPointCartesian3v(entityIndex: number, headPos: Vec3): void;
59
+ setGroundPointCartesian3v(entityIndex: number, groundPos: Vec3): void;
60
+ protected _onLUp: (e: IMouseState) => void;
61
+ protected _onGroundPointerEnter: (e: IMouseState) => void;
62
+ protected _onGroundPointerLeave: (e: IMouseState) => void;
63
+ protected _onGroundPointerLDown: (e: IMouseState) => void;
64
+ protected _onGroundPointerLUp: (e: IMouseState) => void;
65
+ protected _onHeadPointerEnter: (e: IMouseState) => void;
66
+ protected _onHeadPointerLeave: (e: IMouseState) => void;
67
+ protected _onHeadPointerLDown: (e: IMouseState) => void;
68
+ protected _onHeadPointerLUp: (e: IMouseState) => void;
69
+ protected _deactivate(): void;
70
+ setPointerVisibility(visibility: boolean): void;
71
+ setVisibility(visibility: boolean): void;
72
+ clear(): void;
73
+ frame(): void;
74
+ get ellipsoid(): Ellipsoid | null;
75
+ }
76
+ type ElevationProfileSceneEventsList = [
77
+ "change",
78
+ "addpoint"
79
+ ];
80
+ export { ElevationProfileScene };