@vcmap/core 6.3.0-rc.1 → 6.3.0-rc.2
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/dist/cesium.d.ts +12 -0
- package/dist/index.d.ts +10 -2
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/dist/ol.d.ts +13 -2
- package/dist/src/cesium/cesium3DTileFeature.d.ts +1 -0
- package/dist/src/cesium/cesium3DTileFeature.js +16 -3
- package/dist/src/cesium/cesium3DTileFeature.js.map +1 -1
- package/dist/src/cesium/cesium3DTilePointFeature.js +2 -1
- package/dist/src/cesium/cesium3DTilePointFeature.js.map +1 -1
- package/dist/src/classRegistry.d.ts +7 -1
- package/dist/src/classRegistry.js.map +1 -1
- package/dist/src/featureProvider/abstractAttributeProvider.d.ts +62 -0
- package/dist/src/featureProvider/abstractAttributeProvider.js +129 -0
- package/dist/src/featureProvider/abstractAttributeProvider.js.map +1 -0
- package/dist/src/featureProvider/abstractFeatureProvider.d.ts +9 -18
- package/dist/src/featureProvider/abstractFeatureProvider.js +7 -38
- package/dist/src/featureProvider/abstractFeatureProvider.js.map +1 -1
- package/dist/src/featureProvider/compositeFeatureProvider.d.ts +27 -0
- package/dist/src/featureProvider/compositeFeatureProvider.js +53 -0
- package/dist/src/featureProvider/compositeFeatureProvider.js.map +1 -0
- package/dist/src/featureProvider/csvAttributeProvider.d.ts +41 -0
- package/dist/src/featureProvider/csvAttributeProvider.js +126 -0
- package/dist/src/featureProvider/csvAttributeProvider.js.map +1 -0
- package/dist/src/featureProvider/featureProviderFactory.d.ts +3 -0
- package/dist/src/featureProvider/featureProviderFactory.js +17 -0
- package/dist/src/featureProvider/featureProviderFactory.js.map +1 -0
- package/dist/src/featureProvider/i3sAttributeProvider.d.ts +7 -0
- package/dist/src/featureProvider/i3sAttributeProvider.js +43 -0
- package/dist/src/featureProvider/i3sAttributeProvider.js.map +1 -0
- package/dist/src/featureProvider/jsonAttributeProvider.d.ts +26 -0
- package/dist/src/featureProvider/jsonAttributeProvider.js +73 -0
- package/dist/src/featureProvider/jsonAttributeProvider.js.map +1 -0
- package/dist/src/featureProvider/tileProviderFeatureProvider.d.ts +4 -6
- package/dist/src/featureProvider/tileProviderFeatureProvider.js +9 -11
- package/dist/src/featureProvider/tileProviderFeatureProvider.js.map +1 -1
- package/dist/src/featureProvider/urlIdAttributeProvider.d.ts +28 -0
- package/dist/src/featureProvider/urlIdAttributeProvider.js +50 -0
- package/dist/src/featureProvider/urlIdAttributeProvider.js.map +1 -0
- package/dist/src/featureProvider/wmsFeatureProvider.d.ts +12 -3
- package/dist/src/featureProvider/wmsFeatureProvider.js +17 -6
- package/dist/src/featureProvider/wmsFeatureProvider.js.map +1 -1
- package/dist/src/interaction/featureAtPixelInteraction.d.ts +15 -3
- package/dist/src/interaction/featureAtPixelInteraction.js +41 -1
- package/dist/src/interaction/featureAtPixelInteraction.js.map +1 -1
- package/dist/src/interaction/featureProviderInteraction.js +42 -26
- package/dist/src/interaction/featureProviderInteraction.js.map +1 -1
- package/dist/src/layer/cesium/cesiumTilesetCesiumImpl.d.ts +14 -5
- package/dist/src/layer/cesium/cesiumTilesetCesiumImpl.js +243 -128
- package/dist/src/layer/cesium/cesiumTilesetCesiumImpl.js.map +1 -1
- package/dist/src/layer/cesium/i3sCesiumImpl.d.ts +33 -0
- package/dist/src/layer/cesium/i3sCesiumImpl.js +107 -0
- package/dist/src/layer/cesium/i3sCesiumImpl.js.map +1 -0
- package/dist/src/layer/cesium/vcsTile/vcsQuadtreeTileProvider.js +2 -1
- package/dist/src/layer/cesium/vcsTile/vcsQuadtreeTileProvider.js.map +1 -1
- package/dist/src/layer/cesium/vectorRasterTileCesiumImpl.js +7 -6
- package/dist/src/layer/cesium/vectorRasterTileCesiumImpl.js.map +1 -1
- package/dist/src/layer/cesium/vectorTileImageryProvider.js +2 -2
- package/dist/src/layer/cesium/vectorTileImageryProvider.js.map +1 -1
- package/dist/src/layer/cesiumTilesetLayer.d.ts +9 -0
- package/dist/src/layer/cesiumTilesetLayer.js +26 -1
- package/dist/src/layer/cesiumTilesetLayer.js.map +1 -1
- package/dist/src/layer/i3sLayer.d.ts +80 -0
- package/dist/src/layer/i3sLayer.js +242 -0
- package/dist/src/layer/i3sLayer.js.map +1 -0
- package/dist/src/layer/layer.d.ts +8 -3
- package/dist/src/layer/layer.js +7 -1
- package/dist/src/layer/layer.js.map +1 -1
- package/dist/src/layer/layerSymbols.d.ts +4 -0
- package/dist/src/layer/layerSymbols.js +4 -0
- package/dist/src/layer/layerSymbols.js.map +1 -1
- package/dist/src/layer/panoramaDatasetLayer.d.ts +2 -0
- package/dist/src/layer/panoramaDatasetLayer.js +33 -13
- package/dist/src/layer/panoramaDatasetLayer.js.map +1 -1
- package/dist/src/layer/tileProvider/flatGeobufTileProvider.js +3 -2
- package/dist/src/layer/tileProvider/flatGeobufTileProvider.js.map +1 -1
- package/dist/src/layer/tileProvider/mvtTileProvider.js +3 -2
- package/dist/src/layer/tileProvider/mvtTileProvider.js.map +1 -1
- package/dist/src/layer/tileProvider/tileProvider.d.ts +6 -0
- package/dist/src/layer/tileProvider/tileProvider.js +12 -1
- package/dist/src/layer/tileProvider/tileProvider.js.map +1 -1
- package/dist/src/layer/vectorLayer.js +2 -2
- package/dist/src/layer/vectorLayer.js.map +1 -1
- package/dist/src/layer/vectorProperties.js +10 -1
- package/dist/src/layer/vectorProperties.js.map +1 -1
- package/dist/src/layer/vectorTileLayer.d.ts +14 -5
- package/dist/src/layer/vectorTileLayer.js +78 -26
- package/dist/src/layer/vectorTileLayer.js.map +1 -1
- package/dist/src/layer/wmsLayer.d.ts +3 -0
- package/dist/src/layer/wmsLayer.js +62 -32
- package/dist/src/layer/wmsLayer.js.map +1 -1
- package/dist/src/map/baseCesiumMap.d.ts +4 -4
- package/dist/src/map/baseCesiumMap.js +12 -0
- package/dist/src/map/baseCesiumMap.js.map +1 -1
- package/dist/src/map/cesiumMap.js +0 -11
- package/dist/src/map/cesiumMap.js.map +1 -1
- package/dist/src/map/obliqueMap.js +11 -4
- package/dist/src/map/obliqueMap.js.map +1 -1
- package/dist/src/map/panoramaMap.js +1 -1
- package/dist/src/panorama/panoramaImage.js +6 -5
- package/dist/src/panorama/panoramaImage.js.map +1 -1
- package/dist/src/style/declarativeStyleItem.js +7 -8
- package/dist/src/style/declarativeStyleItem.js.map +1 -1
- package/dist/src/util/fetch.d.ts +7 -0
- package/dist/src/util/fetch.js +7 -0
- package/dist/src/util/fetch.js.map +1 -1
- package/dist/src/vcsApp.d.ts +2 -3
- package/dist/src/vcsApp.js.map +1 -1
- package/dist/src/vcsModuleHelpers.d.ts +5 -2
- package/dist/src/vcsModuleHelpers.js +27 -1
- package/dist/src/vcsModuleHelpers.js.map +1 -1
- package/dist/tests/unit/helpers/cesiumHelpers.js +7 -1
- package/dist/tests/unit/helpers/cesiumHelpers.js.map +1 -1
- package/index.ts +27 -0
- package/package.json +2 -2
- package/src/cesium/cesium.d.ts +12 -0
- package/src/cesium/cesium3DTileFeature.ts +25 -3
- package/src/cesium/cesium3DTilePointFeature.ts +3 -1
- package/src/classRegistry.ts +8 -3
- package/src/featureProvider/abstractAttributeProvider.ts +201 -0
- package/src/featureProvider/abstractFeatureProvider.ts +27 -47
- package/src/featureProvider/compositeFeatureProvider.ts +103 -0
- package/src/featureProvider/csvAttributeProvider.ts +186 -0
- package/src/featureProvider/featureProviderFactory.ts +31 -0
- package/src/featureProvider/i3sAttributeProvider.ts +60 -0
- package/src/featureProvider/jsonAttributeProvider.ts +109 -0
- package/src/featureProvider/tileProviderFeatureProvider.ts +13 -14
- package/src/featureProvider/urlIdAttributeProvider.ts +82 -0
- package/src/featureProvider/wmsFeatureProvider.ts +24 -7
- package/src/global.d.ts +2 -0
- package/src/interaction/featureAtPixelInteraction.ts +53 -3
- package/src/interaction/featureProviderInteraction.ts +59 -38
- package/src/layer/cesium/cesiumTilesetCesiumImpl.ts +296 -157
- package/src/layer/cesium/i3sCesiumImpl.ts +141 -0
- package/src/layer/cesium/vcsTile/vcsQuadtreeTileProvider.ts +4 -3
- package/src/layer/cesium/vectorRasterTileCesiumImpl.ts +7 -6
- package/src/layer/cesium/vectorTileImageryProvider.ts +2 -2
- package/src/layer/cesiumTilesetLayer.ts +51 -1
- package/src/layer/i3sLayer.ts +343 -0
- package/src/layer/layer.ts +30 -3
- package/src/layer/layerSymbols.ts +5 -0
- package/src/layer/panoramaDatasetLayer.ts +44 -13
- package/src/layer/tileProvider/flatGeobufTileProvider.ts +3 -2
- package/src/layer/tileProvider/mvtTileProvider.ts +3 -2
- package/src/layer/tileProvider/tileProvider.ts +13 -1
- package/src/layer/vectorLayer.ts +4 -2
- package/src/layer/vectorProperties.ts +10 -1
- package/src/layer/vectorTileLayer.ts +135 -47
- package/src/layer/wmsLayer.ts +77 -44
- package/src/map/baseCesiumMap.ts +29 -5
- package/src/map/cesiumMap.ts +0 -15
- package/src/map/obliqueMap.ts +13 -6
- package/src/map/panoramaMap.ts +1 -1
- package/src/ol/ol.d.ts +13 -2
- package/src/panorama/panoramaImage.ts +8 -5
- package/src/style/declarativeStyleItem.ts +7 -9
- package/src/util/fetch.ts +7 -0
- package/src/vcsApp.ts +7 -8
- package/src/vcsModuleHelpers.ts +62 -4
|
@@ -3,8 +3,8 @@ import type { Feature } from 'ol/index.js';
|
|
|
3
3
|
import AbstractFeatureProvider, {
|
|
4
4
|
type AbstractFeatureProviderOptions,
|
|
5
5
|
} from './abstractFeatureProvider.js';
|
|
6
|
-
import { featureProviderClassRegistry } from '../classRegistry.js';
|
|
7
6
|
import type TileProvider from '../layer/tileProvider/tileProvider.js';
|
|
7
|
+
import type Layer from '../layer/layer.js';
|
|
8
8
|
|
|
9
9
|
export type TileProviderFeatureProviderOptions =
|
|
10
10
|
AbstractFeatureProviderOptions & {
|
|
@@ -18,26 +18,21 @@ class TileProviderFeatureProvider extends AbstractFeatureProvider {
|
|
|
18
18
|
|
|
19
19
|
tileProvider: TileProvider;
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
* @param options
|
|
24
|
-
*/
|
|
25
|
-
constructor(layerName: string, options: TileProviderFeatureProviderOptions) {
|
|
26
|
-
super(layerName, options);
|
|
21
|
+
constructor(options: TileProviderFeatureProviderOptions) {
|
|
22
|
+
super({ ...options, mapTypes: ['CesiumMap'] });
|
|
27
23
|
|
|
28
|
-
this.mapTypes = ['CesiumMap'];
|
|
29
24
|
this.tileProvider = options.tileProvider;
|
|
30
25
|
}
|
|
31
26
|
|
|
32
27
|
async getFeaturesByCoordinate(
|
|
33
28
|
coordinate: Coordinate,
|
|
34
29
|
resolution: number,
|
|
35
|
-
|
|
30
|
+
layer: Layer,
|
|
36
31
|
): Promise<Feature[]> {
|
|
37
32
|
const features = await this.tileProvider.getFeaturesByCoordinate(
|
|
38
33
|
coordinate,
|
|
39
34
|
resolution,
|
|
40
|
-
headers,
|
|
35
|
+
layer.headers,
|
|
41
36
|
);
|
|
42
37
|
const checkShow = (feature: Feature): boolean =>
|
|
43
38
|
this.style ? !!this.style.cesiumStyle.show.evaluate(feature) : true;
|
|
@@ -48,6 +43,14 @@ class TileProviderFeatureProvider extends AbstractFeatureProvider {
|
|
|
48
43
|
});
|
|
49
44
|
}
|
|
50
45
|
|
|
46
|
+
toJSON(
|
|
47
|
+
defaultOptions: AbstractFeatureProviderOptions = AbstractFeatureProvider.getDefaultOptions(),
|
|
48
|
+
): AbstractFeatureProviderOptions {
|
|
49
|
+
const options = super.toJSON(defaultOptions);
|
|
50
|
+
delete options.mapTypes;
|
|
51
|
+
return options;
|
|
52
|
+
}
|
|
53
|
+
|
|
51
54
|
destroy(): void {
|
|
52
55
|
this.tileProvider.destroy();
|
|
53
56
|
super.destroy();
|
|
@@ -55,7 +58,3 @@ class TileProviderFeatureProvider extends AbstractFeatureProvider {
|
|
|
55
58
|
}
|
|
56
59
|
|
|
57
60
|
export default TileProviderFeatureProvider;
|
|
58
|
-
featureProviderClassRegistry.registerClass(
|
|
59
|
-
TileProviderFeatureProvider.className,
|
|
60
|
-
TileProviderFeatureProvider,
|
|
61
|
-
);
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import AbstractAttributeProvider from './abstractAttributeProvider.js';
|
|
2
|
+
import type { VcsObjectOptions } from '../vcsObject.js';
|
|
3
|
+
import { getInitForUrl, requestJson } from '../util/fetch.js';
|
|
4
|
+
import { featureProviderClassRegistry } from '../classRegistry.js';
|
|
5
|
+
|
|
6
|
+
export type UrlIdAttributeProviderOptions = VcsObjectOptions & {
|
|
7
|
+
urlTemplate: string;
|
|
8
|
+
headers?: Record<string, string>;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Provides attributes for features by fetching data from a URL based on feature IDs.
|
|
13
|
+
* The URL template should contain a {id} placeholder that will be replaced with the encoded feature ID.
|
|
14
|
+
* urlTemplate: 'https://api.example.com/features/{id}'
|
|
15
|
+
* For a feature with ID "123", this would request: https://api.example.com/features/123
|
|
16
|
+
*
|
|
17
|
+
* The backend should return a JSON object with attribute key-value pairs.
|
|
18
|
+
* {
|
|
19
|
+
* "name": "Feature Name",
|
|
20
|
+
* "description": "Feature description",
|
|
21
|
+
* "value": 42
|
|
22
|
+
* }
|
|
23
|
+
* If the request fails or returns invalid data, the provider returns undefined.
|
|
24
|
+
*/
|
|
25
|
+
export default class UrlIdAttributeProvider extends AbstractAttributeProvider {
|
|
26
|
+
static get className(): string {
|
|
27
|
+
return 'UrlIdAttributeProvider';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private _urlTemplate: string;
|
|
31
|
+
|
|
32
|
+
private _headers?: Record<string, string> | undefined;
|
|
33
|
+
|
|
34
|
+
constructor(options: UrlIdAttributeProviderOptions) {
|
|
35
|
+
super(options);
|
|
36
|
+
|
|
37
|
+
this._urlTemplate = options.urlTemplate;
|
|
38
|
+
|
|
39
|
+
this._headers = options.headers
|
|
40
|
+
? structuredClone(options.headers)
|
|
41
|
+
: undefined;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
protected async _getAttributes(
|
|
45
|
+
id: string,
|
|
46
|
+
): Promise<Record<string, unknown> | undefined> {
|
|
47
|
+
const url = this._urlTemplate.replace(
|
|
48
|
+
'{id}',
|
|
49
|
+
encodeURIComponent(String(id)),
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
return await requestJson<Record<string, unknown>>(
|
|
54
|
+
url,
|
|
55
|
+
getInitForUrl(url, this._headers),
|
|
56
|
+
);
|
|
57
|
+
} catch {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
override toJSON(
|
|
63
|
+
_defaultOptions?: UrlIdAttributeProviderOptions,
|
|
64
|
+
): UrlIdAttributeProviderOptions {
|
|
65
|
+
const config: Partial<UrlIdAttributeProviderOptions> = super.toJSON(
|
|
66
|
+
_defaultOptions,
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
config.urlTemplate = this._urlTemplate;
|
|
70
|
+
|
|
71
|
+
if (this._headers) {
|
|
72
|
+
config.headers = structuredClone(this._headers);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return config as UrlIdAttributeProviderOptions;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
featureProviderClassRegistry.registerClass(
|
|
80
|
+
UrlIdAttributeProvider.className,
|
|
81
|
+
UrlIdAttributeProvider,
|
|
82
|
+
);
|
|
@@ -16,7 +16,7 @@ import type { Options as WMSGetFeatureInfoOptions } from 'ol/format/WMSGetFeatur
|
|
|
16
16
|
import { containsCoordinate } from 'ol/extent.js';
|
|
17
17
|
import { parseInteger } from '@vcsuite/parsers';
|
|
18
18
|
import { getLogger } from '@vcsuite/logger';
|
|
19
|
-
import type
|
|
19
|
+
import { type AbstractFeatureProviderOptions } from './abstractFeatureProvider.js';
|
|
20
20
|
import AbstractFeatureProvider from './abstractFeatureProvider.js';
|
|
21
21
|
import type { ProjectionOptions } from '../util/projection.js';
|
|
22
22
|
import Projection, { mercatorProjection } from '../util/projection.js';
|
|
@@ -27,6 +27,7 @@ import Extent from '../util/extent.js';
|
|
|
27
27
|
import { getInitForUrl, requestUrl } from '../util/fetch.js';
|
|
28
28
|
import { featureProviderClassRegistry } from '../classRegistry.js';
|
|
29
29
|
import { TilingScheme } from '../layer/rasterLayer.js';
|
|
30
|
+
import type Layer from '../layer/layer.js';
|
|
30
31
|
|
|
31
32
|
export type FormatOptions = GeoJSONOptions &
|
|
32
33
|
GMLOptions &
|
|
@@ -78,6 +79,10 @@ export type WMSFeatureProviderOptions = AbstractFeatureProviderOptions & {
|
|
|
78
79
|
*/
|
|
79
80
|
version?: string;
|
|
80
81
|
htmlPositionFeatureTitle?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Optional headers to include in GetFeatureInfo requests. Overrides layer headers.
|
|
84
|
+
*/
|
|
85
|
+
headers?: Record<string, string>;
|
|
81
86
|
};
|
|
82
87
|
|
|
83
88
|
const gmlFormats = { GML: GML3, GML2, GML3, GML32 };
|
|
@@ -191,6 +196,7 @@ class WMSFeatureProvider extends AbstractFeatureProvider {
|
|
|
191
196
|
tileSize: [256, 256],
|
|
192
197
|
parameters: {},
|
|
193
198
|
extent: undefined,
|
|
199
|
+
headers: undefined,
|
|
194
200
|
};
|
|
195
201
|
}
|
|
196
202
|
|
|
@@ -233,9 +239,14 @@ class WMSFeatureProvider extends AbstractFeatureProvider {
|
|
|
233
239
|
|
|
234
240
|
htmlPositionFeatureTitle?: string;
|
|
235
241
|
|
|
236
|
-
|
|
242
|
+
/**
|
|
243
|
+
* Optional headers to include in GetFeatureInfo requests.
|
|
244
|
+
*/
|
|
245
|
+
headers?: Record<string, string>;
|
|
246
|
+
|
|
247
|
+
constructor(options: WMSFeatureProviderOptions) {
|
|
237
248
|
const defaultOptions = WMSFeatureProvider.getDefaultOptions();
|
|
238
|
-
super(
|
|
249
|
+
super({ ...defaultOptions, ...options });
|
|
239
250
|
|
|
240
251
|
if (options.extent) {
|
|
241
252
|
if (options.extent instanceof Extent) {
|
|
@@ -271,6 +282,9 @@ class WMSFeatureProvider extends AbstractFeatureProvider {
|
|
|
271
282
|
? new Projection(options.projection)
|
|
272
283
|
: undefined;
|
|
273
284
|
this.htmlPositionFeatureTitle = options.htmlPositionFeatureTitle;
|
|
285
|
+
this.headers = options.headers
|
|
286
|
+
? structuredClone(options.headers)
|
|
287
|
+
: undefined;
|
|
274
288
|
}
|
|
275
289
|
|
|
276
290
|
get wmsSource(): TileWMS {
|
|
@@ -324,7 +338,7 @@ class WMSFeatureProvider extends AbstractFeatureProvider {
|
|
|
324
338
|
async getFeaturesByCoordinate(
|
|
325
339
|
coordinate: Coordinate,
|
|
326
340
|
resolution: number,
|
|
327
|
-
|
|
341
|
+
layer: Layer,
|
|
328
342
|
): Promise<Feature[]> {
|
|
329
343
|
if (
|
|
330
344
|
this.extent?.isValid() &&
|
|
@@ -354,10 +368,10 @@ class WMSFeatureProvider extends AbstractFeatureProvider {
|
|
|
354
368
|
|
|
355
369
|
if (this.featureInfoResponseType === 'text/html') {
|
|
356
370
|
return this.featureResponseCallback(null, coordinate).map((f) =>
|
|
357
|
-
this.getProviderFeature(f),
|
|
371
|
+
this.getProviderFeature(f, layer),
|
|
358
372
|
);
|
|
359
373
|
} else if (url) {
|
|
360
|
-
const init = getInitForUrl(url, headers);
|
|
374
|
+
const init = getInitForUrl(url, this.headers ?? layer.headers);
|
|
361
375
|
let data: string;
|
|
362
376
|
try {
|
|
363
377
|
const response = await requestUrl(url, init);
|
|
@@ -367,7 +381,7 @@ class WMSFeatureProvider extends AbstractFeatureProvider {
|
|
|
367
381
|
return [];
|
|
368
382
|
}
|
|
369
383
|
return this.featureResponseCallback(data, coordinate).map((f) =>
|
|
370
|
-
this.getProviderFeature(f),
|
|
384
|
+
this.getProviderFeature(f, layer),
|
|
371
385
|
);
|
|
372
386
|
}
|
|
373
387
|
return [];
|
|
@@ -427,6 +441,9 @@ class WMSFeatureProvider extends AbstractFeatureProvider {
|
|
|
427
441
|
if (this.htmlPositionFeatureTitle) {
|
|
428
442
|
config.htmlPositionFeatureTitle = this.htmlPositionFeatureTitle;
|
|
429
443
|
}
|
|
444
|
+
if (this.headers) {
|
|
445
|
+
config.headers = structuredClone(this.headers);
|
|
446
|
+
}
|
|
430
447
|
|
|
431
448
|
return config as WMSFeatureProviderOptions;
|
|
432
449
|
}
|
package/src/global.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ import type {
|
|
|
4
4
|
Ray,
|
|
5
5
|
Billboard,
|
|
6
6
|
Label,
|
|
7
|
+
I3SNode,
|
|
8
|
+
I3SDataProvider,
|
|
7
9
|
} from '@vcmap-cesium/engine';
|
|
8
10
|
import {
|
|
9
11
|
Cartesian3,
|
|
@@ -12,7 +14,9 @@ import {
|
|
|
12
14
|
Entity,
|
|
13
15
|
} from '@vcmap-cesium/engine';
|
|
14
16
|
import type OLMap from 'ol/Map.js';
|
|
15
|
-
import
|
|
17
|
+
import Feature from 'ol/Feature.js';
|
|
18
|
+
import { Point } from 'ol/geom.js';
|
|
19
|
+
import { v4 as uuid } from 'uuid';
|
|
16
20
|
import AbstractInteraction, {
|
|
17
21
|
type EventFeature,
|
|
18
22
|
type InteractionEvent,
|
|
@@ -22,7 +26,7 @@ import {
|
|
|
22
26
|
ModificationKeyType,
|
|
23
27
|
PointerKeyType,
|
|
24
28
|
} from './interactionType.js';
|
|
25
|
-
import { allowPicking, vcsLayerName } from '../layer/layerSymbols.js';
|
|
29
|
+
import { allowPicking, i3sData, vcsLayerName } from '../layer/layerSymbols.js';
|
|
26
30
|
import { originalFeatureSymbol, primitives } from '../layer/vectorSymbols.js';
|
|
27
31
|
import type OpenlayersMap from '../map/openlayersMap.js';
|
|
28
32
|
import type ObliqueMap from '../map/obliqueMap.js';
|
|
@@ -31,6 +35,7 @@ import { cartesian3DDistance, cartesianToMercator } from '../util/math.js';
|
|
|
31
35
|
import type { PrimitiveType } from '../util/featureconverter/convert.js';
|
|
32
36
|
import type BaseCesiumMap from '../map/baseCesiumMap.js';
|
|
33
37
|
import type PanoramaMap from '../map/panoramaMap.js';
|
|
38
|
+
import { isProvidedFeature } from '../featureProvider/featureProviderSymbols.js';
|
|
34
39
|
|
|
35
40
|
/**
|
|
36
41
|
* This is the return from cesium scene.pick and scene.drillPick, which returns "any". We cast to this type.
|
|
@@ -45,6 +50,11 @@ type CesiumPickObject = {
|
|
|
45
50
|
olFeature?: Feature;
|
|
46
51
|
[vcsLayerName]?: string;
|
|
47
52
|
};
|
|
53
|
+
content?: {
|
|
54
|
+
tile?: {
|
|
55
|
+
i3sNode: I3SNode;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
48
58
|
};
|
|
49
59
|
|
|
50
60
|
function getFeatureFromOlMap(
|
|
@@ -81,6 +91,12 @@ function getFeatureFromOlMap(
|
|
|
81
91
|
return feature;
|
|
82
92
|
}
|
|
83
93
|
|
|
94
|
+
export function isI3SFeature(f: EventFeature): f is Feature & {
|
|
95
|
+
[i3sData]: { i3sNode: I3SNode; cartesianPosition?: Cartesian3 };
|
|
96
|
+
} {
|
|
97
|
+
return !!(f != null && (f as Feature)[i3sData]);
|
|
98
|
+
}
|
|
99
|
+
|
|
84
100
|
export function getFeatureFromPickObject(
|
|
85
101
|
object: CesiumPickObject,
|
|
86
102
|
): EventFeature | undefined {
|
|
@@ -114,8 +130,24 @@ export function getFeatureFromPickObject(
|
|
|
114
130
|
) {
|
|
115
131
|
// entity
|
|
116
132
|
feature = object.id;
|
|
133
|
+
} else if (object.content?.tile?.i3sNode) {
|
|
134
|
+
// i3s feature
|
|
135
|
+
const dataProvider =
|
|
136
|
+
// @ts-expect-error eslint-disable-next-line no-underscore-dangle, @typescript-eslint/ban-ts-comment
|
|
137
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
138
|
+
object.content.tile.i3sNode._dataProvider as I3SDataProvider;
|
|
139
|
+
const layername = dataProvider[vcsLayerName];
|
|
140
|
+
if (object instanceof Cesium3DTileFeature) {
|
|
141
|
+
feature = object;
|
|
142
|
+
feature[vcsLayerName] = layername;
|
|
143
|
+
} else if (dataProvider[allowPicking] !== false) {
|
|
144
|
+
feature = new Feature({});
|
|
145
|
+
feature.setId(uuid());
|
|
146
|
+
feature[vcsLayerName] = layername;
|
|
147
|
+
feature[i3sData] = { i3sNode: object.content.tile.i3sNode };
|
|
148
|
+
feature[isProvidedFeature] = true;
|
|
149
|
+
}
|
|
117
150
|
}
|
|
118
|
-
|
|
119
151
|
return feature;
|
|
120
152
|
}
|
|
121
153
|
|
|
@@ -350,6 +382,15 @@ class FeatureAtPixelInteraction extends AbstractInteraction {
|
|
|
350
382
|
if (event.map.className === 'CesiumMap') {
|
|
351
383
|
event.position = cartesianToMercator(cartesianPosition);
|
|
352
384
|
event.positionOrPixel = event.position.slice();
|
|
385
|
+
if (
|
|
386
|
+
feature instanceof Feature &&
|
|
387
|
+
feature[isProvidedFeature] &&
|
|
388
|
+
isI3SFeature(feature)
|
|
389
|
+
) {
|
|
390
|
+
feature.setGeometry(new Point(event.position));
|
|
391
|
+
feature.set('olcs_altitudeMode', 'absolute');
|
|
392
|
+
feature[i3sData].cartesianPosition = cartesianPosition;
|
|
393
|
+
}
|
|
353
394
|
} else {
|
|
354
395
|
const currentImage = (event.map as PanoramaMap).currentPanoramaImage;
|
|
355
396
|
if (currentImage) {
|
|
@@ -363,6 +404,15 @@ class FeatureAtPixelInteraction extends AbstractInteraction {
|
|
|
363
404
|
if (currentDistance == null || newDistance < currentDistance) {
|
|
364
405
|
event.position = newPosition;
|
|
365
406
|
event.positionOrPixel = event.position.slice();
|
|
407
|
+
if (
|
|
408
|
+
feature instanceof Feature &&
|
|
409
|
+
feature[isProvidedFeature] &&
|
|
410
|
+
isI3SFeature(feature)
|
|
411
|
+
) {
|
|
412
|
+
feature.setGeometry(new Point(event.position));
|
|
413
|
+
feature.set('olcs_altitudeMode', 'absolute');
|
|
414
|
+
feature[i3sData].cartesianPosition = cartesianPosition;
|
|
415
|
+
}
|
|
366
416
|
}
|
|
367
417
|
}
|
|
368
418
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Coordinate } from 'ol/coordinate.js';
|
|
2
|
-
|
|
3
2
|
import Point from 'ol/geom/Point.js';
|
|
4
3
|
import Feature from 'ol/Feature.js';
|
|
5
4
|
import AbstractInteraction, {
|
|
5
|
+
type EventFeature,
|
|
6
6
|
type InteractionEvent,
|
|
7
7
|
} from './abstractInteraction.js';
|
|
8
8
|
import {
|
|
@@ -14,6 +14,10 @@ import {
|
|
|
14
14
|
isProvidedClusterFeature,
|
|
15
15
|
isProvidedFeature,
|
|
16
16
|
} from '../featureProvider/featureProviderSymbols.js';
|
|
17
|
+
import AbstractFeatureProvider from '../featureProvider/abstractFeatureProvider.js';
|
|
18
|
+
import { vcsLayerName } from '../layer/layerSymbols.js';
|
|
19
|
+
import CompositeFeatureProvider from '../featureProvider/compositeFeatureProvider.js';
|
|
20
|
+
import AbstractAttributeProvider from '../featureProvider/abstractAttributeProvider.js';
|
|
17
21
|
|
|
18
22
|
/**
|
|
19
23
|
* @group Interaction
|
|
@@ -27,50 +31,67 @@ class FeatureProviderInteraction extends AbstractInteraction {
|
|
|
27
31
|
|
|
28
32
|
// eslint-disable-next-line class-methods-use-this
|
|
29
33
|
async pipe(event: InteractionEvent): Promise<InteractionEvent> {
|
|
30
|
-
if (event.feature) {
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
if (!event.feature) {
|
|
35
|
+
const layersWithProvider = [...event.map.layerCollection]
|
|
36
|
+
.filter((l) => {
|
|
37
|
+
return (
|
|
38
|
+
l.featureProvider instanceof AbstractFeatureProvider &&
|
|
39
|
+
l.active &&
|
|
40
|
+
l.isSupported(event.map) &&
|
|
41
|
+
l.featureProvider.isSupported(event.map)
|
|
42
|
+
);
|
|
43
|
+
})
|
|
44
|
+
.reverse();
|
|
33
45
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
l.featureProvider &&
|
|
38
|
-
l.active &&
|
|
39
|
-
l.isSupported(event.map) &&
|
|
40
|
-
l.featureProvider.isSupported(event.map)
|
|
46
|
+
if (layersWithProvider.length > 0) {
|
|
47
|
+
const resolution = event.map.getCurrentResolution(
|
|
48
|
+
event.position as Coordinate,
|
|
41
49
|
);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
l.featureProvider?.getFeaturesByCoordinate?.(
|
|
54
|
-
event.position as Coordinate,
|
|
55
|
-
resolution,
|
|
56
|
-
l.headers,
|
|
50
|
+
// TODO make sure the layers are rendered, check min/max RenderingResolution
|
|
51
|
+
const features = (
|
|
52
|
+
await Promise.all(
|
|
53
|
+
layersWithProvider.map((l) =>
|
|
54
|
+
(
|
|
55
|
+
l.featureProvider as AbstractFeatureProvider
|
|
56
|
+
).getFeaturesByCoordinate?.(
|
|
57
|
+
event.position as Coordinate,
|
|
58
|
+
resolution,
|
|
59
|
+
l,
|
|
60
|
+
),
|
|
57
61
|
),
|
|
58
|
-
)
|
|
62
|
+
)
|
|
59
63
|
)
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
.filter((f) => !!f)
|
|
65
|
+
.flat();
|
|
66
|
+
if (features.length === 1) {
|
|
67
|
+
event.feature = features[0];
|
|
68
|
+
} else if (features.length > 1) {
|
|
69
|
+
const feature = new Feature({ features });
|
|
70
|
+
feature[isProvidedFeature] = true; // backward compatibility, may remove in future
|
|
71
|
+
feature[isProvidedClusterFeature] = true;
|
|
72
|
+
feature.setGeometry(new Point(event.position as Coordinate));
|
|
73
|
+
event.feature = feature;
|
|
74
|
+
}
|
|
71
75
|
}
|
|
72
76
|
}
|
|
73
77
|
|
|
78
|
+
if (event.feature) {
|
|
79
|
+
const features = (event.feature as Feature)[isProvidedClusterFeature]
|
|
80
|
+
? ((event.feature as Feature).get('features') as EventFeature[])
|
|
81
|
+
: [event.feature];
|
|
82
|
+
|
|
83
|
+
const promises = features.map(async (feature) => {
|
|
84
|
+
const layer = event.map.layerCollection.getByKey(feature[vcsLayerName]);
|
|
85
|
+
if (
|
|
86
|
+
layer?.featureProvider instanceof AbstractAttributeProvider ||
|
|
87
|
+
layer?.featureProvider instanceof CompositeFeatureProvider
|
|
88
|
+
) {
|
|
89
|
+
await layer.featureProvider.augmentFeature(feature);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
await Promise.all(promises);
|
|
93
|
+
}
|
|
94
|
+
|
|
74
95
|
return event;
|
|
75
96
|
}
|
|
76
97
|
}
|