@vcmap/core 5.0.0-rc.4 → 5.0.0-rc.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.
- package/index.d.ts +222 -65
- package/index.js +9 -1
- package/package.json +5 -10
- package/src/vcs/vcm/category/appBackedCategory.js +41 -0
- package/src/vcs/vcm/category/category.js +374 -0
- package/src/vcs/vcm/category/categoryCollection.js +145 -0
- package/src/vcs/vcm/context.js +73 -0
- package/src/vcs/vcm/layer/featureStore.js +2 -2
- package/src/vcs/vcm/layer/featureStoreChanges.js +89 -73
- package/src/vcs/vcm/layer/geojson.js +3 -5
- package/src/vcs/vcm/layer/geojsonHelpers.js +3 -3
- package/src/vcs/vcm/layer/tileProvider/mvtTileProvider.js +3 -3
- package/src/vcs/vcm/layer/tileProvider/staticGeojsonTileProvider.js +3 -3
- package/src/vcs/vcm/layer/tileProvider/urlTemplateTileProvider.js +3 -3
- package/src/vcs/vcm/layer/vectorHelpers.js +4 -4
- package/src/vcs/vcm/layer/wfs.js +5 -5
- package/src/vcs/vcm/oblique/ObliqueDataSet.js +7 -7
- package/src/vcs/vcm/util/clipping/clippingPlaneHelper.js +4 -4
- package/src/vcs/vcm/util/featureProvider/featureProviderHelpers.js +3 -4
- package/src/vcs/vcm/util/featureProvider/wmsFeatureProvider.js +11 -6
- package/src/vcs/vcm/util/featureconverter/extent3D.js +181 -0
- package/src/vcs/vcm/util/fetch.js +32 -0
- package/src/vcs/vcm/util/overrideCollection.js +224 -0
- package/src/vcs/vcm/util/style/declarativeStyleItem.js +2 -0
- package/src/vcs/vcm/util/style/styleFactory.js +1 -1
- package/src/vcs/vcm/util/style/styleItem.js +2 -0
- package/src/vcs/vcm/util/style/vectorStyleItem.js +2 -0
- package/src/vcs/vcm/vcsApp.js +360 -0
- package/src/vcs/vcm/vcsAppContextHelpers.js +108 -0
- package/src/vcs/vcm/util/featureconverter/extent3d.js +0 -154
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { getLogger as getLoggerByName } from '@vcsuite/logger';
|
|
2
|
+
import { VcsClassRegistry } from './classRegistry.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @returns {import("@vcsuite/logger").Logger}
|
|
6
|
+
*/
|
|
7
|
+
function getLogger() {
|
|
8
|
+
return getLoggerByName('init');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @type {symbol}
|
|
13
|
+
*/
|
|
14
|
+
export const contextIdSymbol = Symbol('contextId');
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* returns a constructor of a type.
|
|
18
|
+
* @api stable
|
|
19
|
+
* @export
|
|
20
|
+
* @param {Object} options
|
|
21
|
+
* @param {...*} args
|
|
22
|
+
* @returns {Promise<Object|null>}
|
|
23
|
+
*/
|
|
24
|
+
export async function getObjectFromOptions(options, ...args) {
|
|
25
|
+
if (!options.type) {
|
|
26
|
+
getLogger().warning(`ObjectCreation failed: could not find type in options ${options}`);
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
const ObjectConstructor = await VcsClassRegistry.getClass(options.type);
|
|
30
|
+
if (!ObjectConstructor) {
|
|
31
|
+
getLogger().warning(`ObjectCreation failed: could not find javascript class of type ${options.type}`);
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
let object;
|
|
35
|
+
try {
|
|
36
|
+
object = new ObjectConstructor(options, ...args);
|
|
37
|
+
} catch (ex) {
|
|
38
|
+
getLogger().warning(`Error: ${ex}`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (!object) {
|
|
42
|
+
getLogger().warning('ObjectCreation failed: could not create new Object');
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
return object;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* @param {import("@vcmap/core").VcsApp} vcsApp
|
|
50
|
+
* @param {VcsMapOptions} mapConfig
|
|
51
|
+
* @returns {Promise<import("@vcmap/core").VcsMap|null>}
|
|
52
|
+
*/
|
|
53
|
+
export async function deserializeMap(vcsApp, mapConfig) {
|
|
54
|
+
const map = await getObjectFromOptions(mapConfig);
|
|
55
|
+
if (map) {
|
|
56
|
+
map.layerCollection = vcsApp.layers;
|
|
57
|
+
}
|
|
58
|
+
return map;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @param {ViewPointOptions} viewPointObject
|
|
63
|
+
* @returns {Promise<null|import("@vcmap/core").ViewPoint>}
|
|
64
|
+
*/
|
|
65
|
+
export async function deserializeViewPoint(viewPointObject) {
|
|
66
|
+
const viewpoint = /** @type {import("@vcmap/core").ViewPoint} */ (await getObjectFromOptions(viewPointObject));
|
|
67
|
+
if (viewpoint && viewpoint.isValid()) {
|
|
68
|
+
return viewpoint;
|
|
69
|
+
}
|
|
70
|
+
getLogger().warning(`Viewpoint ${viewPointObject.name} is not valid`);
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @param {import("@vcmap/core").VcsApp} vcsApp
|
|
76
|
+
* @param {import("@vcmap/core").Layer} layer
|
|
77
|
+
* @returns {Promise<LayerOptions|null>}
|
|
78
|
+
*/
|
|
79
|
+
export async function serializeLayer(vcsApp, layer) {
|
|
80
|
+
const serializedLayer = layer.toJSON();
|
|
81
|
+
serializedLayer.zIndex = layer[vcsApp.layers.zIndexSymbol];
|
|
82
|
+
return serializedLayer;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @param {import("@vcmap/core").Layer} current
|
|
87
|
+
* @param {import("@vcmap/core").Layer} previous
|
|
88
|
+
* @param {number} currentIndex
|
|
89
|
+
* @returns {number|null}
|
|
90
|
+
*/
|
|
91
|
+
export function getLayerIndex(current, previous, currentIndex) {
|
|
92
|
+
if (current.zIndex !== previous.zIndex) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
return currentIndex;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @param {import("@vcmap/core").Collection<*>} collection
|
|
100
|
+
*/
|
|
101
|
+
export function destroyCollection(collection) {
|
|
102
|
+
[...collection].forEach((i) => {
|
|
103
|
+
if (i.destroy && !i.isDestroyed) {
|
|
104
|
+
i.destroy();
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
collection.destroy();
|
|
108
|
+
}
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import GeometryType from 'ol/geom/GeometryType.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Create an empty extent.
|
|
5
|
-
* @returns {Array<number>} Empty extent.
|
|
6
|
-
*/
|
|
7
|
-
export function createEmpty3D() {
|
|
8
|
-
return [Infinity, Infinity, Infinity, -Infinity, -Infinity, -Infinity];
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Create a new extent or update the provided extent.
|
|
13
|
-
* @param {number} minX Minimum X.
|
|
14
|
-
* @param {number} minY Minimum Y.
|
|
15
|
-
* @param {number} minZ Minimum Z.
|
|
16
|
-
* @param {number} maxX Maximum X.
|
|
17
|
-
* @param {number} maxY Maximum Y.
|
|
18
|
-
* @param {number} maxZ Maximum Z.
|
|
19
|
-
* @param {Array<number>=} optExtent Destination extent.
|
|
20
|
-
* @returns {Array<number>} Extent.
|
|
21
|
-
*/
|
|
22
|
-
export function createOrUpdate3D(minX, minY, minZ, maxX, maxY, maxZ, optExtent) {
|
|
23
|
-
if (optExtent) {
|
|
24
|
-
optExtent[0] = minX;
|
|
25
|
-
optExtent[1] = minY;
|
|
26
|
-
optExtent[2] = minZ;
|
|
27
|
-
optExtent[3] = maxX;
|
|
28
|
-
optExtent[4] = maxY;
|
|
29
|
-
optExtent[5] = maxZ;
|
|
30
|
-
return optExtent;
|
|
31
|
-
} else {
|
|
32
|
-
return [minX, minY, minZ, maxX, maxY, maxZ];
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @param {Array<number>} extent Extent.
|
|
38
|
-
* @param {number} x X.
|
|
39
|
-
* @param {number} y Y.
|
|
40
|
-
* @param {number} z Z.
|
|
41
|
-
*/
|
|
42
|
-
export function extendXYZ(extent, x, y, z) {
|
|
43
|
-
extent[0] = Math.min(extent[0], x);
|
|
44
|
-
extent[1] = Math.min(extent[1], y);
|
|
45
|
-
extent[2] = Math.min(extent[2], z);
|
|
46
|
-
extent[3] = Math.max(extent[3], x);
|
|
47
|
-
extent[4] = Math.max(extent[4], y);
|
|
48
|
-
extent[5] = Math.max(extent[5], z);
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* @param {Array<number>} extent Extent.
|
|
52
|
-
* @param {number} x X.
|
|
53
|
-
* @param {number} y Y.
|
|
54
|
-
*/
|
|
55
|
-
export function extendXY(extent, x, y) {
|
|
56
|
-
extent[0] = Math.min(extent[0], x);
|
|
57
|
-
extent[1] = Math.min(extent[1], y);
|
|
58
|
-
extent[3] = Math.max(extent[3], x);
|
|
59
|
-
extent[4] = Math.max(extent[4], y);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* @param {Array<number>} extent Extent.
|
|
64
|
-
* @param {number} z Z.
|
|
65
|
-
*/
|
|
66
|
-
export function extendZ(extent, z) {
|
|
67
|
-
extent[2] = Math.min(extent[2], z);
|
|
68
|
-
extent[5] = Math.max(extent[5], z);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* @param {Array<number>} extent Extent.
|
|
73
|
-
* @param {Array<number>} flatCoordinates Flat coordinates.
|
|
74
|
-
* @param {number} stride Stride.
|
|
75
|
-
* @returns {Array<number>} Extent.
|
|
76
|
-
*/
|
|
77
|
-
export function extendFlatCoordinates(
|
|
78
|
-
extent,
|
|
79
|
-
flatCoordinates,
|
|
80
|
-
stride,
|
|
81
|
-
) {
|
|
82
|
-
const { length } = flatCoordinates;
|
|
83
|
-
for (let offset = 0; offset < length; offset += stride) {
|
|
84
|
-
if (stride > 2) {
|
|
85
|
-
extendXYZ(extent, flatCoordinates[offset], flatCoordinates[offset + 1], flatCoordinates[offset + 2]);
|
|
86
|
-
} else {
|
|
87
|
-
extendXY(extent, flatCoordinates[offset], flatCoordinates[offset + 1]);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return extent;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* @param {import("ol/geom/Geometry").default} geometry Geometry.
|
|
95
|
-
* @param {Array<number>=} optExtent Extent.
|
|
96
|
-
* @returns {Array<number>} Extent.
|
|
97
|
-
*/
|
|
98
|
-
export function createOrUpdateFromGeometry(geometry, optExtent) {
|
|
99
|
-
const extent = optExtent || createEmpty3D();
|
|
100
|
-
if (geometry.getType() === GeometryType.GEOMETRY_COLLECTION) {
|
|
101
|
-
/** @type {import("ol/geom/GeometryCollection").default} */ (geometry)
|
|
102
|
-
.getGeometriesArray().forEach((geom) => { createOrUpdateFromGeometry(geom, extent); });
|
|
103
|
-
} else if (geometry.getType() === GeometryType.CIRCLE) {
|
|
104
|
-
const flatCoordinates = /** @type {import("ol/geom/Circle").default} */ (geometry).getFlatCoordinates();
|
|
105
|
-
const stride = /** @type {import("ol/geom/Circle").default} */ (geometry).getStride();
|
|
106
|
-
const radius = flatCoordinates[stride] - flatCoordinates[0];
|
|
107
|
-
extendXY(
|
|
108
|
-
extent,
|
|
109
|
-
flatCoordinates[0] - radius,
|
|
110
|
-
flatCoordinates[1] - radius,
|
|
111
|
-
);
|
|
112
|
-
extendXY(
|
|
113
|
-
extent,
|
|
114
|
-
flatCoordinates[0] + radius,
|
|
115
|
-
flatCoordinates[1] + radius,
|
|
116
|
-
);
|
|
117
|
-
if (stride > 2) {
|
|
118
|
-
extendZ(extent, flatCoordinates[2]);
|
|
119
|
-
}
|
|
120
|
-
} else {
|
|
121
|
-
const flatCoordinates = /** @type {import("ol/geom/SimpleGeometry").default} */ (geometry).getFlatCoordinates();
|
|
122
|
-
const stride = /** @type {import("ol/geom/SimpleGeometry").default} */ (geometry).getStride();
|
|
123
|
-
extendFlatCoordinates(extent, flatCoordinates, stride);
|
|
124
|
-
}
|
|
125
|
-
return extent;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* @param {VectorHeightInfo} heightInfo
|
|
130
|
-
* @param {Array<number>} optExtent
|
|
131
|
-
*/
|
|
132
|
-
export function createOrUpdateFromHeightInfo(heightInfo, optExtent) {
|
|
133
|
-
const extent = optExtent || createEmpty3D();
|
|
134
|
-
if (heightInfo.extruded) {
|
|
135
|
-
const calculatedFeatureMaxHeight =
|
|
136
|
-
heightInfo.groundLevel + heightInfo.storeyHeightsAboveGround.reduce((accumulator, currentValue) => {
|
|
137
|
-
return accumulator + currentValue;
|
|
138
|
-
}, 0);
|
|
139
|
-
extendZ(extent, calculatedFeatureMaxHeight);
|
|
140
|
-
const calculatedFeatureMinHeight =
|
|
141
|
-
heightInfo.groundLevel - heightInfo.storeyHeightsBelowGround.reduce((accumulator, currentValue) => {
|
|
142
|
-
return accumulator + currentValue;
|
|
143
|
-
}, 0);
|
|
144
|
-
extendZ(extent, calculatedFeatureMinHeight);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* @param {Array<number>} extent Extent.
|
|
150
|
-
* @returns {import("ol/extent").Extent} Extent.
|
|
151
|
-
*/
|
|
152
|
-
export function make2D(extent) {
|
|
153
|
-
return [extent[0], extent[1], extent[3], extent[4]];
|
|
154
|
-
}
|