@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.
Files changed (146) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +44 -0
  3. package/build/postinstall.js +44 -0
  4. package/index.js +139 -0
  5. package/package.json +92 -0
  6. package/src/cesium/cesium3DTileFeature.js +9 -0
  7. package/src/cesium/cesium3DTilePointFeature.js +9 -0
  8. package/src/cesium/cesiumVcsCameraPrimitive.js +146 -0
  9. package/src/cesium/wallpaperMaterial.js +64 -0
  10. package/src/ol/feature.js +47 -0
  11. package/src/ol/geom/circle.js +24 -0
  12. package/src/ol/geom/geometryCollection.js +33 -0
  13. package/src/ol/render/canvas/canvasTileRenderer.js +179 -0
  14. package/src/ol/source/ClusterEnhancedVectorSource.js +39 -0
  15. package/src/ol/source/VcsCluster.js +37 -0
  16. package/src/vcs/vcm/classRegistry.js +106 -0
  17. package/src/vcs/vcm/event/vcsEvent.js +89 -0
  18. package/src/vcs/vcm/globalCollections.js +11 -0
  19. package/src/vcs/vcm/interaction/abstractInteraction.js +149 -0
  20. package/src/vcs/vcm/interaction/coordinateAtPixel.js +102 -0
  21. package/src/vcs/vcm/interaction/eventHandler.js +425 -0
  22. package/src/vcs/vcm/interaction/featureAtPixelInteraction.js +286 -0
  23. package/src/vcs/vcm/interaction/featureProviderInteraction.js +54 -0
  24. package/src/vcs/vcm/interaction/interactionChain.js +124 -0
  25. package/src/vcs/vcm/interaction/interactionType.js +114 -0
  26. package/src/vcs/vcm/layer/buildings.js +17 -0
  27. package/src/vcs/vcm/layer/cesium/cesiumTilesetCesium.js +359 -0
  28. package/src/vcs/vcm/layer/cesium/clusterContext.js +95 -0
  29. package/src/vcs/vcm/layer/cesium/dataSourceCesium.js +171 -0
  30. package/src/vcs/vcm/layer/cesium/openStreetMapCesium.js +29 -0
  31. package/src/vcs/vcm/layer/cesium/pointCloudCesium.js +58 -0
  32. package/src/vcs/vcm/layer/cesium/rasterLayerCesium.js +110 -0
  33. package/src/vcs/vcm/layer/cesium/singleImageCesium.js +49 -0
  34. package/src/vcs/vcm/layer/cesium/terrainCesium.js +80 -0
  35. package/src/vcs/vcm/layer/cesium/tmsCesium.js +54 -0
  36. package/src/vcs/vcm/layer/cesium/vectorCesium.js +255 -0
  37. package/src/vcs/vcm/layer/cesium/vectorContext.js +167 -0
  38. package/src/vcs/vcm/layer/cesium/vectorRasterTileCesium.js +116 -0
  39. package/src/vcs/vcm/layer/cesium/vectorTileImageryProvider.js +246 -0
  40. package/src/vcs/vcm/layer/cesium/wmsCesium.js +71 -0
  41. package/src/vcs/vcm/layer/cesium/wmtsCesium.js +101 -0
  42. package/src/vcs/vcm/layer/cesium/x3dmHelper.js +22 -0
  43. package/src/vcs/vcm/layer/cesiumTileset.js +376 -0
  44. package/src/vcs/vcm/layer/czml.js +141 -0
  45. package/src/vcs/vcm/layer/dataSource.js +259 -0
  46. package/src/vcs/vcm/layer/featureLayer.js +261 -0
  47. package/src/vcs/vcm/layer/featureStore.js +647 -0
  48. package/src/vcs/vcm/layer/featureStoreChanges.js +360 -0
  49. package/src/vcs/vcm/layer/featureStoreState.js +19 -0
  50. package/src/vcs/vcm/layer/featureVisibility.js +435 -0
  51. package/src/vcs/vcm/layer/geojson.js +185 -0
  52. package/src/vcs/vcm/layer/geojsonHelpers.js +450 -0
  53. package/src/vcs/vcm/layer/globalHider.js +157 -0
  54. package/src/vcs/vcm/layer/layer.js +752 -0
  55. package/src/vcs/vcm/layer/layerImplementation.js +102 -0
  56. package/src/vcs/vcm/layer/layerState.js +17 -0
  57. package/src/vcs/vcm/layer/layerSymbols.js +6 -0
  58. package/src/vcs/vcm/layer/oblique/layerOblique.js +76 -0
  59. package/src/vcs/vcm/layer/oblique/obliqueHelpers.js +175 -0
  60. package/src/vcs/vcm/layer/oblique/vectorOblique.js +469 -0
  61. package/src/vcs/vcm/layer/openStreetMap.js +194 -0
  62. package/src/vcs/vcm/layer/openlayers/layerOpenlayers.js +79 -0
  63. package/src/vcs/vcm/layer/openlayers/openStreetMapOpenlayers.js +27 -0
  64. package/src/vcs/vcm/layer/openlayers/rasterLayerOpenlayers.js +121 -0
  65. package/src/vcs/vcm/layer/openlayers/singleImageOpenlayers.js +49 -0
  66. package/src/vcs/vcm/layer/openlayers/tileDebugOpenlayers.js +39 -0
  67. package/src/vcs/vcm/layer/openlayers/tmsOpenlayers.js +62 -0
  68. package/src/vcs/vcm/layer/openlayers/vectorOpenlayers.js +118 -0
  69. package/src/vcs/vcm/layer/openlayers/vectorTileOpenlayers.js +177 -0
  70. package/src/vcs/vcm/layer/openlayers/wmsOpenlayers.js +55 -0
  71. package/src/vcs/vcm/layer/openlayers/wmtsOpenlayers.js +141 -0
  72. package/src/vcs/vcm/layer/pointCloud.js +162 -0
  73. package/src/vcs/vcm/layer/rasterLayer.js +294 -0
  74. package/src/vcs/vcm/layer/singleImage.js +119 -0
  75. package/src/vcs/vcm/layer/terrain.js +122 -0
  76. package/src/vcs/vcm/layer/terrainHelpers.js +123 -0
  77. package/src/vcs/vcm/layer/tileLoadedHelper.js +72 -0
  78. package/src/vcs/vcm/layer/tileProvider/mvtTileProvider.js +104 -0
  79. package/src/vcs/vcm/layer/tileProvider/staticGeojsonTileProvider.js +67 -0
  80. package/src/vcs/vcm/layer/tileProvider/tileProvider.js +584 -0
  81. package/src/vcs/vcm/layer/tileProvider/tileProviderFactory.js +28 -0
  82. package/src/vcs/vcm/layer/tileProvider/urlTemplateTileProvider.js +106 -0
  83. package/src/vcs/vcm/layer/tms.js +121 -0
  84. package/src/vcs/vcm/layer/vector.js +632 -0
  85. package/src/vcs/vcm/layer/vectorHelpers.js +206 -0
  86. package/src/vcs/vcm/layer/vectorProperties.js +1391 -0
  87. package/src/vcs/vcm/layer/vectorSymbols.js +40 -0
  88. package/src/vcs/vcm/layer/vectorTile.js +480 -0
  89. package/src/vcs/vcm/layer/wfs.js +165 -0
  90. package/src/vcs/vcm/layer/wms.js +270 -0
  91. package/src/vcs/vcm/layer/wmsHelpers.js +65 -0
  92. package/src/vcs/vcm/layer/wmts.js +235 -0
  93. package/src/vcs/vcm/maps/baseOLMap.js +257 -0
  94. package/src/vcs/vcm/maps/cameraLimiter.js +219 -0
  95. package/src/vcs/vcm/maps/cesium.js +1192 -0
  96. package/src/vcs/vcm/maps/map.js +511 -0
  97. package/src/vcs/vcm/maps/mapState.js +17 -0
  98. package/src/vcs/vcm/maps/oblique.js +536 -0
  99. package/src/vcs/vcm/maps/openlayers.js +205 -0
  100. package/src/vcs/vcm/object.js +92 -0
  101. package/src/vcs/vcm/oblique/ObliqueCollection.js +572 -0
  102. package/src/vcs/vcm/oblique/ObliqueDataSet.js +357 -0
  103. package/src/vcs/vcm/oblique/ObliqueImage.js +247 -0
  104. package/src/vcs/vcm/oblique/ObliqueImageMeta.js +126 -0
  105. package/src/vcs/vcm/oblique/ObliqueProvider.js +433 -0
  106. package/src/vcs/vcm/oblique/ObliqueView.js +130 -0
  107. package/src/vcs/vcm/oblique/ObliqueViewDirection.js +40 -0
  108. package/src/vcs/vcm/oblique/helpers.js +483 -0
  109. package/src/vcs/vcm/oblique/parseImageJson.js +248 -0
  110. package/src/vcs/vcm/util/clipping/clippingObject.js +386 -0
  111. package/src/vcs/vcm/util/clipping/clippingObjectManager.js +312 -0
  112. package/src/vcs/vcm/util/clipping/clippingPlaneHelper.js +413 -0
  113. package/src/vcs/vcm/util/collection.js +193 -0
  114. package/src/vcs/vcm/util/dateTime.js +60 -0
  115. package/src/vcs/vcm/util/exclusiveManager.js +135 -0
  116. package/src/vcs/vcm/util/extent.js +124 -0
  117. package/src/vcs/vcm/util/featureProvider/abstractFeatureProvider.js +196 -0
  118. package/src/vcs/vcm/util/featureProvider/featureProviderHelpers.js +51 -0
  119. package/src/vcs/vcm/util/featureProvider/featureProviderSymbols.js +11 -0
  120. package/src/vcs/vcm/util/featureProvider/tileProviderFeatureProvider.js +62 -0
  121. package/src/vcs/vcm/util/featureProvider/wmsFeatureProvider.js +280 -0
  122. package/src/vcs/vcm/util/featureconverter/circleToCesium.js +215 -0
  123. package/src/vcs/vcm/util/featureconverter/convert.js +83 -0
  124. package/src/vcs/vcm/util/featureconverter/extent3d.js +154 -0
  125. package/src/vcs/vcm/util/featureconverter/featureconverterHelper.js +591 -0
  126. package/src/vcs/vcm/util/featureconverter/lineStringToCesium.js +171 -0
  127. package/src/vcs/vcm/util/featureconverter/pointToCesium.js +359 -0
  128. package/src/vcs/vcm/util/featureconverter/polygonToCesium.js +229 -0
  129. package/src/vcs/vcm/util/geometryHelpers.js +172 -0
  130. package/src/vcs/vcm/util/indexedCollection.js +158 -0
  131. package/src/vcs/vcm/util/isMobile.js +12 -0
  132. package/src/vcs/vcm/util/layerCollection.js +216 -0
  133. package/src/vcs/vcm/util/locale.js +53 -0
  134. package/src/vcs/vcm/util/mapCollection.js +363 -0
  135. package/src/vcs/vcm/util/math.js +71 -0
  136. package/src/vcs/vcm/util/projection.js +348 -0
  137. package/src/vcs/vcm/util/splitScreen.js +233 -0
  138. package/src/vcs/vcm/util/style/declarativeStyleItem.js +631 -0
  139. package/src/vcs/vcm/util/style/shapesCategory.js +67 -0
  140. package/src/vcs/vcm/util/style/styleFactory.js +48 -0
  141. package/src/vcs/vcm/util/style/styleHelpers.js +555 -0
  142. package/src/vcs/vcm/util/style/styleItem.js +226 -0
  143. package/src/vcs/vcm/util/style/vectorStyleItem.js +927 -0
  144. package/src/vcs/vcm/util/style/writeStyle.js +48 -0
  145. package/src/vcs/vcm/util/urlHelpers.js +16 -0
  146. package/src/vcs/vcm/util/viewpoint.js +333 -0
@@ -0,0 +1,205 @@
1
+ import { Math as CesiumMath } from '@vcmap/cesium';
2
+ import View from 'ol/View.js';
3
+ import { getTransform } from 'ol/proj.js';
4
+ import { inAndOut } from 'ol/easing.js';
5
+ import { boundingExtent, containsXY } from 'ol/extent.js';
6
+ import { parseBoolean } from '@vcsuite/parsers';
7
+ import ViewPoint from '../util/viewpoint.js';
8
+ import BaseOLMap from './baseOLMap.js';
9
+ import VcsMap from './map.js';
10
+ import { VcsClassRegistry } from '../classRegistry.js';
11
+
12
+ /**
13
+ * @typedef {VcsMapOptions} OpenlayersOptions
14
+ * @property {boolean} [fixedNorthOrientation=true] - sets whether the openlayers map has a fixed orientation towards north (default true)
15
+ * @api stable
16
+ */
17
+
18
+ /**
19
+ * Openlayers Map Class (2D map)
20
+ * @class
21
+ * @export
22
+ * @extends {BaseOLMap}
23
+ * @api stable
24
+ */
25
+ class Openlayers extends BaseOLMap {
26
+ /**
27
+ * @type {string}
28
+ */
29
+ static get className() { return 'vcs.vcm.maps.Openlayers'; }
30
+
31
+ /**
32
+ * @returns {OpenlayersOptions}
33
+ */
34
+ static getDefaultOptions() {
35
+ return {
36
+ ...VcsMap.getDefaultOptions(),
37
+ fixedNorthOrientation: true,
38
+ };
39
+ }
40
+
41
+ /**
42
+ * @param {OpenlayersOptions} options
43
+ */
44
+ constructor(options) {
45
+ super(options);
46
+
47
+ const defaultOptions = Openlayers.getDefaultOptions();
48
+
49
+ /** @type {boolean} */
50
+ this.fixedNorthOrientation = parseBoolean(options.fixedNorthOrientation, defaultOptions.fixedNorthOrientation);
51
+ }
52
+
53
+ /**
54
+ * @returns {Promise<void>}
55
+ */
56
+ async initialize() {
57
+ if (!this.initialized) {
58
+ await super.initialize();
59
+ this.olMap.setView(new View({
60
+ center: [1230922.6203948376, 6350766.117974091],
61
+ zoom: 13,
62
+ }));
63
+ this.initialized = true;
64
+ }
65
+ }
66
+
67
+ /**
68
+ * @inheritDoc
69
+ * @returns {Promise<ViewPoint>}
70
+ */
71
+ async getViewPoint() {
72
+ return this.getViewPointSync();
73
+ }
74
+
75
+ /**
76
+ * @inheritDoc
77
+ * @returns {ViewPoint}
78
+ */
79
+ getViewPointSync() {
80
+ const view = this.olMap.getView();
81
+ const coord = view.getCenter();
82
+ const toLatLon = getTransform(view.getProjection(), 'EPSG:4326');
83
+ const fov = Math.PI / 3.0;
84
+ const viewport = this.olMap.getViewport();
85
+ const size = {};
86
+ size.height = viewport.offsetHeight || 1;
87
+ size.width = viewport.offsetWidth || 1;
88
+ const aspectRatio = size.width / size.height;
89
+ const fovy = Math.atan(Math.tan(fov * 0.5) / aspectRatio) * 2.0;
90
+ const latlon = toLatLon(coord.slice(0, 2));
91
+ const metersPerUnit = view.getProjection().getMetersPerUnit();
92
+
93
+ const resolution = view.getResolution();
94
+ const visibleMapUnits = resolution * size.height;
95
+ const relativeCircumference = Math.cos(Math.abs(CesiumMath.toRadians(latlon[1])));
96
+ const visibleMeters = visibleMapUnits * metersPerUnit * relativeCircumference;
97
+ const height = Math.abs((visibleMeters / 2) / Math.tan(fovy / 2));
98
+
99
+ const heading = -CesiumMath.toDegrees(view.getRotation());
100
+ // don't add 0;
101
+ const groundPosition = latlon; // .concat([0]);
102
+ const pitch = -90;
103
+ return new ViewPoint({
104
+ groundPosition,
105
+ pitch,
106
+ heading,
107
+ distance: height,
108
+ });
109
+ }
110
+
111
+ /**
112
+ * @param {ViewPoint} viewpoint
113
+ * @returns {Promise<void>}
114
+ * @inheritDoc
115
+ */
116
+ gotoViewPoint(viewpoint) {
117
+ if (this.movementDisabled || !viewpoint.isValid()) {
118
+ return Promise.resolve();
119
+ }
120
+ if (this.fixedNorthOrientation) {
121
+ viewpoint.heading = 0;
122
+ }
123
+ const view = this.olMap.getView();
124
+ const fromLatLon = getTransform('EPSG:4326', view.getProjection());
125
+ let coords = [];
126
+ if (viewpoint.groundPosition) {
127
+ coords = viewpoint.groundPosition.slice(0, 2);
128
+ } else {
129
+ coords = viewpoint.cameraPosition.slice(0, 2);
130
+ }
131
+ const { distance } = viewpoint;
132
+ const center = fromLatLon(coords);
133
+
134
+ const fov = Math.PI / 3.0;
135
+ const viewport = this.olMap.getViewport();
136
+ const size = {};
137
+ size.height = viewport.offsetHeight ? viewport.offsetHeight : 1;
138
+ size.width = viewport.offsetWidth ? viewport.offsetWidth : 1;
139
+ const aspectRatio = size.width / size.height;
140
+ const fovy = Math.atan(Math.tan(fov * 0.5) / aspectRatio) * 2.0;
141
+ const visibleMeters = 2 * distance * Math.tan(fovy / 2);
142
+ const metersPerUnit = view.getProjection().getMetersPerUnit();
143
+ const relativeCircumference = Math.cos(Math.abs(CesiumMath.toRadians(coords[1])));
144
+ const visibleMapUnits = visibleMeters / metersPerUnit / relativeCircumference;
145
+
146
+ const resolution = visibleMapUnits / size.height;
147
+
148
+ if (viewpoint.animate) {
149
+ let rotation = 0;
150
+ if (!this.fixedNorthOrientation && viewpoint.heading != null) {
151
+ rotation = -CesiumMath.toRadians(viewpoint.heading);
152
+ }
153
+ return new Promise((resolve) => {
154
+ view.animate({
155
+ duration: viewpoint.duration ? viewpoint.duration * 1000 : 100,
156
+ center,
157
+ easing: inAndOut, // XXX map to viewpoint easingFunctionName?
158
+ resolution,
159
+ rotation,
160
+ }, () => { resolve(); });
161
+ });
162
+ } else {
163
+ view.setCenter(center);
164
+ view.setResolution(resolution);
165
+ if (!this.fixedNorthOrientation && viewpoint.heading != null) {
166
+ view.setRotation(-CesiumMath.toRadians(viewpoint.heading));
167
+ }
168
+ }
169
+ return Promise.resolve();
170
+ }
171
+
172
+ /**
173
+ * @param {import("ol/coordinate").Coordinate} coords in WGS84 degrees
174
+ * @returns {boolean}
175
+ * @api
176
+ */
177
+ pointIsVisible(coords) {
178
+ const view = this.olMap.getView();
179
+ const extent = view.calculateExtent(this.olMap.getSize());
180
+ const toLatLon = getTransform(view.getProjection(), 'EPSG:4326');
181
+ const topLeft = [extent[0], extent[3]];
182
+ const bottomRight = [extent[2], extent[1]];
183
+ const bbox = [toLatLon(topLeft), toLatLon(bottomRight)];
184
+
185
+ return containsXY(boundingExtent(bbox), coords[0], coords[1]);
186
+ }
187
+
188
+ /**
189
+ * @returns {OpenlayersOptions}
190
+ * @api
191
+ */
192
+ getConfigObject() {
193
+ const config = /** @type {OpenlayersOptions} */ (super.getConfigObject());
194
+
195
+ const defaultOptions = Openlayers.getDefaultOptions();
196
+ if (this.fixedNorthOrientation !== defaultOptions.fixedNorthOrientation) {
197
+ config.fixedNorthOrientation = this.fixedNorthOrientation;
198
+ }
199
+
200
+ return config;
201
+ }
202
+ }
203
+
204
+ VcsClassRegistry.registerClass(Openlayers.className, Openlayers);
205
+ export default Openlayers;
@@ -0,0 +1,92 @@
1
+ import { v4 as uuidv4 } from 'uuid';
2
+ import { getLogger } from '@vcsuite/logger';
3
+
4
+ /**
5
+ * @typedef {Object} VcsObjectOptions
6
+ * @property {string|undefined} [type] - the type of object, typically only used in configs
7
+ * @property {string|undefined} [name] - name of the object, if not given a uuid is generated, is used for the framework functions getObjectByName
8
+ * @property {Object|undefined} [properties] - key value store for framework independent values per Object
9
+ * @api
10
+ */
11
+
12
+ /**
13
+ * baseclass for all Objects
14
+ * @class
15
+ * @api stable
16
+ */
17
+ class VcsObject {
18
+ static get className() { return 'vcs.vcm.Framework'; }
19
+
20
+ /**
21
+ * @param {VcsObjectOptions} options
22
+ */
23
+ constructor(options) {
24
+ /**
25
+ * unique Name
26
+ * @type {string}
27
+ * @api
28
+ * @readonly
29
+ */
30
+ this.name = options.name || uuidv4();
31
+
32
+
33
+ /**
34
+ * @type {Object}
35
+ * @api
36
+ */
37
+ this.properties = options.properties || {};
38
+ }
39
+
40
+ /**
41
+ * @api
42
+ * @readonly
43
+ * @type {string}
44
+ */
45
+ get className() {
46
+ // @ts-ignore
47
+ return this.constructor.className;
48
+ }
49
+
50
+ /**
51
+ * @returns {import("@vcsuite/logger").Logger}
52
+ * @api
53
+ */
54
+ getLogger() {
55
+ return getLogger(this.className);
56
+ }
57
+
58
+ /**
59
+ * @returns {VcsObjectOptions}
60
+ * @api
61
+ */
62
+ getConfigObject() {
63
+ const config = {
64
+ type: this.className,
65
+ name: this.name,
66
+ };
67
+
68
+ if (Object.keys(this.properties).length > 0) {
69
+ config.properties = { ...this.properties };
70
+ }
71
+
72
+ return config;
73
+ }
74
+
75
+ /**
76
+ * @api
77
+ */
78
+ destroy() {
79
+ this.isDestroyed = true;
80
+ this.properties = {};
81
+ }
82
+
83
+ /**
84
+ * @deprecated v4.0
85
+ */
86
+ dispose() {
87
+ this.getLogger().deprecate('dispose', 'use destroy()');
88
+ this.destroy();
89
+ }
90
+ }
91
+
92
+ export default VcsObject;