@vcmap/core 5.0.0-rc.5 → 5.0.0-rc.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/index.d.ts +50 -7
- package/index.js +2 -1
- package/package.json +3 -5
- package/src/vcs/vcm/globalCollections.js +1 -5
- package/src/vcs/vcm/maps/oblique.js +17 -22
- package/src/vcs/vcm/oblique/ObliqueCollection.js +25 -1
- package/src/vcs/vcm/oblique/ObliqueImageMeta.js +2 -2
- package/src/vcs/vcm/oblique/ObliqueProvider.js +2 -1
- package/src/vcs/vcm/oblique/ObliqueView.js +31 -1
- package/src/vcs/vcm/oblique/defaultObliqueCollection.js +62 -0
- package/src/vcs/vcm/vcsApp.js +14 -1
package/index.d.ts
CHANGED
|
@@ -182,8 +182,6 @@ export class VcsEvent<T extends any> {
|
|
|
182
182
|
|
|
183
183
|
export const styleCollection: Collection<StyleItem>;
|
|
184
184
|
|
|
185
|
-
export const obliqueCollectionCollection: Collection<ObliqueCollection>;
|
|
186
|
-
|
|
187
185
|
/**
|
|
188
186
|
*/
|
|
189
187
|
export interface ObliqueParameters {
|
|
@@ -5259,7 +5257,6 @@ export interface ObliqueOptions extends VcsMapOptions {
|
|
|
5259
5257
|
changeOnMoveEnd?: boolean;
|
|
5260
5258
|
switchThreshold?: number;
|
|
5261
5259
|
switchOnEdge?: boolean;
|
|
5262
|
-
defaultCollectionName?: string | undefined;
|
|
5263
5260
|
}
|
|
5264
5261
|
|
|
5265
5262
|
/**
|
|
@@ -5271,7 +5268,6 @@ export function getViewDirectionFromViewPoint(viewpoint: ViewPoint): ObliqueView
|
|
|
5271
5268
|
* Oblique Map Class (2D map with oblique imagery)
|
|
5272
5269
|
*/
|
|
5273
5270
|
export class Oblique extends BaseOLMap {
|
|
5274
|
-
constructor(options: ObliqueOptions);
|
|
5275
5271
|
static getDefaultOptions(): ObliqueOptions;
|
|
5276
5272
|
|
|
5277
5273
|
/**
|
|
@@ -5501,6 +5497,7 @@ export interface ObliqueCollectionOptions extends VcsObjectOptions {
|
|
|
5501
5497
|
minZoom?: number | undefined;
|
|
5502
5498
|
scaleFactor?: number | undefined;
|
|
5503
5499
|
hideLevels?: number | undefined;
|
|
5500
|
+
activeOnStartup?: boolean | undefined;
|
|
5504
5501
|
}
|
|
5505
5502
|
|
|
5506
5503
|
export class ObliqueCollection {
|
|
@@ -5512,11 +5509,16 @@ export class ObliqueCollection {
|
|
|
5512
5509
|
* Event raised when images are loaded. Is passed an Array of ObliqueImages as its only argument.
|
|
5513
5510
|
*/
|
|
5514
5511
|
imagesLoaded: VcsEvent<ObliqueImage[]>;
|
|
5512
|
+
/**
|
|
5513
|
+
* Whether to activate this collection after loading its defining context.
|
|
5514
|
+
*/
|
|
5515
|
+
activeOnStartup: boolean;
|
|
5515
5516
|
readonly dataSets: ObliqueDataSet[];
|
|
5516
5517
|
/**
|
|
5517
5518
|
* Indicates, that this collection has been loaded
|
|
5518
5519
|
*/
|
|
5519
5520
|
loaded: boolean;
|
|
5521
|
+
destroyed: any;
|
|
5520
5522
|
/**
|
|
5521
5523
|
* A vector source of all tiles available to this collection in mercator. The feature have a "state" property,
|
|
5522
5524
|
* the id is the string tile coordinate "z/x/y" of the tile
|
|
@@ -5766,7 +5768,7 @@ export interface ObliqueImageMetaOptions {
|
|
|
5766
5768
|
tileResolution: number[];
|
|
5767
5769
|
projection: Projection;
|
|
5768
5770
|
url: string;
|
|
5769
|
-
terrainProvider
|
|
5771
|
+
terrainProvider?: import("@vcmap/cesium").CesiumTerrainProvider;
|
|
5770
5772
|
name: string;
|
|
5771
5773
|
format?: string | undefined;
|
|
5772
5774
|
}
|
|
@@ -5802,7 +5804,7 @@ export class ObliqueImageMeta {
|
|
|
5802
5804
|
/**
|
|
5803
5805
|
* An optional terrain provider
|
|
5804
5806
|
*/
|
|
5805
|
-
terrainProvider: import("@vcmap/cesium").CesiumTerrainProvider;
|
|
5807
|
+
terrainProvider: import("@vcmap/cesium").CesiumTerrainProvider | undefined;
|
|
5806
5808
|
format: string;
|
|
5807
5809
|
/**
|
|
5808
5810
|
* Removes radial distortion in image coordinates. Radial coefficients must be provided
|
|
@@ -5911,7 +5913,7 @@ export class ObliqueView {
|
|
|
5911
5913
|
/**
|
|
5912
5914
|
* Sets the layers source to request data for this image
|
|
5913
5915
|
*/
|
|
5914
|
-
setImageName(name: string): void;
|
|
5916
|
+
setImageName(name: string, isDefaultImage?: boolean): void;
|
|
5915
5917
|
}
|
|
5916
5918
|
|
|
5917
5919
|
/**
|
|
@@ -5931,6 +5933,43 @@ export const obliqueViewDirectionNames: {
|
|
|
5931
5933
|
|
|
5932
5934
|
export function getDirectionName(direction: number): string | undefined;
|
|
5933
5935
|
|
|
5936
|
+
/**
|
|
5937
|
+
* This is a special oblique collection wich is shown, if no other oblique collection is set on an Oblique map.
|
|
5938
|
+
* It will render a single image which indicates that no images can be loaded.
|
|
5939
|
+
*/
|
|
5940
|
+
export class DefaultObliqueCollection extends ObliqueCollection {
|
|
5941
|
+
viewOptions: ObliqueViewOptions;
|
|
5942
|
+
|
|
5943
|
+
/**
|
|
5944
|
+
* Event raised when images are loaded. Is passed an Array of ObliqueImages as its only argument.
|
|
5945
|
+
*/
|
|
5946
|
+
imagesLoaded: VcsEvent<ObliqueImage[]>;
|
|
5947
|
+
/**
|
|
5948
|
+
* Whether to activate this collection after loading its defining context.
|
|
5949
|
+
*/
|
|
5950
|
+
activeOnStartup: boolean;
|
|
5951
|
+
readonly dataSets: ObliqueDataSet[];
|
|
5952
|
+
/**
|
|
5953
|
+
* Indicates, that this collection has been loaded
|
|
5954
|
+
*/
|
|
5955
|
+
loaded: boolean;
|
|
5956
|
+
destroyed: any;
|
|
5957
|
+
/**
|
|
5958
|
+
* A vector source of all tiles available to this collection in mercator. The feature have a "state" property,
|
|
5959
|
+
* the id is the string tile coordinate "z/x/y" of the tile
|
|
5960
|
+
*/
|
|
5961
|
+
readonly tileFeatureSource: import("ol/source/Vector").default<import("ol/geom/Geometry").default>;
|
|
5962
|
+
/**
|
|
5963
|
+
* A vector source of all image currently loaded for this collection in mercator.
|
|
5964
|
+
* The id is the image name. The feature has a "viewDirection" property.
|
|
5965
|
+
*/
|
|
5966
|
+
readonly imageFeatureSource: import("ol/source/Vector").default<import("ol/geom/Geometry").default>;
|
|
5967
|
+
/**
|
|
5968
|
+
* All currently loaded images
|
|
5969
|
+
*/
|
|
5970
|
+
readonly images: ObliqueImage[];
|
|
5971
|
+
}
|
|
5972
|
+
|
|
5934
5973
|
export interface PickTerrainReturn {
|
|
5935
5974
|
estimate: boolean;
|
|
5936
5975
|
coords: import("ol/coordinate").Coordinate;
|
|
@@ -7565,6 +7604,10 @@ export class VcsApp {
|
|
|
7565
7604
|
addContext(context: Context): Promise<void>;
|
|
7566
7605
|
protected _removeContext(contextId: string): Promise<void>;
|
|
7567
7606
|
removeContext(contextId: string): Promise<void>;
|
|
7607
|
+
/**
|
|
7608
|
+
* Destroys the app and all its collections, their content and ui managers.
|
|
7609
|
+
*/
|
|
7610
|
+
destroy(): void;
|
|
7568
7611
|
}
|
|
7569
7612
|
|
|
7570
7613
|
export function getVcsAppById(id: string): VcsApp;
|
package/index.js
CHANGED
|
@@ -12,7 +12,7 @@ export { default as CategoryCollection } from './src/vcs/vcm/category/categoryCo
|
|
|
12
12
|
export { VcsClassRegistry, default as ClassRegistry } from './src/vcs/vcm/classRegistry.js';
|
|
13
13
|
export { default as Context } from './src/vcs/vcm/context.js';
|
|
14
14
|
export { default as VcsEvent } from './src/vcs/vcm/event/vcsEvent.js';
|
|
15
|
-
export { styleCollection
|
|
15
|
+
export { styleCollection } from './src/vcs/vcm/globalCollections.js';
|
|
16
16
|
export { default as AbstractInteraction } from './src/vcs/vcm/interaction/abstractInteraction.js';
|
|
17
17
|
export { default as CoordinateAtPixel } from './src/vcs/vcm/interaction/coordinateAtPixel.js';
|
|
18
18
|
export { default as EventHandler } from './src/vcs/vcm/interaction/eventHandler.js';
|
|
@@ -102,6 +102,7 @@ export { default as ObliqueImageMeta } from './src/vcs/vcm/oblique/ObliqueImageM
|
|
|
102
102
|
export { default as ObliqueProvider } from './src/vcs/vcm/oblique/ObliqueProvider.js';
|
|
103
103
|
export { default as ObliqueView } from './src/vcs/vcm/oblique/ObliqueView.js';
|
|
104
104
|
export { ObliqueViewDirection, obliqueViewDirectionNames, getDirectionName } from './src/vcs/vcm/oblique/ObliqueViewDirection.js';
|
|
105
|
+
export { default as DefaultObliqueCollection } from './src/vcs/vcm/oblique/defaultObliqueCollection.js';
|
|
105
106
|
export { sortRealWordEdgeCoordinates, checkLineIntersection, transformCWIFC, transformToImage, transformFromImage, hasSameOrigin } from './src/vcs/vcm/oblique/helpers.js';
|
|
106
107
|
export { getVersionFromImageJson, parseImageMeta, parseImageData, parseLegacyImageData } from './src/vcs/vcm/oblique/parseImageJson.js';
|
|
107
108
|
export { default as ClippingObject } from './src/vcs/vcm/util/clipping/clippingObject.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vcmap/core",
|
|
3
|
-
"version": "5.0.0-rc.
|
|
3
|
+
"version": "5.0.0-rc.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -36,7 +36,6 @@
|
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@rollup/plugin-commonjs": "^18.0.0",
|
|
38
38
|
"@rollup/plugin-node-resolve": "^11.2.1",
|
|
39
|
-
"@vcmap/cesium": "^1.87.3",
|
|
40
39
|
"@vcsuite/eslint-config": "^2.0.3",
|
|
41
40
|
"@vcsuite/tsd-jsdoc": "^1.0.2",
|
|
42
41
|
"@web/dev-server": "^0.1.11",
|
|
@@ -53,14 +52,13 @@
|
|
|
53
52
|
"mocha-junit-reporter": "^2.0.2",
|
|
54
53
|
"nock": "^13.2.4",
|
|
55
54
|
"node-fetch": "^3.2.0",
|
|
56
|
-
"ol": "^6.9.0",
|
|
57
55
|
"sinon": "^9.2.4",
|
|
58
56
|
"sinon-chai": "^3.6.0",
|
|
59
57
|
"typescript": "^4.4.4"
|
|
60
58
|
},
|
|
61
59
|
"peerDependencies": {
|
|
62
|
-
"@vcmap/cesium": "~1.87.
|
|
63
|
-
"ol": "^6.
|
|
60
|
+
"@vcmap/cesium": "~1.87.3",
|
|
61
|
+
"ol": "^6.9.0"
|
|
64
62
|
},
|
|
65
63
|
"eslintConfig": {
|
|
66
64
|
"extends": [
|
|
@@ -3,9 +3,5 @@ import Collection from './util/collection.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* @type {import("@vcmap/core").Collection<import("@vcmap/core").StyleItem>}
|
|
5
5
|
*/
|
|
6
|
+
// eslint-disable-next-line import/prefer-default-export
|
|
6
7
|
export const styleCollection = new Collection();
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @type {import("@vcmap/core").Collection<import("@vcmap/core").ObliqueCollection>}
|
|
10
|
-
*/
|
|
11
|
-
export const obliqueCollectionCollection = new Collection();
|
|
@@ -9,12 +9,12 @@ import ViewPoint from '../util/viewpoint.js';
|
|
|
9
9
|
import BaseOLMap from './baseOLMap.js';
|
|
10
10
|
import VcsMap from './map.js';
|
|
11
11
|
import VcsEvent from '../event/vcsEvent.js';
|
|
12
|
-
import { obliqueCollectionCollection } from '../globalCollections.js';
|
|
13
12
|
import { ObliqueViewDirection as ViewDirection } from '../oblique/ObliqueViewDirection.js';
|
|
14
13
|
import ObliqueProvider from '../oblique/ObliqueProvider.js';
|
|
15
14
|
import ObliqueCollection from '../oblique/ObliqueCollection.js';
|
|
16
15
|
import { transformFromImage } from '../oblique/helpers.js';
|
|
17
16
|
import { VcsClassRegistry } from '../classRegistry.js';
|
|
17
|
+
import DefaultObliqueCollection from '../oblique/defaultObliqueCollection.js';
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* @typedef {Object} ObliqueClickParameters
|
|
@@ -28,7 +28,6 @@ import { VcsClassRegistry } from '../classRegistry.js';
|
|
|
28
28
|
* @property {boolean} [changeOnMoveEnd=false]
|
|
29
29
|
* @property {number} [switchThreshold=0]
|
|
30
30
|
* @property {boolean} [switchOnEdge=true]
|
|
31
|
-
* @property {string|undefined} defaultCollectionName
|
|
32
31
|
* @api
|
|
33
32
|
*/
|
|
34
33
|
|
|
@@ -39,6 +38,8 @@ const defaultHeadings = {
|
|
|
39
38
|
[ViewDirection.WEST]: 270,
|
|
40
39
|
};
|
|
41
40
|
|
|
41
|
+
const defaultCollection = new DefaultObliqueCollection();
|
|
42
|
+
|
|
42
43
|
/**
|
|
43
44
|
* returns the direction which matches the heading of the viewpoint
|
|
44
45
|
* @param {ViewPoint} viewpoint
|
|
@@ -91,22 +92,12 @@ class Oblique extends BaseOLMap {
|
|
|
91
92
|
changeOnMoveEnd: false,
|
|
92
93
|
switchThreshold: 0,
|
|
93
94
|
switchOnEdge: true,
|
|
94
|
-
defaultCollectionName: undefined,
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
/**
|
|
99
|
-
* @param {ObliqueOptions} options
|
|
100
|
-
*/
|
|
101
98
|
constructor(options) {
|
|
102
99
|
super(options);
|
|
103
100
|
const defaultOptions = Oblique.getDefaultOptions();
|
|
104
|
-
/**
|
|
105
|
-
* @type {string|undefined}
|
|
106
|
-
* @private
|
|
107
|
-
*/
|
|
108
|
-
this._defaultCollectionName = options.defaultCollectionName || defaultOptions.defaultCollectionName;
|
|
109
|
-
|
|
110
101
|
/**
|
|
111
102
|
* @type {ObliqueCollection|null}
|
|
112
103
|
* @private
|
|
@@ -139,6 +130,11 @@ class Oblique extends BaseOLMap {
|
|
|
139
130
|
* @api
|
|
140
131
|
*/
|
|
141
132
|
this.collectionChanged = new VcsEvent();
|
|
133
|
+
/**
|
|
134
|
+
* @type {function():void}
|
|
135
|
+
* @private
|
|
136
|
+
*/
|
|
137
|
+
this._activeCollectionDestroyedListener = () => {};
|
|
142
138
|
}
|
|
143
139
|
|
|
144
140
|
/**
|
|
@@ -209,9 +205,7 @@ class Oblique extends BaseOLMap {
|
|
|
209
205
|
this.switchEnabled = this._switchEnabled;
|
|
210
206
|
let collectionToLoad = this._loadingCollection;
|
|
211
207
|
if (!collectionToLoad) {
|
|
212
|
-
collectionToLoad =
|
|
213
|
-
obliqueCollectionCollection.getByKey(this._defaultCollectionName) :
|
|
214
|
-
[...obliqueCollectionCollection][0];
|
|
208
|
+
collectionToLoad = defaultCollection;
|
|
215
209
|
}
|
|
216
210
|
if (collectionToLoad) {
|
|
217
211
|
await this._setCollection(collectionToLoad);
|
|
@@ -333,11 +327,11 @@ class Oblique extends BaseOLMap {
|
|
|
333
327
|
return;
|
|
334
328
|
}
|
|
335
329
|
|
|
336
|
-
|
|
337
|
-
|
|
330
|
+
this._loadingCollection = obliqueCollection;
|
|
331
|
+
if (!this.initializedPromise) {
|
|
338
332
|
return;
|
|
339
333
|
}
|
|
340
|
-
|
|
334
|
+
|
|
341
335
|
await this.initializedPromise;
|
|
342
336
|
if (this._loadingCollection !== obliqueCollection) {
|
|
343
337
|
return;
|
|
@@ -354,6 +348,10 @@ class Oblique extends BaseOLMap {
|
|
|
354
348
|
*/
|
|
355
349
|
async _setCollection(obliqueCollection, viewpoint) {
|
|
356
350
|
this._loadingCollection = obliqueCollection;
|
|
351
|
+
this._activeCollectionDestroyedListener();
|
|
352
|
+
this._activeCollectionDestroyedListener = obliqueCollection.destroyed.addEventListener(() => {
|
|
353
|
+
this._setCollection(defaultCollection);
|
|
354
|
+
});
|
|
357
355
|
await obliqueCollection.load();
|
|
358
356
|
const vp = viewpoint || await this.getViewPoint();
|
|
359
357
|
if (this._loadingCollection !== obliqueCollection) {
|
|
@@ -513,10 +511,6 @@ class Oblique extends BaseOLMap {
|
|
|
513
511
|
config.switchOnEdge = this.switchEnabled;
|
|
514
512
|
}
|
|
515
513
|
|
|
516
|
-
if (this._defaultCollectionName !== defaultOptions.defaultCollectionName) {
|
|
517
|
-
config.defaultCollectionName = this._defaultCollectionName;
|
|
518
|
-
}
|
|
519
|
-
|
|
520
514
|
return config;
|
|
521
515
|
}
|
|
522
516
|
|
|
@@ -528,6 +522,7 @@ class Oblique extends BaseOLMap {
|
|
|
528
522
|
this._obliqueProvider.destroy();
|
|
529
523
|
}
|
|
530
524
|
this.collectionChanged.destroy();
|
|
525
|
+
this._activeCollectionDestroyedListener();
|
|
531
526
|
super.destroy();
|
|
532
527
|
}
|
|
533
528
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { parseInteger, parseNumber } from '@vcsuite/parsers';
|
|
1
|
+
import { parseBoolean, parseInteger, parseNumber } from '@vcsuite/parsers';
|
|
2
2
|
import RBush from 'rbush';
|
|
3
3
|
import knn from 'rbush-knn';
|
|
4
4
|
import { getTransform } from 'ol/proj.js';
|
|
@@ -67,6 +67,7 @@ import VcsObject from '../object.js';
|
|
|
67
67
|
* @property {number|undefined} [minZoom]
|
|
68
68
|
* @property {number|undefined} [scaleFactor=4]
|
|
69
69
|
* @property {number|undefined} [hideLevels]
|
|
70
|
+
* @property {boolean|undefined} [activeOnStartup=false]
|
|
70
71
|
* @api
|
|
71
72
|
*/
|
|
72
73
|
|
|
@@ -124,6 +125,7 @@ class ObliqueCollection extends VcsObject {
|
|
|
124
125
|
scaleFactor: 4,
|
|
125
126
|
dataSets: undefined,
|
|
126
127
|
hideLevels: 0,
|
|
128
|
+
activeOnStartup: false,
|
|
127
129
|
};
|
|
128
130
|
}
|
|
129
131
|
|
|
@@ -185,6 +187,18 @@ class ObliqueCollection extends VcsObject {
|
|
|
185
187
|
this._addDataSet(dataSet);
|
|
186
188
|
});
|
|
187
189
|
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* @type {VcsEvent<void>}
|
|
193
|
+
* @private
|
|
194
|
+
*/
|
|
195
|
+
this._destroyed = new VcsEvent();
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Whether to activate this collection after loading its defining context.
|
|
199
|
+
* @type {boolean}
|
|
200
|
+
*/
|
|
201
|
+
this.activeOnStartup = parseBoolean(options.activeOnStartup, defaultOptions.activeOnStartup);
|
|
188
202
|
}
|
|
189
203
|
|
|
190
204
|
/**
|
|
@@ -205,6 +219,13 @@ class ObliqueCollection extends VcsObject {
|
|
|
205
219
|
return this._loaded;
|
|
206
220
|
}
|
|
207
221
|
|
|
222
|
+
/**
|
|
223
|
+
* @returns {VcsEvent<void>}
|
|
224
|
+
*/
|
|
225
|
+
get destroyed() {
|
|
226
|
+
return this._destroyed;
|
|
227
|
+
}
|
|
228
|
+
|
|
208
229
|
/**
|
|
209
230
|
* A vector source of all tiles available to this collection in mercator. The feature have a "state" property,
|
|
210
231
|
* the id is the string tile coordinate "z/x/y" of the tile
|
|
@@ -592,6 +613,9 @@ class ObliqueCollection extends VcsObject {
|
|
|
592
613
|
this._imageFeatureSource = null;
|
|
593
614
|
}
|
|
594
615
|
this.imagesLoaded.destroy();
|
|
616
|
+
super.destroy();
|
|
617
|
+
this.destroyed.raiseEvent();
|
|
618
|
+
this._destroyed.destroy();
|
|
595
619
|
}
|
|
596
620
|
|
|
597
621
|
/**
|
|
@@ -11,7 +11,7 @@ import { cartesian2DDistance } from '../util/math.js';
|
|
|
11
11
|
* @property {Array<number>} tileResolution
|
|
12
12
|
* @property {import("@vcmap/core").Projection} projection
|
|
13
13
|
* @property {string} url
|
|
14
|
-
* @property {import("@vcmap/cesium").CesiumTerrainProvider} terrainProvider
|
|
14
|
+
* @property {import("@vcmap/cesium").CesiumTerrainProvider} [terrainProvider]
|
|
15
15
|
* @property {string} name
|
|
16
16
|
* @property {string|undefined} [format='jpg']
|
|
17
17
|
* @api
|
|
@@ -75,7 +75,7 @@ class ObliqueImageMeta {
|
|
|
75
75
|
this.url = options.url;
|
|
76
76
|
/**
|
|
77
77
|
* An optional terrain provider
|
|
78
|
-
* @type {import("@vcmap/cesium").CesiumTerrainProvider}
|
|
78
|
+
* @type {import("@vcmap/cesium").CesiumTerrainProvider|undefined}
|
|
79
79
|
* @api
|
|
80
80
|
*/
|
|
81
81
|
this.terrainProvider = options.terrainProvider;
|
|
@@ -7,6 +7,7 @@ import { transformFromImage } from './helpers.js';
|
|
|
7
7
|
import { getHeightFromTerrainProvider } from '../layer/terrainHelpers.js';
|
|
8
8
|
import { mercatorProjection } from '../util/projection.js';
|
|
9
9
|
import VcsEvent from '../event/vcsEvent.js';
|
|
10
|
+
import { isDefaultImageSymbol } from './defaultObliqueCollection.js';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* @typedef {Object} ObliqueViewPoint
|
|
@@ -293,7 +294,7 @@ class ObliqueProvider {
|
|
|
293
294
|
const previousView = this._currentView;
|
|
294
295
|
this._currentView = olView;
|
|
295
296
|
if (isNewImage) {
|
|
296
|
-
this._currentView.setImageName(this._currentImage.name);
|
|
297
|
+
this._currentView.setImageName(this._currentImage.name, this._currentImage[isDefaultImageSymbol]);
|
|
297
298
|
}
|
|
298
299
|
|
|
299
300
|
const [width, height] = this._currentImage.meta.size;
|
|
@@ -6,6 +6,29 @@ import TileImage from 'ol/source/TileImage.js';
|
|
|
6
6
|
import Tile from 'ol/layer/Tile.js';
|
|
7
7
|
import { hasSameOrigin } from './helpers.js';
|
|
8
8
|
|
|
9
|
+
/** @type {string} */
|
|
10
|
+
let defaultImage = '';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @returns {string}
|
|
14
|
+
*/
|
|
15
|
+
function getDefaultImage() {
|
|
16
|
+
if (!defaultImage) {
|
|
17
|
+
const canvas = document.createElement('canvas');
|
|
18
|
+
canvas.height = 512;
|
|
19
|
+
canvas.width = 512;
|
|
20
|
+
const context = canvas.getContext('2d');
|
|
21
|
+
context.fillStyle = '#409D76';
|
|
22
|
+
context.fillRect(0, 0, 512, 512);
|
|
23
|
+
context.font = 'bold 46px Monospace, Courier New';
|
|
24
|
+
context.fillStyle = '#424242';
|
|
25
|
+
context.textAlign = 'center';
|
|
26
|
+
context.fillText('No Image', 256, 256);
|
|
27
|
+
defaultImage = canvas.toDataURL('png');
|
|
28
|
+
}
|
|
29
|
+
return defaultImage;
|
|
30
|
+
}
|
|
31
|
+
|
|
9
32
|
/**
|
|
10
33
|
* @typedef {Object} ObliqueViewOptions
|
|
11
34
|
* @property {number} minZoom
|
|
@@ -108,9 +131,16 @@ class ObliqueView {
|
|
|
108
131
|
/**
|
|
109
132
|
* Sets the layers source to request data for this image
|
|
110
133
|
* @param {string} name
|
|
134
|
+
* @param {boolean} [isDefaultImage=false]
|
|
111
135
|
* @api
|
|
112
136
|
*/
|
|
113
|
-
setImageName(name) {
|
|
137
|
+
setImageName(name, isDefaultImage = false) {
|
|
138
|
+
if (isDefaultImage) {
|
|
139
|
+
this.tileImageSource.setTileLoadFunction(/** @param {import("ol").ImageTile} tile */ (tile) => {
|
|
140
|
+
/** @type {HTMLImageElement} */ (tile.getImage()).src = getDefaultImage();
|
|
141
|
+
tile.load();
|
|
142
|
+
});
|
|
143
|
+
}
|
|
114
144
|
this.tileImageSource.setTileUrlFunction((coords) => {
|
|
115
145
|
const [z, x, yInverted] = coords;
|
|
116
146
|
const y = -yInverted - 1;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import ObliqueCollection from './ObliqueCollection.js';
|
|
2
|
+
import ObliqueImage from './ObliqueImage.js';
|
|
3
|
+
import ObliqueImageMeta from './ObliqueImageMeta.js';
|
|
4
|
+
import { ObliqueViewDirection } from './ObliqueViewDirection.js';
|
|
5
|
+
import { mercatorProjection } from '../util/projection.js';
|
|
6
|
+
|
|
7
|
+
const defaultMeta = new ObliqueImageMeta({
|
|
8
|
+
name: 'defaultObliqueMeta',
|
|
9
|
+
size: [512, 512],
|
|
10
|
+
tileSize: [512, 512],
|
|
11
|
+
tileResolution: [1],
|
|
12
|
+
projection: mercatorProjection,
|
|
13
|
+
format: 'png',
|
|
14
|
+
url: '',
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @type {symbol}
|
|
19
|
+
* @private
|
|
20
|
+
*/
|
|
21
|
+
export const isDefaultImageSymbol = Symbol('isDefaultImage');
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* This is a special oblique collection wich is shown, if no other oblique collection is set on an Oblique map.
|
|
25
|
+
* It will render a single image which indicates that no images can be loaded.
|
|
26
|
+
* @class
|
|
27
|
+
* @extends {ObliqueCollection}
|
|
28
|
+
*/
|
|
29
|
+
class DefaultObliqueCollection extends ObliqueCollection {
|
|
30
|
+
constructor() {
|
|
31
|
+
super({});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @param {import("ol/coordinate").Coordinate} mercatorCoordinate
|
|
36
|
+
* @param {ObliqueViewDirection} viewDirection
|
|
37
|
+
* @returns {ObliqueImage}
|
|
38
|
+
*/
|
|
39
|
+
// eslint-disable-next-line no-unused-vars
|
|
40
|
+
getImageForCoordinate(mercatorCoordinate, viewDirection) {
|
|
41
|
+
const groundCoordinates = [
|
|
42
|
+
[mercatorCoordinate[0] - 100, mercatorCoordinate[1] - 100, 0],
|
|
43
|
+
[mercatorCoordinate[0] + 100, mercatorCoordinate[1] - 100, 0],
|
|
44
|
+
[mercatorCoordinate[0] + 100, mercatorCoordinate[1] + 100, 0],
|
|
45
|
+
[mercatorCoordinate[0] - 100, mercatorCoordinate[1] + 100, 0],
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
const image = new ObliqueImage({
|
|
49
|
+
meta: defaultMeta,
|
|
50
|
+
viewDirection: ObliqueViewDirection.NORTH,
|
|
51
|
+
viewDirectionAngle: 0,
|
|
52
|
+
name: this.name,
|
|
53
|
+
groundCoordinates,
|
|
54
|
+
centerPointOnGround: mercatorCoordinate,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
image[isDefaultImageSymbol] = true;
|
|
58
|
+
return image;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export default DefaultObliqueCollection;
|
package/src/vcs/vcm/vcsApp.js
CHANGED
|
@@ -23,6 +23,7 @@ import StyleItem from './util/style/styleItem.js';
|
|
|
23
23
|
import IndexedCollection from './util/indexedCollection.js';
|
|
24
24
|
import VcsEvent from './event/vcsEvent.js';
|
|
25
25
|
import { setDefaultProjectionOptions } from './util/projection.js';
|
|
26
|
+
import Oblique from './maps/oblique.js';
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* @returns {import("@vcsuite/logger").Logger}
|
|
@@ -91,7 +92,7 @@ class VcsApp {
|
|
|
91
92
|
new Collection(),
|
|
92
93
|
getDynamicContextId,
|
|
93
94
|
null,
|
|
94
|
-
|
|
95
|
+
config => new ObliqueCollection(config),
|
|
95
96
|
ObliqueCollection,
|
|
96
97
|
); // XXX there is a global for this collection in core.
|
|
97
98
|
/**
|
|
@@ -258,6 +259,15 @@ class VcsApp {
|
|
|
258
259
|
}
|
|
259
260
|
});
|
|
260
261
|
|
|
262
|
+
const activeObliqueCollection = [...this._obliqueCollections]
|
|
263
|
+
.find(c => c[contextIdSymbol] === context.id && c.activeOnStartup);
|
|
264
|
+
|
|
265
|
+
if (activeObliqueCollection) {
|
|
266
|
+
[...this._maps]
|
|
267
|
+
.filter(m => m instanceof Oblique)
|
|
268
|
+
.forEach((m) => { /** @type {Oblique} */ (m).setCollection(activeObliqueCollection); });
|
|
269
|
+
}
|
|
270
|
+
|
|
261
271
|
if (config.startingMapName) {
|
|
262
272
|
await this._maps.setActiveMap(config.startingMapName);
|
|
263
273
|
} else if (!this._maps.activeMap && this._maps.size > 0) {
|
|
@@ -327,6 +337,9 @@ class VcsApp {
|
|
|
327
337
|
return this._contextMutationPromise;
|
|
328
338
|
}
|
|
329
339
|
|
|
340
|
+
/**
|
|
341
|
+
* Destroys the app and all its collections, their content and ui managers.
|
|
342
|
+
*/
|
|
330
343
|
destroy() {
|
|
331
344
|
Object.defineProperty(this, '_contextMutationPromise', {
|
|
332
345
|
get() {
|