@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,33 @@
|
|
|
1
|
+
import GeometryCollection from 'ol/geom/GeometryCollection.js';
|
|
2
|
+
import GeometryLayout from 'ol/geom/GeometryLayout.js';
|
|
3
|
+
import { check } from '@vcsuite/check';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @returns {Array<import("ol/coordinate").Coordinate|Array<import("ol/coordinate").Coordinate>|Array<Array<import("ol/coordinate").Coordinate>>|Array<Array<Array<import("ol/coordinate").Coordinate>>>>}
|
|
7
|
+
*/
|
|
8
|
+
GeometryCollection.prototype.getCoordinates = function getCoordinates() {
|
|
9
|
+
return this.getGeometries().map(g => g.getCoordinates());
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @param {Array<import("ol/coordinate").Coordinate|Array<import("ol/coordinate").Coordinate>|Array<Array<import("ol/coordinate").Coordinate>>|Array<Array<Array<import("ol/coordinate").Coordinate>>>>} coordinates
|
|
14
|
+
* @param {import("ol/geom/GeometryLayout").default=} optLayout
|
|
15
|
+
*/
|
|
16
|
+
GeometryCollection.prototype.setCoordinates = function setCoordinates(coordinates, optLayout) {
|
|
17
|
+
check(coordinates, Array);
|
|
18
|
+
check(coordinates.length, this.getGeometries().length);
|
|
19
|
+
|
|
20
|
+
this.setGeometries(this.getGeometries()
|
|
21
|
+
.map((g, i) => { g.setCoordinates(coordinates[i], optLayout); return g; }));
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @returns {import("ol/geom/GeometryLayout").default}
|
|
26
|
+
*/
|
|
27
|
+
GeometryCollection.prototype.getLayout = function getLayout() {
|
|
28
|
+
const firstGeom = this.getGeometries()[0];
|
|
29
|
+
if (firstGeom) {
|
|
30
|
+
return firstGeom.getLayout();
|
|
31
|
+
}
|
|
32
|
+
return /** @type {undefined} */ (GeometryLayout.XYZ);
|
|
33
|
+
};
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import CanvasImmediateRenderer from 'ol/render/canvas/Immediate.js';
|
|
3
|
+
import { intersects } from 'ol/extent.js';
|
|
4
|
+
import { transformGeom2D } from 'ol/geom/SimpleGeometry.js';
|
|
5
|
+
import { transform2D } from 'ol/geom/flat/transform.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @class
|
|
9
|
+
* @extends {CanvasImmediateRenderer}
|
|
10
|
+
* @memberOf ol
|
|
11
|
+
* @exports
|
|
12
|
+
* Tile Renderer Implementation of openlayers CanvasImmediateRenderer
|
|
13
|
+
* can be used to allow for a correction Factor to take into account Mercator Tile distortion
|
|
14
|
+
*/
|
|
15
|
+
class CanvasTileRenderer extends CanvasImmediateRenderer {
|
|
16
|
+
/**
|
|
17
|
+
* @param {CanvasRenderingContext2D} context Context.
|
|
18
|
+
* @param {number} pixelRatio Pixel ratio.
|
|
19
|
+
* @param {import("ol/extent").Extent} extent Extent.
|
|
20
|
+
* @param {import("ol/transform").Transform} transform Transform.
|
|
21
|
+
* @param {number} viewRotation View rotation.
|
|
22
|
+
* @param {number=} squaredTolerance Optional squared tolerance for simplification.
|
|
23
|
+
* @param {import("ol/proj").TransformFunction=} userTransform Transform from user to view projection.
|
|
24
|
+
* @param {number} [scaleY=1] Scale value for Scaling Circles, Images, Text in Y direction.
|
|
25
|
+
*/
|
|
26
|
+
constructor(
|
|
27
|
+
context,
|
|
28
|
+
pixelRatio,
|
|
29
|
+
extent,
|
|
30
|
+
transform,
|
|
31
|
+
viewRotation,
|
|
32
|
+
squaredTolerance,
|
|
33
|
+
userTransform,
|
|
34
|
+
scaleY = 1,
|
|
35
|
+
) {
|
|
36
|
+
super(context, pixelRatio, extent, transform, viewRotation, squaredTolerance, userTransform);
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @private
|
|
40
|
+
* @type {number}
|
|
41
|
+
*/
|
|
42
|
+
this.scaleY = scaleY;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @private
|
|
46
|
+
* @type {import("ol/size").Size}
|
|
47
|
+
*/
|
|
48
|
+
this.scaledImageScale_ = [0, 0];
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @private
|
|
52
|
+
* @type {import("ol/size").Size}
|
|
53
|
+
*/
|
|
54
|
+
this.scaledTextScale_ = [0, 0];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @private
|
|
59
|
+
* @type {import("ol/size").Size}
|
|
60
|
+
*/
|
|
61
|
+
get imageScale_() {
|
|
62
|
+
return this.scaledImageScale_;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @private
|
|
67
|
+
* @param {import("ol/size").Size} value
|
|
68
|
+
*/
|
|
69
|
+
set imageScale_(value) {
|
|
70
|
+
const imageScale = value || [1, 1];
|
|
71
|
+
this.scaledImageScale_ = [
|
|
72
|
+
imageScale[0],
|
|
73
|
+
imageScale[1] * this.scaleY,
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @private
|
|
79
|
+
* @type {import("ol/size").Size}
|
|
80
|
+
*/
|
|
81
|
+
get textScale_() {
|
|
82
|
+
return this.scaledTextScale_;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @private
|
|
87
|
+
* @param {import("ol/size").Size} value
|
|
88
|
+
*/
|
|
89
|
+
set textScale_(value) {
|
|
90
|
+
const textScale = value || [1, 1];
|
|
91
|
+
this.scaledTextScale_ = [
|
|
92
|
+
textScale[0],
|
|
93
|
+
textScale[1] * this.scaleY,
|
|
94
|
+
];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* @param {Array<number>} flatCoordinates Flat coordinates.
|
|
99
|
+
* @param {number} offset Offset.
|
|
100
|
+
* @param {number} end End.
|
|
101
|
+
* @param {number} stride Stride.
|
|
102
|
+
* @param {boolean} close Close.
|
|
103
|
+
* @private
|
|
104
|
+
* @returns {number} end End.
|
|
105
|
+
*/
|
|
106
|
+
moveToLineTo_(flatCoordinates, offset, end, stride, close) {
|
|
107
|
+
const context = this.context_;
|
|
108
|
+
const pixelCoordinates = transform2D(
|
|
109
|
+
flatCoordinates,
|
|
110
|
+
offset,
|
|
111
|
+
end,
|
|
112
|
+
stride,
|
|
113
|
+
this.transform_,
|
|
114
|
+
this.pixelCoordinates_,
|
|
115
|
+
);
|
|
116
|
+
context.moveTo(pixelCoordinates[0], pixelCoordinates[1]);
|
|
117
|
+
const { length } = pixelCoordinates;
|
|
118
|
+
for (let i = 2; i < length; i += 2) {
|
|
119
|
+
context.lineTo(pixelCoordinates[i], pixelCoordinates[i + 1]);
|
|
120
|
+
}
|
|
121
|
+
if (close) {
|
|
122
|
+
context.closePath();
|
|
123
|
+
}
|
|
124
|
+
return end;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Render a circle geometry into the canvas. Rendering is immediate and uses
|
|
129
|
+
* the current fill and stroke styles.
|
|
130
|
+
*
|
|
131
|
+
* takes the mercator yscale into account and draws a ellipse instead of a circle.
|
|
132
|
+
*
|
|
133
|
+
* @param {import("ol/geom/Circle").default} geometry Circle geometry.
|
|
134
|
+
* @api
|
|
135
|
+
*/
|
|
136
|
+
drawCircle(geometry) {
|
|
137
|
+
if (!intersects(this.extent_, geometry.getExtent())) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (this.fillState_ || this.strokeState_) {
|
|
141
|
+
if (this.fillState_) {
|
|
142
|
+
this.setContextFillState_(this.fillState_);
|
|
143
|
+
}
|
|
144
|
+
if (this.strokeState_) {
|
|
145
|
+
this.setContextStrokeState_(this.strokeState_);
|
|
146
|
+
}
|
|
147
|
+
const pixelCoordinates = transformGeom2D(
|
|
148
|
+
geometry,
|
|
149
|
+
this.transform_,
|
|
150
|
+
this.pixelCoordinates_,
|
|
151
|
+
);
|
|
152
|
+
const dx = pixelCoordinates[2] - pixelCoordinates[0];
|
|
153
|
+
const dy = pixelCoordinates[3] - pixelCoordinates[1];
|
|
154
|
+
const radius = Math.sqrt(dx * dx + dy * dy);
|
|
155
|
+
const context = this.context_;
|
|
156
|
+
context.beginPath();
|
|
157
|
+
context.ellipse(
|
|
158
|
+
pixelCoordinates[0],
|
|
159
|
+
pixelCoordinates[1],
|
|
160
|
+
radius,
|
|
161
|
+
radius * this.scaleY,
|
|
162
|
+
0,
|
|
163
|
+
0,
|
|
164
|
+
2 * Math.PI,
|
|
165
|
+
);
|
|
166
|
+
if (this.fillState_) {
|
|
167
|
+
context.fill();
|
|
168
|
+
}
|
|
169
|
+
if (this.strokeState_) {
|
|
170
|
+
context.stroke();
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
if (this.text_ !== '') {
|
|
174
|
+
this.drawText_(geometry.getCenter(), 0, 2, 2);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export default CanvasTileRenderer;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { getUid } from 'ol/util.js';
|
|
2
|
+
import VectorSource from 'ol/source/Vector.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @class
|
|
6
|
+
* @extends {import("ol/source").Vector<import("ol/geom/Geometry").default>}
|
|
7
|
+
* @memberOf ol
|
|
8
|
+
*/
|
|
9
|
+
class ClusterEnhancedVectorSource extends VectorSource {
|
|
10
|
+
/**
|
|
11
|
+
* @param {import("ol").Feature<import("ol/geom/Geometry").default>} feature
|
|
12
|
+
* @param {boolean=} silent
|
|
13
|
+
*/
|
|
14
|
+
removeFeature(feature, silent) {
|
|
15
|
+
const featureKey = getUid(feature);
|
|
16
|
+
if (featureKey in this.nullGeometryFeatures_) {
|
|
17
|
+
delete this.nullGeometryFeatures_[featureKey];
|
|
18
|
+
} else if (this.featuresRtree_) {
|
|
19
|
+
this.featuresRtree_.remove(feature);
|
|
20
|
+
}
|
|
21
|
+
this.removeFeatureInternal(feature);
|
|
22
|
+
if (!silent) {
|
|
23
|
+
this.changed();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @param {import("ol").Feature<import("ol/geom/Geometry").default>} feature
|
|
29
|
+
* @param {boolean=} silent
|
|
30
|
+
*/
|
|
31
|
+
addFeature(feature, silent) {
|
|
32
|
+
this.addFeatureInternal(feature);
|
|
33
|
+
if (!silent) {
|
|
34
|
+
this.changed();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default ClusterEnhancedVectorSource;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import Cluster from 'ol/source/Cluster.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @class
|
|
5
|
+
* @extends {import("ol/source/Cluster").default}
|
|
6
|
+
* @memberOf ol
|
|
7
|
+
*/
|
|
8
|
+
class VcsCluster extends Cluster {
|
|
9
|
+
constructor(props) {
|
|
10
|
+
super(props);
|
|
11
|
+
/**
|
|
12
|
+
* @type {boolean}
|
|
13
|
+
*/
|
|
14
|
+
this._paused = false;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
pause() {
|
|
18
|
+
this._paused = true;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
resume() {
|
|
22
|
+
this._paused = false;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
isPaused() {
|
|
26
|
+
return this._paused;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
refresh() {
|
|
30
|
+
if (this._paused) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
super.refresh();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default VcsCluster;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { check } from '@vcsuite/check';
|
|
2
|
+
import { getLogger } from '@vcsuite/logger';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @class
|
|
6
|
+
* @api
|
|
7
|
+
*/
|
|
8
|
+
class ClassRegistry {
|
|
9
|
+
constructor() {
|
|
10
|
+
/**
|
|
11
|
+
* @type {Map<string, function():(function(new: *, ...*)|Promise<function(new: *, ...*)>)>}
|
|
12
|
+
* @private
|
|
13
|
+
*/
|
|
14
|
+
this._classMap = new Map();
|
|
15
|
+
/**
|
|
16
|
+
* @type {import("@vcsuite/logger").Logger}
|
|
17
|
+
*/
|
|
18
|
+
this.logger = getLogger('vcs.vcm.ClassRegistry');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Register a class by its class name.
|
|
23
|
+
* @param {string} className
|
|
24
|
+
* @param {function(new: *, ...*)} ctor
|
|
25
|
+
* @api
|
|
26
|
+
*/
|
|
27
|
+
registerClass(className, ctor) {
|
|
28
|
+
check(className, String);
|
|
29
|
+
check(ctor, Function);
|
|
30
|
+
|
|
31
|
+
if (this._classMap.has(className)) {
|
|
32
|
+
throw new Error('a constructor with this className has already been registered');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
this._classMap.set(className, () => ctor);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @param {string} className
|
|
40
|
+
* @param {function():Promise<function(new: *, ...*)>} cb - a callback providing a promise which returns the constructor on resolve.
|
|
41
|
+
* used for lazy loading modules, e.g
|
|
42
|
+
* <code>ClassRegistry.registerDeferredClass(() => import('my-module').then(({ default: MyCtor }) => MyCtor));</code>
|
|
43
|
+
* @api
|
|
44
|
+
*/
|
|
45
|
+
registerDeferredClass(className, cb) {
|
|
46
|
+
check(className, String);
|
|
47
|
+
check(cb, Function);
|
|
48
|
+
|
|
49
|
+
this._classMap.set(className, cb);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Gets the constructor for a registered class or undefined, if no such class was registerd
|
|
54
|
+
* @param {string} className
|
|
55
|
+
* @returns {function(new: *, ...*)|Promise<*>|undefined}
|
|
56
|
+
* @api
|
|
57
|
+
*/
|
|
58
|
+
getClass(className) {
|
|
59
|
+
if (this._classMap.has(className)) {
|
|
60
|
+
return this._classMap.get(className)();
|
|
61
|
+
}
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* @param {string} className
|
|
67
|
+
* @param {...*} args
|
|
68
|
+
* @returns {Promise<*>}
|
|
69
|
+
* @api
|
|
70
|
+
*/
|
|
71
|
+
async create(className, ...args) {
|
|
72
|
+
check(className, String);
|
|
73
|
+
|
|
74
|
+
const Ctor = await this.getClass(className);
|
|
75
|
+
if (!Ctor) {
|
|
76
|
+
this.logger.error(`could not find constructor ${className}`);
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
return new Ctor(...args);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* @param {string} className
|
|
84
|
+
* @param {...*} args
|
|
85
|
+
* @returns {*}
|
|
86
|
+
* @deprecated 4.0
|
|
87
|
+
*/
|
|
88
|
+
createSync(className, ...args) {
|
|
89
|
+
check(className, String);
|
|
90
|
+
|
|
91
|
+
const Ctor = /** @type {function(new: *, ...*)} */ (this.getClass(className));
|
|
92
|
+
if (!Ctor) {
|
|
93
|
+
this.logger.error(`could not find constructor ${className}`);
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
return new Ctor(...args);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export default ClassRegistry;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @export
|
|
104
|
+
* @type {ClassRegistry}
|
|
105
|
+
*/
|
|
106
|
+
export const VcsClassRegistry = new ClassRegistry();
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @class
|
|
3
|
+
* @template {*} T
|
|
4
|
+
* @export
|
|
5
|
+
* @api
|
|
6
|
+
*/
|
|
7
|
+
class VcsEvent {
|
|
8
|
+
constructor() {
|
|
9
|
+
/**
|
|
10
|
+
* @type {Set<function(T=): Promise<void>|void>}
|
|
11
|
+
* @private
|
|
12
|
+
*/
|
|
13
|
+
this._listeners = new Set();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The number of listeners
|
|
18
|
+
* @type {number}
|
|
19
|
+
* @readonly
|
|
20
|
+
* @api
|
|
21
|
+
*/
|
|
22
|
+
get numberOfListeners() {
|
|
23
|
+
return this._listeners.size;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Adds an event listener. An event listener can only be added once.
|
|
28
|
+
* A listener added multiple times will only be called once.
|
|
29
|
+
* @param {function(T=): Promise<void>|void} listener
|
|
30
|
+
* @returns {function(): void} - remove callback. call this function to remove the listener
|
|
31
|
+
* @api
|
|
32
|
+
*/
|
|
33
|
+
addEventListener(listener) {
|
|
34
|
+
this._listeners.add(listener);
|
|
35
|
+
return () => {
|
|
36
|
+
this.removeEventListener(listener);
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Removes the provided listener
|
|
42
|
+
* @param {function(T=): Promise<void>|void} listener
|
|
43
|
+
* @returns {boolean} - whether a listener was removed
|
|
44
|
+
* @api
|
|
45
|
+
*/
|
|
46
|
+
removeEventListener(listener) {
|
|
47
|
+
if (this._listeners.has(listener)) {
|
|
48
|
+
this._listeners.delete(listener);
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Raise the event, calling all listeners
|
|
57
|
+
* @param {T=} event
|
|
58
|
+
* @api
|
|
59
|
+
*/
|
|
60
|
+
raiseEvent(event) {
|
|
61
|
+
this._listeners.forEach((cb) => {
|
|
62
|
+
cb(event);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @param {T=} event
|
|
68
|
+
* @returns {Promise<void>}
|
|
69
|
+
*/
|
|
70
|
+
async awaitRaisedEvent(event) {
|
|
71
|
+
const promises = new Array(this._listeners.size);
|
|
72
|
+
let i = 0;
|
|
73
|
+
this._listeners.forEach((cb) => {
|
|
74
|
+
promises[i] = cb(event);
|
|
75
|
+
i += 1;
|
|
76
|
+
});
|
|
77
|
+
await Promise.all(promises);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* clears all listeners
|
|
82
|
+
* @api
|
|
83
|
+
*/
|
|
84
|
+
destroy() {
|
|
85
|
+
this._listeners.clear();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export default VcsEvent;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Collection from './util/collection.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @type {import("@vcmap/core").Collection<import("@vcmap/core").StyleItem>}
|
|
5
|
+
*/
|
|
6
|
+
export const styleCollection = new Collection();
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @type {import("@vcmap/core").Collection<import("@vcmap/core").ObliqueCollection>}
|
|
10
|
+
*/
|
|
11
|
+
export const obliqueCollectionCollection = new Collection();
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
+
import { EventType, ModificationKeyType, PointerKeyType } from './interactionType.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {Object} ObliqueParameters
|
|
6
|
+
* @property {import("ol/coordinate").Coordinate} pixel - the image pixel clicked
|
|
7
|
+
* @property {boolean|undefined} estimate - true if the terrain could not be taken into account
|
|
8
|
+
* @api
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @typedef {MapEvent} InteractionEvent
|
|
13
|
+
* @property {EventType} type
|
|
14
|
+
* @property {undefined|import("ol").Feature<import("ol/geom/Geometry").default>|import("@vcmap/cesium").Cesium3DTileFeature|import("@vcmap/cesium").Cesium3DTilePointFeature} feature - a potential feature at said location
|
|
15
|
+
* @property {boolean|undefined} stopPropagation - if set to true, the event chain is interrupted
|
|
16
|
+
* @property {undefined|ObliqueParameters} obliqueParameters - additional parameters from oblique if obliquemode is active
|
|
17
|
+
* @property {import("@vcmap/cesium").Ray|undefined} ray - potential ray
|
|
18
|
+
* @property {boolean|undefined} exactPosition - whether the position is exact, eg with translucentDepthPicking on
|
|
19
|
+
* @api
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* An abstract interface for all interactions
|
|
24
|
+
* @class
|
|
25
|
+
* @export
|
|
26
|
+
* @abstract
|
|
27
|
+
* @api
|
|
28
|
+
*/
|
|
29
|
+
class AbstractInteraction {
|
|
30
|
+
constructor() {
|
|
31
|
+
/**
|
|
32
|
+
* A unique identifier for this interaction
|
|
33
|
+
* @type {string}
|
|
34
|
+
* @api
|
|
35
|
+
*/
|
|
36
|
+
this.id = uuidv4();
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* A bitmask representing the default events to listen to
|
|
40
|
+
* {@link EventType}, default is NONE
|
|
41
|
+
* @type {number}
|
|
42
|
+
* @protected
|
|
43
|
+
* @api
|
|
44
|
+
*/
|
|
45
|
+
this._defaultActive = EventType.NONE;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The current active bitmask for {@link EventType}
|
|
49
|
+
* @type {number}
|
|
50
|
+
* @api
|
|
51
|
+
*/
|
|
52
|
+
this.active = this._defaultActive;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The default bitmask for modification keys to listen to,
|
|
56
|
+
* {@link ModificationKeyType} default is NONE
|
|
57
|
+
* @type {number}
|
|
58
|
+
* @protected
|
|
59
|
+
* @api
|
|
60
|
+
*/
|
|
61
|
+
this._defaultModificationKey = ModificationKeyType.NONE;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The current active {@link ModificationKeyType}
|
|
65
|
+
* @type {number}
|
|
66
|
+
* @api
|
|
67
|
+
*/
|
|
68
|
+
this.modificationKey = this._defaultModificationKey;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* default bitmask for pointer key {@link PointerKeyType}, starting value is LEFT
|
|
72
|
+
* @type {number}
|
|
73
|
+
* @protected
|
|
74
|
+
*/
|
|
75
|
+
this._defaultPointerKey = PointerKeyType.LEFT;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The currently active {@link PointerKeyType}
|
|
79
|
+
* @type {number}
|
|
80
|
+
*/
|
|
81
|
+
this.pointerKey = this._defaultPointerKey;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Main function, called when an event is raised for this interaction
|
|
86
|
+
* @param {InteractionEvent} event
|
|
87
|
+
* @returns {Promise<InteractionEvent>}
|
|
88
|
+
* @api
|
|
89
|
+
*/
|
|
90
|
+
// eslint-disable-next-line class-methods-use-this
|
|
91
|
+
async pipe(event) {
|
|
92
|
+
return event;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Sets the interaction active.
|
|
97
|
+
* Use boolean (true|false) to toggle default behavior.
|
|
98
|
+
* Pass it a bitmask of {@link EventType}
|
|
99
|
+
* to change the active state.
|
|
100
|
+
* Call without arguments to reset the default active, modification key and pointer Key behavior
|
|
101
|
+
* @param {(boolean|number)=} active
|
|
102
|
+
* @api
|
|
103
|
+
*/
|
|
104
|
+
setActive(active) {
|
|
105
|
+
if (typeof active === 'undefined') {
|
|
106
|
+
this.active = this._defaultActive;
|
|
107
|
+
this.modificationKey = this._defaultModificationKey;
|
|
108
|
+
this.pointerKey = this._defaultPointerKey;
|
|
109
|
+
} else if (typeof active === 'boolean') {
|
|
110
|
+
this.active = active ? this._defaultActive : EventType.NONE;
|
|
111
|
+
} else {
|
|
112
|
+
this.active = active;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Sets the modification key to listen to
|
|
118
|
+
* @param {number=} mod
|
|
119
|
+
* @api
|
|
120
|
+
*/
|
|
121
|
+
setModification(mod) {
|
|
122
|
+
if (mod) {
|
|
123
|
+
this.modificationKey = mod;
|
|
124
|
+
} else {
|
|
125
|
+
this.modificationKey = this._defaultModificationKey;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Sets the pointer key for this interaction$
|
|
131
|
+
* @param {number} pointer
|
|
132
|
+
* @api
|
|
133
|
+
*/
|
|
134
|
+
setPointer(pointer) {
|
|
135
|
+
if (pointer) {
|
|
136
|
+
this.pointerKey = pointer;
|
|
137
|
+
} else {
|
|
138
|
+
this.pointerKey = this._defaultPointerKey;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* destroys the implementation, removing any created resources
|
|
144
|
+
*/
|
|
145
|
+
// eslint-disable-next-line class-methods-use-this
|
|
146
|
+
destroy() {}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export default AbstractInteraction;
|