@vcmap/core 5.0.0-rc.0
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/LICENSE.md +21 -0
- package/README.md +44 -0
- package/build/postinstall.js +44 -0
- package/index.js +139 -0
- package/package.json +92 -0
- package/src/cesium/cesium3DTileFeature.js +9 -0
- package/src/cesium/cesium3DTilePointFeature.js +9 -0
- package/src/cesium/cesiumVcsCameraPrimitive.js +146 -0
- package/src/cesium/wallpaperMaterial.js +64 -0
- package/src/ol/feature.js +47 -0
- package/src/ol/geom/circle.js +24 -0
- package/src/ol/geom/geometryCollection.js +33 -0
- package/src/ol/render/canvas/canvasTileRenderer.js +179 -0
- package/src/ol/source/ClusterEnhancedVectorSource.js +39 -0
- package/src/ol/source/VcsCluster.js +37 -0
- package/src/vcs/vcm/classRegistry.js +106 -0
- package/src/vcs/vcm/event/vcsEvent.js +89 -0
- package/src/vcs/vcm/globalCollections.js +11 -0
- package/src/vcs/vcm/interaction/abstractInteraction.js +149 -0
- package/src/vcs/vcm/interaction/coordinateAtPixel.js +102 -0
- package/src/vcs/vcm/interaction/eventHandler.js +425 -0
- package/src/vcs/vcm/interaction/featureAtPixelInteraction.js +286 -0
- package/src/vcs/vcm/interaction/featureProviderInteraction.js +54 -0
- package/src/vcs/vcm/interaction/interactionChain.js +124 -0
- package/src/vcs/vcm/interaction/interactionType.js +114 -0
- package/src/vcs/vcm/layer/buildings.js +17 -0
- package/src/vcs/vcm/layer/cesium/cesiumTilesetCesium.js +359 -0
- package/src/vcs/vcm/layer/cesium/clusterContext.js +95 -0
- package/src/vcs/vcm/layer/cesium/dataSourceCesium.js +171 -0
- package/src/vcs/vcm/layer/cesium/openStreetMapCesium.js +29 -0
- package/src/vcs/vcm/layer/cesium/pointCloudCesium.js +58 -0
- package/src/vcs/vcm/layer/cesium/rasterLayerCesium.js +110 -0
- package/src/vcs/vcm/layer/cesium/singleImageCesium.js +49 -0
- package/src/vcs/vcm/layer/cesium/terrainCesium.js +80 -0
- package/src/vcs/vcm/layer/cesium/tmsCesium.js +54 -0
- package/src/vcs/vcm/layer/cesium/vectorCesium.js +255 -0
- package/src/vcs/vcm/layer/cesium/vectorContext.js +167 -0
- package/src/vcs/vcm/layer/cesium/vectorRasterTileCesium.js +116 -0
- package/src/vcs/vcm/layer/cesium/vectorTileImageryProvider.js +246 -0
- package/src/vcs/vcm/layer/cesium/wmsCesium.js +71 -0
- package/src/vcs/vcm/layer/cesium/wmtsCesium.js +101 -0
- package/src/vcs/vcm/layer/cesium/x3dmHelper.js +22 -0
- package/src/vcs/vcm/layer/cesiumTileset.js +376 -0
- package/src/vcs/vcm/layer/czml.js +141 -0
- package/src/vcs/vcm/layer/dataSource.js +259 -0
- package/src/vcs/vcm/layer/featureLayer.js +261 -0
- package/src/vcs/vcm/layer/featureStore.js +647 -0
- package/src/vcs/vcm/layer/featureStoreChanges.js +360 -0
- package/src/vcs/vcm/layer/featureStoreState.js +19 -0
- package/src/vcs/vcm/layer/featureVisibility.js +435 -0
- package/src/vcs/vcm/layer/geojson.js +185 -0
- package/src/vcs/vcm/layer/geojsonHelpers.js +450 -0
- package/src/vcs/vcm/layer/globalHider.js +157 -0
- package/src/vcs/vcm/layer/layer.js +752 -0
- package/src/vcs/vcm/layer/layerImplementation.js +102 -0
- package/src/vcs/vcm/layer/layerState.js +17 -0
- package/src/vcs/vcm/layer/layerSymbols.js +6 -0
- package/src/vcs/vcm/layer/oblique/layerOblique.js +76 -0
- package/src/vcs/vcm/layer/oblique/obliqueHelpers.js +175 -0
- package/src/vcs/vcm/layer/oblique/vectorOblique.js +469 -0
- package/src/vcs/vcm/layer/openStreetMap.js +194 -0
- package/src/vcs/vcm/layer/openlayers/layerOpenlayers.js +79 -0
- package/src/vcs/vcm/layer/openlayers/openStreetMapOpenlayers.js +27 -0
- package/src/vcs/vcm/layer/openlayers/rasterLayerOpenlayers.js +121 -0
- package/src/vcs/vcm/layer/openlayers/singleImageOpenlayers.js +49 -0
- package/src/vcs/vcm/layer/openlayers/tileDebugOpenlayers.js +39 -0
- package/src/vcs/vcm/layer/openlayers/tmsOpenlayers.js +62 -0
- package/src/vcs/vcm/layer/openlayers/vectorOpenlayers.js +118 -0
- package/src/vcs/vcm/layer/openlayers/vectorTileOpenlayers.js +177 -0
- package/src/vcs/vcm/layer/openlayers/wmsOpenlayers.js +55 -0
- package/src/vcs/vcm/layer/openlayers/wmtsOpenlayers.js +141 -0
- package/src/vcs/vcm/layer/pointCloud.js +162 -0
- package/src/vcs/vcm/layer/rasterLayer.js +294 -0
- package/src/vcs/vcm/layer/singleImage.js +119 -0
- package/src/vcs/vcm/layer/terrain.js +122 -0
- package/src/vcs/vcm/layer/terrainHelpers.js +123 -0
- package/src/vcs/vcm/layer/tileLoadedHelper.js +72 -0
- package/src/vcs/vcm/layer/tileProvider/mvtTileProvider.js +104 -0
- package/src/vcs/vcm/layer/tileProvider/staticGeojsonTileProvider.js +67 -0
- package/src/vcs/vcm/layer/tileProvider/tileProvider.js +584 -0
- package/src/vcs/vcm/layer/tileProvider/tileProviderFactory.js +28 -0
- package/src/vcs/vcm/layer/tileProvider/urlTemplateTileProvider.js +106 -0
- package/src/vcs/vcm/layer/tms.js +121 -0
- package/src/vcs/vcm/layer/vector.js +632 -0
- package/src/vcs/vcm/layer/vectorHelpers.js +206 -0
- package/src/vcs/vcm/layer/vectorProperties.js +1391 -0
- package/src/vcs/vcm/layer/vectorSymbols.js +40 -0
- package/src/vcs/vcm/layer/vectorTile.js +480 -0
- package/src/vcs/vcm/layer/wfs.js +165 -0
- package/src/vcs/vcm/layer/wms.js +270 -0
- package/src/vcs/vcm/layer/wmsHelpers.js +65 -0
- package/src/vcs/vcm/layer/wmts.js +235 -0
- package/src/vcs/vcm/maps/baseOLMap.js +257 -0
- package/src/vcs/vcm/maps/cameraLimiter.js +219 -0
- package/src/vcs/vcm/maps/cesium.js +1192 -0
- package/src/vcs/vcm/maps/map.js +511 -0
- package/src/vcs/vcm/maps/mapState.js +17 -0
- package/src/vcs/vcm/maps/oblique.js +536 -0
- package/src/vcs/vcm/maps/openlayers.js +205 -0
- package/src/vcs/vcm/object.js +92 -0
- package/src/vcs/vcm/oblique/ObliqueCollection.js +572 -0
- package/src/vcs/vcm/oblique/ObliqueDataSet.js +357 -0
- package/src/vcs/vcm/oblique/ObliqueImage.js +247 -0
- package/src/vcs/vcm/oblique/ObliqueImageMeta.js +126 -0
- package/src/vcs/vcm/oblique/ObliqueProvider.js +433 -0
- package/src/vcs/vcm/oblique/ObliqueView.js +130 -0
- package/src/vcs/vcm/oblique/ObliqueViewDirection.js +40 -0
- package/src/vcs/vcm/oblique/helpers.js +483 -0
- package/src/vcs/vcm/oblique/parseImageJson.js +248 -0
- package/src/vcs/vcm/util/clipping/clippingObject.js +386 -0
- package/src/vcs/vcm/util/clipping/clippingObjectManager.js +312 -0
- package/src/vcs/vcm/util/clipping/clippingPlaneHelper.js +413 -0
- package/src/vcs/vcm/util/collection.js +193 -0
- package/src/vcs/vcm/util/dateTime.js +60 -0
- package/src/vcs/vcm/util/exclusiveManager.js +135 -0
- package/src/vcs/vcm/util/extent.js +124 -0
- package/src/vcs/vcm/util/featureProvider/abstractFeatureProvider.js +196 -0
- package/src/vcs/vcm/util/featureProvider/featureProviderHelpers.js +51 -0
- package/src/vcs/vcm/util/featureProvider/featureProviderSymbols.js +11 -0
- package/src/vcs/vcm/util/featureProvider/tileProviderFeatureProvider.js +62 -0
- package/src/vcs/vcm/util/featureProvider/wmsFeatureProvider.js +280 -0
- package/src/vcs/vcm/util/featureconverter/circleToCesium.js +215 -0
- package/src/vcs/vcm/util/featureconverter/convert.js +83 -0
- package/src/vcs/vcm/util/featureconverter/extent3d.js +154 -0
- package/src/vcs/vcm/util/featureconverter/featureconverterHelper.js +591 -0
- package/src/vcs/vcm/util/featureconverter/lineStringToCesium.js +171 -0
- package/src/vcs/vcm/util/featureconverter/pointToCesium.js +359 -0
- package/src/vcs/vcm/util/featureconverter/polygonToCesium.js +229 -0
- package/src/vcs/vcm/util/geometryHelpers.js +172 -0
- package/src/vcs/vcm/util/indexedCollection.js +158 -0
- package/src/vcs/vcm/util/isMobile.js +12 -0
- package/src/vcs/vcm/util/layerCollection.js +216 -0
- package/src/vcs/vcm/util/locale.js +53 -0
- package/src/vcs/vcm/util/mapCollection.js +363 -0
- package/src/vcs/vcm/util/math.js +71 -0
- package/src/vcs/vcm/util/projection.js +348 -0
- package/src/vcs/vcm/util/splitScreen.js +233 -0
- package/src/vcs/vcm/util/style/declarativeStyleItem.js +631 -0
- package/src/vcs/vcm/util/style/shapesCategory.js +67 -0
- package/src/vcs/vcm/util/style/styleFactory.js +48 -0
- package/src/vcs/vcm/util/style/styleHelpers.js +555 -0
- package/src/vcs/vcm/util/style/styleItem.js +226 -0
- package/src/vcs/vcm/util/style/vectorStyleItem.js +927 -0
- package/src/vcs/vcm/util/style/writeStyle.js +48 -0
- package/src/vcs/vcm/util/urlHelpers.js +16 -0
- package/src/vcs/vcm/util/viewpoint.js +333 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { unByKey } from 'ol/Observable.js';
|
|
2
|
+
import Feature from 'ol/Feature.js';
|
|
3
|
+
import GeometryType from 'ol/geom/GeometryType.js';
|
|
4
|
+
import { HeightReference } from '@vcmap/cesium';
|
|
5
|
+
import { FeatureVisibilityAction } from './featureVisibility.js';
|
|
6
|
+
import Projection from '../util/projection.js';
|
|
7
|
+
import { getHeightInfo } from '../util/featureconverter/featureconverterHelper.js';
|
|
8
|
+
import { getFlatCoordinatesFromGeometry } from '../util/geometryHelpers.js';
|
|
9
|
+
import { createOrUpdateFromGeometry, createOrUpdateFromHeightInfo } from '../util/featureconverter/extent3d.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Added to ol.source.Vector to determine, when the source has last had an update to its features visibility.
|
|
13
|
+
* @type {symbol}
|
|
14
|
+
*/
|
|
15
|
+
export const fvLastUpdated = Symbol('FVlastUpdated');
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Added to ol.source.Vector to determine, when the source has last had an update to its features global visibility.
|
|
19
|
+
* @type {symbol}
|
|
20
|
+
*/
|
|
21
|
+
export const globalHiderLastUpdated = Symbol('GlobalHiderLastUpdated');
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @param {import("@vcmap/core").FeatureVisibility} featureVisibility
|
|
25
|
+
* @param {import("ol/source").Vector<import("ol/geom/Geometry").default>} source
|
|
26
|
+
*/
|
|
27
|
+
export function updateFeatureVisibility(featureVisibility, source) {
|
|
28
|
+
Object.keys(featureVisibility.highlightedObjects)
|
|
29
|
+
.forEach((id) => {
|
|
30
|
+
const feat = source.getFeatureById(id);
|
|
31
|
+
if (feat && !featureVisibility.hasHighlightFeature(id, feat)) {
|
|
32
|
+
featureVisibility.addHighlightFeature(id, feat);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
Object.keys(featureVisibility.hiddenObjects)
|
|
37
|
+
.forEach((id) => {
|
|
38
|
+
const feat = source.getFeatureById(id);
|
|
39
|
+
if (feat && !featureVisibility.hasHiddenFeature(id, feat)) {
|
|
40
|
+
featureVisibility.addHiddenFeature(id, feat);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
source[fvLastUpdated] = Date.now();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* @param {import("@vcmap/core").GlobalHider} globalHider
|
|
48
|
+
* @param {import("ol/source").Vector<import("ol/geom/Geometry").default>} source
|
|
49
|
+
*/
|
|
50
|
+
export function updateGlobalHider(globalHider, source) {
|
|
51
|
+
Object.keys(globalHider.hiddenObjects)
|
|
52
|
+
.forEach((id) => {
|
|
53
|
+
const feat = source.getFeatureById(id);
|
|
54
|
+
if (feat && !globalHider.hasFeature(id, feat)) {
|
|
55
|
+
globalHider.addFeature(id, feat);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
source[globalHiderLastUpdated] = Date.now();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @param {import("@vcmap/core").FeatureVisibility} featureVisibility
|
|
63
|
+
* @param {import("ol/source").Vector<import("ol/geom/Geometry").default>} source
|
|
64
|
+
* @param {import("@vcmap/core").GlobalHider} globalHider
|
|
65
|
+
* @returns {Array<Function>}
|
|
66
|
+
*/
|
|
67
|
+
export function synchronizeFeatureVisibilityWithSource(featureVisibility, source, globalHider) {
|
|
68
|
+
const sourceListener = source.on('addfeature', ({ feature }) => {
|
|
69
|
+
const id = feature.getId();
|
|
70
|
+
if (featureVisibility.highlightedObjects[id]) {
|
|
71
|
+
featureVisibility.addHighlightFeature(id, feature);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (featureVisibility.hiddenObjects[id]) {
|
|
75
|
+
featureVisibility.addHiddenFeature(id, feature);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (globalHider.hiddenObjects[id]) {
|
|
79
|
+
globalHider.addFeature(id, feature);
|
|
80
|
+
}
|
|
81
|
+
const now = Date.now();
|
|
82
|
+
source[fvLastUpdated] = now;
|
|
83
|
+
source[globalHiderLastUpdated] = now;
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
if (!source[fvLastUpdated] || source[fvLastUpdated] < featureVisibility.lastUpdated) {
|
|
87
|
+
updateFeatureVisibility(featureVisibility, source);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (!source[globalHiderLastUpdated] || source[globalHiderLastUpdated] < featureVisibility.lastUpdated) {
|
|
91
|
+
updateGlobalHider(globalHider, source);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return [
|
|
95
|
+
featureVisibility.changed.addEventListener(({ action, ids }) => {
|
|
96
|
+
if (action === FeatureVisibilityAction.HIGHLIGHT) {
|
|
97
|
+
ids.forEach((id) => {
|
|
98
|
+
const feat = source.getFeatureById(id);
|
|
99
|
+
if (feat) {
|
|
100
|
+
featureVisibility.addHighlightFeature(id, feat);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
source[fvLastUpdated] = Date.now();
|
|
104
|
+
} else if (action === FeatureVisibilityAction.HIDE) {
|
|
105
|
+
ids.forEach((id) => {
|
|
106
|
+
const feat = source.getFeatureById(id);
|
|
107
|
+
if (feat) {
|
|
108
|
+
featureVisibility.addHiddenFeature(id, feat);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
source[fvLastUpdated] = Date.now();
|
|
112
|
+
}
|
|
113
|
+
}),
|
|
114
|
+
globalHider.changed.addEventListener(({ action, ids }) => {
|
|
115
|
+
if (action === FeatureVisibilityAction.HIDE) {
|
|
116
|
+
ids.forEach((id) => {
|
|
117
|
+
const feat = source.getFeatureById(id);
|
|
118
|
+
if (feat) {
|
|
119
|
+
globalHider.addFeature(id, feat);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
source[globalHiderLastUpdated] = Date.now();
|
|
123
|
+
}
|
|
124
|
+
}),
|
|
125
|
+
() => { unByKey(sourceListener); },
|
|
126
|
+
];
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* @param {VectorClickedObject} object
|
|
131
|
+
* @param {import("@vcmap/core").Vector|import("@vcmap/core").VectorTile} layer
|
|
132
|
+
* @returns {?GenericFeature}
|
|
133
|
+
*/
|
|
134
|
+
export function getGenericFeatureFromClickedObject(object, layer) {
|
|
135
|
+
if (!(object instanceof Feature)) {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
const attributes = object.getProperties();
|
|
139
|
+
delete attributes[object.getGeometryName()];
|
|
140
|
+
|
|
141
|
+
const { clickedPosition } = object;
|
|
142
|
+
if (!clickedPosition) {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
let { latitude, longitude } = clickedPosition;
|
|
146
|
+
const geometry = object.getGeometry();
|
|
147
|
+
let heightOffset = clickedPosition.height;
|
|
148
|
+
let calculateHeight = !heightOffset;
|
|
149
|
+
if (!geometry) {
|
|
150
|
+
calculateHeight = false; // we cannot calculate the height without geometry;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
let relativeToGround = !heightOffset;
|
|
154
|
+
// Edge Case ClickedPosition is next to the feature and Feature got detected in clickToleranz.
|
|
155
|
+
// if the clicked Position does not intersect the feature the closestPoint will be used.
|
|
156
|
+
// also if the clickedPosition is not on the Feature we do not trust the Height Value;
|
|
157
|
+
const mercatorPoint =
|
|
158
|
+
Projection.wgs84ToMercator([clickedPosition.longitude, clickedPosition.latitude, clickedPosition.height]);
|
|
159
|
+
if (geometry && !geometry.intersectsCoordinate(mercatorPoint)) {
|
|
160
|
+
const closestPoint = geometry.getClosestPoint(mercatorPoint);
|
|
161
|
+
[longitude, latitude] = Projection.mercatorToWgs84(closestPoint);
|
|
162
|
+
calculateHeight = true;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// edge case oblique in this case we do get a height value but not of the feature but the underlying terrain.
|
|
166
|
+
// this is necessary to calculate the correct position of the balloon
|
|
167
|
+
|
|
168
|
+
// if we do not have a height value from the clickedPosition we calculate the height based in the feature;
|
|
169
|
+
if (calculateHeight) {
|
|
170
|
+
const coordinates = getFlatCoordinatesFromGeometry(geometry);
|
|
171
|
+
const heightInfo = getHeightInfo(object, layer.vectorProperties, coordinates);
|
|
172
|
+
if (heightInfo.perPositionHeight || heightInfo.extruded) {
|
|
173
|
+
const extent = createOrUpdateFromGeometry(geometry);
|
|
174
|
+
createOrUpdateFromHeightInfo(heightInfo, extent);
|
|
175
|
+
heightOffset = extent[5];
|
|
176
|
+
}
|
|
177
|
+
// edge case points are rendered depending on the terrain, so we set relativeToGround to true.
|
|
178
|
+
// In this case the heightAboveGroundAdjustment is also just an Offset.
|
|
179
|
+
if (
|
|
180
|
+
!heightInfo.extruded &&
|
|
181
|
+
(geometry.getType() === GeometryType.POINT || geometry.getType() === GeometryType.MULTI_POINT) &&
|
|
182
|
+
(
|
|
183
|
+
heightInfo.heightReference === HeightReference.RELATIVE_TO_GROUND ||
|
|
184
|
+
heightInfo.heightReference === HeightReference.CLAMP_TO_GROUND)
|
|
185
|
+
) {
|
|
186
|
+
heightOffset = heightInfo.heightAboveGroundAdjustment;
|
|
187
|
+
relativeToGround = true;
|
|
188
|
+
} else {
|
|
189
|
+
heightOffset += heightInfo.heightAboveGroundAdjustment;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// if we have to calculate the height we have to take heightAboveGround into account
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
delete attributes.clickedPosition;
|
|
196
|
+
heightOffset = Number.isFinite(heightOffset) ? heightOffset : 0;
|
|
197
|
+
return {
|
|
198
|
+
layerName: layer.name,
|
|
199
|
+
layerClass: layer.className,
|
|
200
|
+
attributes: { ...layer.genericFeatureProperties, ...attributes },
|
|
201
|
+
longitude,
|
|
202
|
+
latitude,
|
|
203
|
+
height: heightOffset + layer.balloonHeightOffset,
|
|
204
|
+
relativeToGround,
|
|
205
|
+
};
|
|
206
|
+
}
|