@vcmap/core 5.0.0-rc.10 → 5.0.0-rc.13

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 (129) hide show
  1. package/index.d.ts +201 -125
  2. package/index.js +2 -3
  3. package/package.json +6 -2
  4. package/src/category/category.js +21 -5
  5. package/src/classRegistry.js +0 -6
  6. package/src/context.js +0 -1
  7. package/src/featureProvider/abstractFeatureProvider.js +0 -1
  8. package/src/featureProvider/wmsFeatureProvider.js +0 -1
  9. package/src/interaction/abstractInteraction.js +0 -1
  10. package/src/interaction/interactionChain.js +0 -1
  11. package/src/interaction/interactionType.js +1 -5
  12. package/src/layer/cesium/cesiumTilesetCesiumImpl.js +2 -3
  13. package/src/layer/cesium/dataSourceCesiumImpl.js +0 -1
  14. package/src/layer/cesium/openStreetMapCesiumImpl.js +0 -1
  15. package/src/layer/cesium/rasterLayerCesiumImpl.js +0 -1
  16. package/src/layer/cesium/singleImageCesiumImpl.js +0 -1
  17. package/src/layer/cesium/terrainCesiumImpl.js +0 -1
  18. package/src/layer/cesium/tmsCesiumImpl.js +0 -1
  19. package/src/layer/cesium/vectorCesiumImpl.js +3 -4
  20. package/src/layer/cesium/vectorRasterTileCesiumImpl.js +0 -1
  21. package/src/layer/cesium/vectorTileImageryProvider.js +0 -1
  22. package/src/layer/cesium/wmsCesiumImpl.js +0 -1
  23. package/src/layer/cesium/wmtsCesiumImpl.js +0 -1
  24. package/src/layer/cesiumTilesetLayer.js +0 -1
  25. package/src/layer/czmlLayer.js +0 -1
  26. package/src/layer/dataSourceLayer.js +25 -16
  27. package/src/layer/featureLayer.js +10 -1
  28. package/src/layer/featureStoreLayer.js +1 -1
  29. package/src/layer/featureStoreLayerState.js +0 -1
  30. package/src/layer/featureVisibility.js +3 -1
  31. package/src/layer/geojsonHelpers.js +0 -4
  32. package/src/layer/geojsonLayer.js +0 -1
  33. package/src/layer/globalHider.js +7 -21
  34. package/src/layer/layer.js +84 -38
  35. package/src/layer/layerImplementation.js +0 -1
  36. package/src/layer/layerState.js +0 -1
  37. package/src/layer/oblique/vectorObliqueImpl.js +1 -3
  38. package/src/layer/openStreetMapLayer.js +0 -1
  39. package/src/layer/openlayers/layerOpenlayersImpl.js +0 -1
  40. package/src/layer/openlayers/openStreetMapOpenlayersImpl.js +0 -1
  41. package/src/layer/openlayers/singleImageOpenlayersImpl.js +0 -1
  42. package/src/layer/openlayers/tileDebugOpenlayersImpl.js +0 -1
  43. package/src/layer/openlayers/tmsOpenlayersImpl.js +0 -1
  44. package/src/layer/openlayers/vectorOpenlayersImpl.js +2 -3
  45. package/src/layer/openlayers/vectorTileOpenlayersImpl.js +0 -1
  46. package/src/layer/openlayers/wmsOpenlayersImpl.js +0 -1
  47. package/src/layer/openlayers/wmtsOpenlayersImpl.js +0 -1
  48. package/src/layer/pointCloudLayer.js +0 -1
  49. package/src/layer/rasterLayer.js +0 -2
  50. package/src/layer/singleImageLayer.js +0 -1
  51. package/src/layer/terrainLayer.js +0 -1
  52. package/src/layer/tileProvider/mvtTileProvider.js +21 -2
  53. package/src/layer/tileProvider/staticGeojsonTileProvider.js +0 -1
  54. package/src/layer/tileProvider/tileProvider.js +27 -1
  55. package/src/layer/tileProvider/urlTemplateTileProvider.js +26 -6
  56. package/src/layer/tmsLayer.js +0 -1
  57. package/src/layer/vectorLayer.js +0 -1
  58. package/src/layer/vectorProperties.js +0 -1
  59. package/src/layer/vectorTileLayer.js +45 -13
  60. package/src/layer/wfsLayer.js +0 -1
  61. package/src/layer/wmsLayer.js +0 -1
  62. package/src/layer/wmtsLayer.js +0 -1
  63. package/src/map/baseOLMap.js +0 -1
  64. package/src/map/cameraLimiter.js +0 -1
  65. package/src/map/cesiumMap.js +0 -1
  66. package/src/map/mapState.js +0 -1
  67. package/src/map/obliqueMap.js +0 -1
  68. package/src/map/openlayersMap.js +0 -1
  69. package/src/map/vcsMap.js +6 -2
  70. package/src/oblique/helpers.js +0 -3
  71. package/src/oblique/obliqueCollection.js +0 -1
  72. package/src/oblique/obliqueDataSet.js +0 -2
  73. package/src/oblique/obliqueImage.js +0 -1
  74. package/src/oblique/obliqueImageMeta.js +0 -1
  75. package/src/oblique/obliqueProvider.js +0 -1
  76. package/src/oblique/obliqueView.js +0 -1
  77. package/src/oblique/obliqueViewDirection.js +0 -3
  78. package/src/ol/render/canvas/canvasTileRenderer.js +0 -1
  79. package/src/style/declarativeStyleItem.js +0 -1
  80. package/src/style/shapesCategory.js +0 -2
  81. package/src/style/styleHelpers.js +0 -11
  82. package/src/style/styleItem.js +0 -1
  83. package/src/style/vectorStyleItem.js +0 -4
  84. package/src/util/clipping/clippingObject.js +0 -2
  85. package/src/util/clipping/clippingObjectManager.js +0 -1
  86. package/src/util/clipping/clippingPlaneHelper.js +0 -4
  87. package/src/util/collection.js +15 -3
  88. package/src/util/extent.js +0 -1
  89. package/src/util/indexedCollection.js +0 -1
  90. package/src/util/layerCollection.js +71 -6
  91. package/src/util/locale.js +1 -42
  92. package/src/util/mapCollection.js +29 -14
  93. package/src/util/overrideCollection.js +8 -9
  94. package/src/util/projection.js +0 -5
  95. package/src/util/viewpoint.js +0 -4
  96. package/src/vcsApp.js +53 -0
  97. package/src/vcsEvent.js +0 -1
  98. package/tests/data/buildings/tileset.json +428 -0
  99. package/tests/data/dynamicPointCzml.json +64 -0
  100. package/tests/data/oblique/imageData/imagev34.json +352 -0
  101. package/tests/data/oblique/imageData/imagev35.json +54 -0
  102. package/tests/data/oblique/imageData/imagev35PerImageSize.json +53 -0
  103. package/tests/data/oblique/tiledImageData/12/2199/1342.json +1 -0
  104. package/tests/data/oblique/tiledImageData/12/2199/1343.json +1 -0
  105. package/tests/data/oblique/tiledImageData/12/2199/1344.json +1 -0
  106. package/tests/data/oblique/tiledImageData/12/2200/1342.json +1 -0
  107. package/tests/data/oblique/tiledImageData/12/2200/1343.json +1 -0
  108. package/tests/data/oblique/tiledImageData/12/2200/1344.json +1 -0
  109. package/tests/data/oblique/tiledImageData/12/2201/1342.json +1 -0
  110. package/tests/data/oblique/tiledImageData/12/2201/1343.json +1 -0
  111. package/tests/data/oblique/tiledImageData/12/2201/1344.json +1 -0
  112. package/tests/data/oblique/tiledImageData/image.json +1 -0
  113. package/tests/data/terrain/13/8800/6485.terrain +0 -0
  114. package/tests/data/terrain/13/8800/6486.terrain +0 -0
  115. package/tests/data/terrain/13/8801/6485.terrain +0 -0
  116. package/tests/data/terrain/13/8801/6486.terrain +0 -0
  117. package/tests/data/terrain/layer.json +136 -0
  118. package/tests/data/testGeoJSON.json +161 -0
  119. package/tests/data/tile.pbf +0 -0
  120. package/tests/unit/helpers/cesiumHelpers.js +272 -0
  121. package/tests/unit/helpers/getFileNameFromUrl.js +12 -0
  122. package/tests/unit/helpers/helpers.js +11 -0
  123. package/tests/unit/helpers/imageHelpers.js +20 -0
  124. package/tests/unit/helpers/importJSON.js +15 -0
  125. package/tests/unit/helpers/obliqueData.js +76 -0
  126. package/tests/unit/helpers/obliqueHelpers.js +112 -0
  127. package/tests/unit/helpers/openlayersHelpers.js +22 -0
  128. package/tests/unit/helpers/terrain/terrainData.js +46 -0
  129. package/src/util/dateTime.js +0 -60
@@ -0,0 +1,112 @@
1
+ import Projection from '../../../src/util/projection.js';
2
+ import ObliqueMap from '../../../src/map/obliqueMap.js';
3
+ import ViewPoint from '../../../src/util/viewpoint.js';
4
+
5
+ import { getTerrainProvider } from './terrain/terrainData.js';
6
+ import ObliqueCollection from '../../../src/oblique/obliqueCollection.js';
7
+ import ObliqueDataSet from '../../../src/oblique/obliqueDataSet.js';
8
+ import importJSON from './importJSON.js';
9
+ import getFileNameFromUrl from './getFileNameFromUrl.js';
10
+
11
+ const fileName = getFileNameFromUrl(import.meta.url, '../../../data/oblique/imageData/imagev35.json');
12
+ const imageJson = await importJSON(fileName);
13
+
14
+ /**
15
+ * Center point of first image
16
+ * @type {import("ol/coordinate").Coordinate}
17
+ */
18
+ export const mercatorCoordinates = [1488644.796500772, 6892246.018669462, 0];
19
+
20
+ /**
21
+ * cached oblique Projection
22
+ * @type {Projection}
23
+ */
24
+ let obliqueProjection = null;
25
+
26
+ /**
27
+ * @returns {ViewPoint}
28
+ */
29
+ function getStartingViewpoint() {
30
+ return new ViewPoint({
31
+ name: '5b609a0d-28a1-4f4e-ba6c-29f2592fa889',
32
+ distance: 264.6285087486175,
33
+ cameraPosition: null,
34
+ groundPosition: [
35
+ 13.41528061371218,
36
+ 52.50232648590358,
37
+ ],
38
+ heading: 0,
39
+ pitch: -90,
40
+ roll: 0,
41
+ animate: false,
42
+ });
43
+ }
44
+
45
+ /**
46
+ * returns an oblique Dataset
47
+ * @param {Scope=} scope if provided the dataset is initialized with a terrainProvider
48
+ * @returns {vcs-oblique/ObliqueDataSet}
49
+ */
50
+ export function getObliqueDataSet(scope) {
51
+ if (!obliqueProjection) {
52
+ obliqueProjection = new Projection({
53
+ epsg: 'EPSG:25833',
54
+ proj4: '+proj=utm +zone=33 +ellps=GRS80 +units=m +no_defs',
55
+ });
56
+ }
57
+ let terrainProvider;
58
+ if (scope) {
59
+ getTerrainProvider(scope);
60
+ terrainProvider = {
61
+ url: 'http://localhost/terrain/',
62
+ };
63
+ }
64
+ const obliqueDataSet = new ObliqueDataSet('http://localhost/', obliqueProjection, terrainProvider);
65
+ obliqueDataSet.initialize(imageJson);
66
+ return obliqueDataSet;
67
+ }
68
+
69
+
70
+ /**
71
+ * @param {Array<ObliqueDataSet>=} obliqueDataSets
72
+ * @returns {ObliqueCollection}
73
+ */
74
+ export function getObliqueCollection(obliqueDataSets) {
75
+ const dataSets = obliqueDataSets || [getObliqueDataSet()];
76
+ const obliqueCollection = new ObliqueCollection({
77
+ name: 'obliqueCollection',
78
+ dataSets,
79
+ });
80
+ return obliqueCollection;
81
+ }
82
+
83
+ /**
84
+ * @param {ObliqueOptions} mapOptions
85
+ * @param {Scope=} scope optional server, if provided the map will be initialized with a terrainProvider
86
+ * @returns {Promise<ObliqueMap>}
87
+ */
88
+ export async function getObliqueMap(mapOptions = {}, scope) {
89
+ const obliqueDataSet = getObliqueDataSet(scope);
90
+ const obliqueCollection = getObliqueCollection([obliqueDataSet]);
91
+ const map = new ObliqueMap(mapOptions);
92
+ await map.initialize();
93
+ await map.setCollection(obliqueCollection);
94
+ return map;
95
+ }
96
+
97
+ /**
98
+ * @param {VcsApp} app
99
+ * @param {Scope=} scope optional server, if provided the map will be initialized with a terrainProvider
100
+ * @param {ViewPoint=} startingVP
101
+ * @returns {Promise<ObliqueMap>}
102
+ */
103
+ export async function setObliqueMap(app, scope, startingVP) {
104
+ const map = await getObliqueMap(
105
+ { layerCollection: app.layers, target: app.maps.target },
106
+ scope,
107
+ );
108
+ app.maps.add(map);
109
+ await app.maps.setActiveMap(map.name);
110
+ await map.gotoViewPoint(startingVP || getStartingViewpoint());
111
+ return map;
112
+ }
@@ -0,0 +1,22 @@
1
+ import OpenlayersMap from '../../../src/map/openlayersMap.js';
2
+
3
+ /**
4
+ * @param {OpenlayersOptions=} mapOptions
5
+ * @returns {Promise<OpenlayersMap>}
6
+ */
7
+ export async function getOpenlayersMap(mapOptions) {
8
+ const map = new OpenlayersMap(mapOptions || {});
9
+ await map.initialize();
10
+ return map;
11
+ }
12
+
13
+ /**
14
+ * @param {VcsApp} app
15
+ * @returns {Promise<OpenlayersMap>}
16
+ */
17
+ export async function setOpenlayersMap(app) {
18
+ const map = await getOpenlayersMap({ layerCollection: app.layers, target: app.maps.target });
19
+ app.maps.add(map);
20
+ await app.maps.setActiveMap(map.name);
21
+ return map;
22
+ }
@@ -0,0 +1,46 @@
1
+ import fs from 'fs';
2
+ import { CesiumTerrainProvider } from '@vcmap/cesium';
3
+ import importJSON from '../importJSON.js';
4
+ import getFileNameFromUrl from '../getFileNameFromUrl.js';
5
+
6
+ const fileName = getFileNameFromUrl(import.meta.url, '../../../../data/terrain/layer.json');
7
+ const layerJson = await importJSON(fileName);
8
+ const terrainFiles = {
9
+ 1388006485: './tests/data/terrain/13/8800/6485.terrain',
10
+ 1388006486: './tests/data/terrain/13/8800/6486.terrain',
11
+ 1388016485: './tests/data/terrain/13/8801/6485.terrain',
12
+ 1388016486: './tests/data/terrain/13/8801/6486.terrain',
13
+ };
14
+
15
+ /**
16
+ * serves http://myTerrainProvider/terrain/
17
+ * @param {import("nock").Scope} scope
18
+ */
19
+ export function setTerrainServer(scope) {
20
+ scope
21
+ .get('/terrain/layer.json')
22
+ .reply(200, layerJson, { 'Content-Type': 'application/json' })
23
+ .get(/terrain\/(\d{2})\/(\d{4})\/(\d{4})\.terrain.*/)
24
+ .reply((uri) => {
25
+ const [x, y] = uri.match(/(\d{4})/g);
26
+ const terrainFile = terrainFiles[`13${x}${y}`];
27
+ const res = terrainFile ? fs.createReadStream(terrainFiles[`13${x}${y}`]) : Buffer.from('');
28
+ return [
29
+ 200,
30
+ res,
31
+ { 'Content-Type': 'application/vnd.quantized-mesh' },
32
+ ];
33
+ })
34
+ .persist();
35
+ }
36
+
37
+ /**
38
+ * @param {Scope} scope
39
+ * @returns {cesium/CesiumTerrainProvider}
40
+ */
41
+ export function getTerrainProvider(scope) {
42
+ setTerrainServer(scope);
43
+ return new CesiumTerrainProvider({
44
+ url: 'http://localhost/terrain/',
45
+ });
46
+ }
@@ -1,60 +0,0 @@
1
- /**
2
- * @param {Date} date
3
- * @param {string=} locale
4
- * @returns {string}
5
- */
6
- export function getShortLocaleDate(date, locale) {
7
- // dateStyle is not within the standard yet
8
- // @ts-ignore
9
- return new Intl.DateTimeFormat(locale, { dateStyle: 'short' }).format(date);
10
- }
11
-
12
- /**
13
- * @param {Date} date
14
- * @param {string=} locale
15
- * @returns {string}
16
- */
17
- export function getShortLocaleTime(date, locale) {
18
- // timeStyle is not within the standard yet
19
- // @ts-ignore
20
- return new Intl.DateTimeFormat(locale, { timeStyle: 'short' }).format(date);
21
- }
22
-
23
- /**
24
- * @param {Date} date
25
- * @returns {string}
26
- */
27
- export function getISODateString(date) {
28
- const month = date.getMonth() + 1;
29
- const day = date.getDate();
30
- return `${date.getFullYear()}-${month > 9 ? '' : 0}${month}-${day > 9 ? '' : 0}${day}`;
31
- }
32
-
33
- /**
34
- * @param {Date} date
35
- * @returns {number}
36
- */
37
- export function getDayOfYear(date) {
38
- const start = new Date(date.getFullYear(), 0, 0);
39
- // TS cant handle date manipulation
40
- // @ts-ignore
41
- const diff = (date - start) + ((start.getTimezoneOffset() - date.getTimezoneOffset()) * 60 * 1000);
42
- const oneDay = 1000 * 60 * 60 * 24;
43
- return Math.floor(diff / oneDay);
44
- }
45
-
46
- /**
47
- * @param {Date} date
48
- * @returns {boolean}
49
- */
50
- export function isLeapYear(date) {
51
- const currentYear = date.getFullYear();
52
- if (currentYear % 4 !== 0) {
53
- return false;
54
- } else if (currentYear % 100 !== 0) {
55
- return true;
56
- } else if (currentYear % 400 !== 0) {
57
- return false;
58
- }
59
- return true;
60
- }