@vcmap/core 5.0.0-rc.3 → 5.0.0-rc.31

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 (236) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +12 -5
  3. package/build/postinstall.js +14 -3
  4. package/index.d.ts +3480 -2008
  5. package/index.js +169 -131
  6. package/package.json +25 -27
  7. package/src/category/category.js +483 -0
  8. package/src/category/categoryCollection.js +153 -0
  9. package/src/cesium/cesium3DTileFeature.js +2 -2
  10. package/src/cesium/cesium3DTilePointFeature.js +1 -1
  11. package/src/cesium/cesiumVcsCameraPrimitive.js +16 -8
  12. package/src/cesium/entity.js +29 -0
  13. package/src/cesium/wallpaperMaterial.js +5 -3
  14. package/src/classRegistry.js +169 -0
  15. package/src/{vcs/vcm/util/featureProvider → featureProvider}/abstractFeatureProvider.js +49 -46
  16. package/src/{vcs/vcm/util/featureProvider → featureProvider}/tileProviderFeatureProvider.js +13 -5
  17. package/src/{vcs/vcm/util/featureProvider → featureProvider}/wmsFeatureProvider.js +56 -26
  18. package/src/{vcs/vcm/interaction → interaction}/abstractInteraction.js +33 -21
  19. package/src/{vcs/vcm/interaction → interaction}/coordinateAtPixel.js +40 -21
  20. package/src/{vcs/vcm/interaction → interaction}/eventHandler.js +131 -26
  21. package/src/{vcs/vcm/interaction → interaction}/featureAtPixelInteraction.js +108 -53
  22. package/src/interaction/featureProviderInteraction.js +58 -0
  23. package/src/{vcs/vcm/interaction → interaction}/interactionChain.js +40 -41
  24. package/src/{vcs/vcm/interaction → interaction}/interactionType.js +24 -31
  25. package/src/{vcs/vcm/layer/cesium/cesiumTilesetCesium.js → layer/cesium/cesiumTilesetCesiumImpl.js} +83 -70
  26. package/src/{vcs/vcm/layer → layer}/cesium/clusterContext.js +33 -8
  27. package/src/{vcs/vcm/layer/cesium/dataSourceCesium.js → layer/cesium/dataSourceCesiumImpl.js} +24 -13
  28. package/src/layer/cesium/openStreetMapCesiumImpl.js +32 -0
  29. package/src/{vcs/vcm/layer/cesium/rasterLayerCesium.js → layer/cesium/rasterLayerCesiumImpl.js} +12 -9
  30. package/src/{vcs/vcm/layer/cesium/singleImageCesium.js → layer/cesium/singleImageCesiumImpl.js} +19 -9
  31. package/src/{vcs/vcm/layer/cesium/terrainCesium.js → layer/cesium/terrainCesiumImpl.js} +8 -9
  32. package/src/{vcs/vcm/layer/cesium/tmsCesium.js → layer/cesium/tmsCesiumImpl.js} +21 -10
  33. package/src/{vcs/vcm/layer/cesium/vectorCesium.js → layer/cesium/vectorCesiumImpl.js} +93 -35
  34. package/src/layer/cesium/vectorContext.js +363 -0
  35. package/src/{vcs/vcm/layer/cesium/vectorRasterTileCesium.js → layer/cesium/vectorRasterTileCesiumImpl.js} +21 -13
  36. package/src/{vcs/vcm/layer → layer}/cesium/vectorTileImageryProvider.js +58 -21
  37. package/src/{vcs/vcm/layer/cesium/wmsCesium.js → layer/cesium/wmsCesiumImpl.js} +20 -9
  38. package/src/{vcs/vcm/layer/cesium/wmtsCesium.js → layer/cesium/wmtsCesiumImpl.js} +24 -13
  39. package/src/{vcs/vcm/layer → layer}/cesium/x3dmHelper.js +6 -3
  40. package/src/{vcs/vcm/layer/cesiumTileset.js → layer/cesiumTilesetLayer.js} +71 -112
  41. package/src/{vcs/vcm/layer/czml.js → layer/czmlLayer.js} +23 -20
  42. package/src/{vcs/vcm/layer/dataSource.js → layer/dataSourceLayer.js} +55 -90
  43. package/src/{vcs/vcm/layer → layer}/featureLayer.js +89 -74
  44. package/src/{vcs/vcm/layer/featureStore.js → layer/featureStoreLayer.js} +197 -150
  45. package/src/{vcs/vcm/layer/featureStoreChanges.js → layer/featureStoreLayerChanges.js} +150 -92
  46. package/src/{vcs/vcm/layer/featureStoreState.js → layer/featureStoreLayerState.js} +1 -2
  47. package/src/{vcs/vcm/layer → layer}/featureVisibility.js +114 -82
  48. package/src/{vcs/vcm/layer → layer}/geojsonHelpers.js +84 -69
  49. package/src/{vcs/vcm/layer/geojson.js → layer/geojsonLayer.js} +30 -27
  50. package/src/{vcs/vcm/layer → layer}/globalHider.js +25 -39
  51. package/src/{vcs/vcm/layer → layer}/layer.js +171 -96
  52. package/src/{vcs/vcm/layer → layer}/layerImplementation.js +13 -6
  53. package/src/{vcs/vcm/layer → layer}/layerState.js +0 -1
  54. package/src/{vcs/vcm/layer → layer}/layerSymbols.js +2 -1
  55. package/src/{vcs/vcm/layer/oblique/layerOblique.js → layer/oblique/layerObliqueImpl.js} +7 -5
  56. package/src/{vcs/vcm/layer → layer}/oblique/obliqueHelpers.js +76 -31
  57. package/src/{vcs/vcm/layer/oblique/vectorOblique.js → layer/oblique/vectorObliqueImpl.js} +198 -80
  58. package/src/{vcs/vcm/layer/openStreetMap.js → layer/openStreetMapLayer.js} +59 -40
  59. package/src/layer/openlayers/layerOpenlayersImpl.js +165 -0
  60. package/src/layer/openlayers/openStreetMapOpenlayersImpl.js +28 -0
  61. package/src/layer/openlayers/rasterLayerOpenlayersImpl.js +44 -0
  62. package/src/{vcs/vcm/layer/openlayers/singleImageOpenlayers.js → layer/openlayers/singleImageOpenlayersImpl.js} +8 -7
  63. package/src/{vcs/vcm/layer/openlayers/tileDebugOpenlayers.js → layer/openlayers/tileDebugOpenlayersImpl.js} +7 -6
  64. package/src/{vcs/vcm/layer/openlayers/tmsOpenlayers.js → layer/openlayers/tmsOpenlayersImpl.js} +12 -10
  65. package/src/{vcs/vcm/layer/openlayers/vectorOpenlayers.js → layer/openlayers/vectorOpenlayersImpl.js} +21 -12
  66. package/src/{vcs/vcm/layer/openlayers/vectorTileOpenlayers.js → layer/openlayers/vectorTileOpenlayersImpl.js} +18 -12
  67. package/src/{vcs/vcm/layer/openlayers/wmsOpenlayers.js → layer/openlayers/wmsOpenlayersImpl.js} +9 -8
  68. package/src/{vcs/vcm/layer/openlayers/wmtsOpenlayers.js → layer/openlayers/wmtsOpenlayersImpl.js} +19 -12
  69. package/src/{vcs/vcm/layer/pointCloud.js → layer/pointCloudLayer.js} +42 -39
  70. package/src/{vcs/vcm/layer → layer}/rasterLayer.js +86 -37
  71. package/src/{vcs/vcm/layer/singleImage.js → layer/singleImageLayer.js} +25 -22
  72. package/src/layer/terrainHelpers.js +95 -0
  73. package/src/{vcs/vcm/layer/terrain.js → layer/terrainLayer.js} +28 -21
  74. package/src/{vcs/vcm/layer → layer}/tileLoadedHelper.js +13 -8
  75. package/src/{vcs/vcm/layer → layer}/tileProvider/mvtTileProvider.js +51 -8
  76. package/src/layer/tileProvider/staticGeojsonTileProvider.js +87 -0
  77. package/src/{vcs/vcm/layer → layer}/tileProvider/tileProvider.js +200 -89
  78. package/src/{vcs/vcm/layer → layer}/tileProvider/urlTemplateTileProvider.js +54 -13
  79. package/src/{vcs/vcm/layer/tms.js → layer/tmsLayer.js} +22 -22
  80. package/src/layer/vectorHelpers.js +129 -0
  81. package/src/{vcs/vcm/layer/vector.js → layer/vectorLayer.js} +124 -94
  82. package/src/{vcs/vcm/layer → layer}/vectorProperties.js +419 -107
  83. package/src/{vcs/vcm/layer → layer}/vectorSymbols.js +11 -1
  84. package/src/{vcs/vcm/layer/vectorTile.js → layer/vectorTileLayer.js} +181 -116
  85. package/src/{vcs/vcm/layer/wfs.js → layer/wfsLayer.js} +33 -23
  86. package/src/{vcs/vcm/layer → layer}/wmsHelpers.js +14 -7
  87. package/src/{vcs/vcm/layer/wms.js → layer/wmsLayer.js} +53 -32
  88. package/src/{vcs/vcm/layer/wmts.js → layer/wmtsLayer.js} +56 -42
  89. package/src/{vcs/vcm/maps → map}/baseOLMap.js +83 -35
  90. package/src/{vcs/vcm/maps → map}/cameraLimiter.js +64 -37
  91. package/src/{vcs/vcm/maps/cesium.js → map/cesiumMap.js} +431 -277
  92. package/src/{vcs/vcm/maps → map}/mapState.js +0 -1
  93. package/src/{vcs/vcm/maps/oblique.js → map/obliqueMap.js} +132 -97
  94. package/src/{vcs/vcm/maps/openlayers.js → map/openlayersMap.js} +69 -45
  95. package/src/{vcs/vcm/maps/map.js → map/vcsMap.js} +118 -46
  96. package/src/oblique/defaultObliqueCollection.js +62 -0
  97. package/src/{vcs/vcm/oblique → oblique}/helpers.js +221 -78
  98. package/src/{vcs/vcm/oblique/ObliqueCollection.js → oblique/obliqueCollection.js} +151 -55
  99. package/src/{vcs/vcm/oblique/ObliqueDataSet.js → oblique/obliqueDataSet.js} +77 -46
  100. package/src/{vcs/vcm/oblique/ObliqueImage.js → oblique/obliqueImage.js} +58 -26
  101. package/src/{vcs/vcm/oblique/ObliqueImageMeta.js → oblique/obliqueImageMeta.js} +9 -9
  102. package/src/{vcs/vcm/oblique/ObliqueProvider.js → oblique/obliqueProvider.js} +85 -35
  103. package/src/{vcs/vcm/oblique/ObliqueView.js → oblique/obliqueView.js} +45 -5
  104. package/src/{vcs/vcm/oblique/ObliqueViewDirection.js → oblique/obliqueViewDirection.js} +3 -5
  105. package/src/{vcs/vcm/oblique → oblique}/parseImageJson.js +62 -28
  106. package/src/ol/feature.js +34 -1
  107. package/src/ol/geom/circle.js +14 -5
  108. package/src/ol/geom/geometryCollection.js +14 -8
  109. package/src/ol/render/canvas/canvasTileRenderer.js +11 -10
  110. package/src/overrideClassRegistry.js +214 -0
  111. package/src/style/arcStyle.js +453 -0
  112. package/src/style/arrowStyle.js +304 -0
  113. package/src/{vcs/vcm/util/style → style}/declarativeStyleItem.js +147 -82
  114. package/src/{vcs/vcm/util/style → style}/shapesCategory.js +8 -8
  115. package/src/style/styleFactory.js +32 -0
  116. package/src/{vcs/vcm/util/style → style}/styleHelpers.js +24 -26
  117. package/src/style/styleItem.js +174 -0
  118. package/src/{vcs/vcm/util/style → style}/vectorStyleItem.js +230 -156
  119. package/src/{vcs/vcm/util/style → style}/writeStyle.js +7 -12
  120. package/src/{vcs/vcm/util → util}/clipping/clippingObject.js +79 -49
  121. package/src/{vcs/vcm/util → util}/clipping/clippingObjectManager.js +56 -23
  122. package/src/{vcs/vcm/util → util}/clipping/clippingPlaneHelper.js +149 -88
  123. package/src/{vcs/vcm/util → util}/collection.js +28 -10
  124. package/src/util/editor/createFeatureSession.js +195 -0
  125. package/src/util/editor/editFeaturesSession.js +325 -0
  126. package/src/util/editor/editGeometrySession.js +452 -0
  127. package/src/util/editor/editorHelpers.js +300 -0
  128. package/src/util/editor/editorSessionHelpers.js +132 -0
  129. package/src/util/editor/editorSymbols.js +21 -0
  130. package/src/util/editor/interactions/createBBoxInteraction.js +154 -0
  131. package/src/util/editor/interactions/createCircleInteraction.js +119 -0
  132. package/src/util/editor/interactions/createLineStringInteraction.js +119 -0
  133. package/src/util/editor/interactions/createPointInteraction.js +73 -0
  134. package/src/util/editor/interactions/createPolygonInteraction.js +136 -0
  135. package/src/util/editor/interactions/editFeaturesMouseOverInteraction.js +88 -0
  136. package/src/util/editor/interactions/editGeometryMouseOverInteraction.js +119 -0
  137. package/src/util/editor/interactions/ensureHandlerSelectionInteraction.js +50 -0
  138. package/src/util/editor/interactions/insertVertexInteraction.js +103 -0
  139. package/src/util/editor/interactions/mapInteractionController.js +119 -0
  140. package/src/util/editor/interactions/removeVertexInteraction.js +42 -0
  141. package/src/util/editor/interactions/selectFeatureMouseOverInteraction.js +152 -0
  142. package/src/util/editor/interactions/selectMultiFeatureInteraction.js +165 -0
  143. package/src/util/editor/interactions/selectSingleFeatureInteraction.js +120 -0
  144. package/src/util/editor/interactions/translateVertexInteraction.js +60 -0
  145. package/src/util/editor/selectFeaturesSession.js +303 -0
  146. package/src/util/editor/transformation/create2DHandlers.js +339 -0
  147. package/src/util/editor/transformation/create3DHandlers.js +678 -0
  148. package/src/util/editor/transformation/extrudeInteraction.js +106 -0
  149. package/src/util/editor/transformation/rotateInteraction.js +201 -0
  150. package/src/util/editor/transformation/scaleInteraction.js +201 -0
  151. package/src/util/editor/transformation/transformationHandler.js +178 -0
  152. package/src/util/editor/transformation/transformationTypes.js +88 -0
  153. package/src/util/editor/transformation/translateInteraction.js +263 -0
  154. package/src/util/editor/validateGeoemetry.js +24 -0
  155. package/src/{vcs/vcm/util → util}/exclusiveManager.js +6 -3
  156. package/src/{vcs/vcm/util → util}/extent.js +26 -20
  157. package/src/util/featureconverter/arcToCesium.js +121 -0
  158. package/src/{vcs/vcm/util → util}/featureconverter/circleToCesium.js +70 -37
  159. package/src/{vcs/vcm/util → util}/featureconverter/convert.js +94 -16
  160. package/src/util/featureconverter/extent3D.js +284 -0
  161. package/src/{vcs/vcm/util → util}/featureconverter/featureconverterHelper.js +253 -94
  162. package/src/util/featureconverter/lineStringToCesium.js +343 -0
  163. package/src/util/featureconverter/pointHelpers.js +413 -0
  164. package/src/{vcs/vcm/util → util}/featureconverter/pointToCesium.js +157 -107
  165. package/src/{vcs/vcm/util → util}/featureconverter/polygonToCesium.js +57 -24
  166. package/src/util/fetch.js +34 -0
  167. package/src/{vcs/vcm/util → util}/geometryHelpers.js +25 -17
  168. package/src/{vcs/vcm/util → util}/indexedCollection.js +27 -8
  169. package/src/{vcs/vcm/util → util}/isMobile.js +8 -2
  170. package/src/{vcs/vcm/util → util}/layerCollection.js +109 -19
  171. package/src/util/locale.js +12 -0
  172. package/src/{vcs/vcm/util → util}/mapCollection.js +170 -63
  173. package/src/util/math.js +193 -0
  174. package/src/util/overrideCollection.js +261 -0
  175. package/src/{vcs/vcm/util → util}/projection.js +23 -31
  176. package/src/{vcs/vcm/util → util}/urlHelpers.js +5 -3
  177. package/src/{vcs/vcm/util → util}/viewpoint.js +83 -57
  178. package/src/vcsApp.js +657 -0
  179. package/src/{vcs/vcm/event/vcsEvent.js → vcsEvent.js} +2 -3
  180. package/src/vcsModule.js +130 -0
  181. package/src/vcsModuleHelpers.js +136 -0
  182. package/src/{vcs/vcm/object.js → vcsObject.js} +3 -10
  183. package/tests/data/dynamicPointCzml.json +53 -0
  184. package/tests/data/oblique/imageData/imagev34.json +136 -0
  185. package/tests/data/oblique/imageData/imagev35.json +307 -0
  186. package/tests/data/oblique/imageData/imagev35PerImageSize.json +333 -0
  187. package/tests/data/oblique/tiledImageData/12/2199/1342.json +11056 -0
  188. package/tests/data/oblique/tiledImageData/12/2199/1343.json +11236 -0
  189. package/tests/data/oblique/tiledImageData/12/2199/1344.json +11077 -0
  190. package/tests/data/oblique/tiledImageData/12/2200/1342.json +11036 -0
  191. package/tests/data/oblique/tiledImageData/12/2200/1343.json +11277 -0
  192. package/tests/data/oblique/tiledImageData/12/2200/1344.json +11131 -0
  193. package/tests/data/oblique/tiledImageData/12/2201/1342.json +10870 -0
  194. package/tests/data/oblique/tiledImageData/12/2201/1343.json +11492 -0
  195. package/tests/data/oblique/tiledImageData/12/2201/1344.json +10909 -0
  196. package/tests/data/oblique/tiledImageData/image.json +70 -0
  197. package/tests/data/terrain/13/8800/6485.terrain +0 -0
  198. package/tests/data/terrain/13/8800/6486.terrain +0 -0
  199. package/tests/data/terrain/13/8801/6485.terrain +0 -0
  200. package/tests/data/terrain/13/8801/6486.terrain +0 -0
  201. package/tests/data/terrain/layer.json +127 -0
  202. package/tests/data/testGeoJSON.json +149 -0
  203. package/tests/data/tile.pbf +0 -0
  204. package/tests/unit/helpers/cesiumHelpers.js +326 -0
  205. package/tests/unit/helpers/getFileNameFromUrl.js +12 -0
  206. package/tests/unit/helpers/helpers.js +32 -0
  207. package/tests/unit/helpers/imageHelpers.js +24 -0
  208. package/tests/unit/helpers/importJSON.js +15 -0
  209. package/tests/unit/helpers/obliqueData.js +102 -0
  210. package/tests/unit/helpers/obliqueHelpers.js +115 -0
  211. package/tests/unit/helpers/openlayersHelpers.js +25 -0
  212. package/tests/unit/helpers/terrain/terrainData.js +45 -0
  213. package/src/vcs/vcm/classRegistry.js +0 -106
  214. package/src/vcs/vcm/globalCollections.js +0 -11
  215. package/src/vcs/vcm/interaction/featureProviderInteraction.js +0 -54
  216. package/src/vcs/vcm/layer/buildings.js +0 -17
  217. package/src/vcs/vcm/layer/cesium/openStreetMapCesium.js +0 -29
  218. package/src/vcs/vcm/layer/cesium/pointCloudCesium.js +0 -58
  219. package/src/vcs/vcm/layer/cesium/vectorContext.js +0 -167
  220. package/src/vcs/vcm/layer/openlayers/layerOpenlayers.js +0 -79
  221. package/src/vcs/vcm/layer/openlayers/openStreetMapOpenlayers.js +0 -27
  222. package/src/vcs/vcm/layer/openlayers/rasterLayerOpenlayers.js +0 -121
  223. package/src/vcs/vcm/layer/terrainHelpers.js +0 -119
  224. package/src/vcs/vcm/layer/tileProvider/staticGeojsonTileProvider.js +0 -67
  225. package/src/vcs/vcm/layer/tileProvider/tileProviderFactory.js +0 -28
  226. package/src/vcs/vcm/layer/vectorHelpers.js +0 -206
  227. package/src/vcs/vcm/util/dateTime.js +0 -60
  228. package/src/vcs/vcm/util/featureProvider/featureProviderHelpers.js +0 -51
  229. package/src/vcs/vcm/util/featureconverter/extent3d.js +0 -154
  230. package/src/vcs/vcm/util/featureconverter/lineStringToCesium.js +0 -171
  231. package/src/vcs/vcm/util/locale.js +0 -53
  232. package/src/vcs/vcm/util/math.js +0 -71
  233. package/src/vcs/vcm/util/splitScreen.js +0 -233
  234. package/src/vcs/vcm/util/style/styleFactory.js +0 -48
  235. package/src/vcs/vcm/util/style/styleItem.js +0 -243
  236. /package/src/{vcs/vcm/util/featureProvider → featureProvider}/featureProviderSymbols.js +0 -0
@@ -1,19 +1,25 @@
1
1
  /* eslint no-underscore-dangle: ["error", { "allow": ["_listeners", "_scopes", "_toRemove"] }] */
2
2
  /* eslint-disable no-continue */
3
- import { boundingExtent, getBottomLeft, getBottomRight, getTopLeft, getTopRight } from 'ol/extent.js';
3
+ import {
4
+ boundingExtent,
5
+ getBottomLeft,
6
+ getBottomRight,
7
+ getTopLeft,
8
+ getTopRight,
9
+ } from 'ol/extent.js';
4
10
  import { transform } from 'ol/proj.js';
5
- import { Cartesian2 } from '@vcmap/cesium';
6
- import { ObliqueViewDirection } from './ObliqueViewDirection.js';
11
+ import { Cartesian2 } from '@vcmap-cesium/engine';
12
+ import { ObliqueViewDirection } from './obliqueViewDirection.js';
7
13
  import { getHeightFromTerrainProvider } from '../layer/terrainHelpers.js';
8
14
  import { cartesian2DDistance } from '../util/math.js';
9
15
  import { mercatorProjection, wgs84Projection } from '../util/projection.js';
10
16
 
11
17
  /**
12
- * @type {import("@vcmap/cesium").Cartesian2}
18
+ * @type {import("@vcmap-cesium/engine").Cartesian2}
13
19
  */
14
20
  let scratchCartesian2A = new Cartesian2();
15
21
  /**
16
- * @type {import("@vcmap/cesium").Cartesian2}
22
+ * @type {import("@vcmap-cesium/engine").Cartesian2}
17
23
  */
18
24
  let scratchCartesian2B = new Cartesian2();
19
25
 
@@ -32,7 +38,10 @@ let scratchCartesian2B = new Cartesian2();
32
38
  * @param {(ObliqueViewDirection|boolean)=} [sortDirection=false]
33
39
  * @returns {Array<import("ol/coordinate").Coordinate>}
34
40
  */
35
- export function sortRealWordEdgeCoordinates(inputCornerPoints, sortDirection = false) {
41
+ export function sortRealWordEdgeCoordinates(
42
+ inputCornerPoints,
43
+ sortDirection = false,
44
+ ) {
36
45
  const cornerPoints = inputCornerPoints.slice();
37
46
  const extent = boundingExtent(cornerPoints);
38
47
  const extentPoints = [
@@ -70,8 +79,16 @@ export function sortRealWordEdgeCoordinates(inputCornerPoints, sortDirection = f
70
79
  * @returns {number|null}
71
80
  */
72
81
  function angleBetweenTwo2DVectors(v1, v2) {
73
- scratchCartesian2A = Cartesian2.fromElements(v1[0], v1[1], scratchCartesian2A);
74
- scratchCartesian2B = Cartesian2.fromElements(v2[0], v2[1], scratchCartesian2B);
82
+ scratchCartesian2A = Cartesian2.fromElements(
83
+ v1[0],
84
+ v1[1],
85
+ scratchCartesian2A,
86
+ );
87
+ scratchCartesian2B = Cartesian2.fromElements(
88
+ v2[0],
89
+ v2[1],
90
+ scratchCartesian2B,
91
+ );
75
92
  return Cartesian2.angleBetween(scratchCartesian2A, scratchCartesian2B);
76
93
  }
77
94
 
@@ -80,7 +97,6 @@ function angleBetweenTwo2DVectors(v1, v2) {
80
97
  * @param {Array<import("ol/coordinate").Coordinate>} segment1
81
98
  * @param {Array<import("ol/coordinate").Coordinate>} segment2
82
99
  * @returns {{x: (number|null), y:(number|null), onLine1: boolean, onLine2: boolean}}
83
- * @export
84
100
  */
85
101
  export function checkLineIntersection(segment1, segment2) {
86
102
  // if the lines intersect, the result contains the x and y of the intersection (treating the lines as infinite) and booleans for whether line segment 1 or line segment 2 contain the point
@@ -97,22 +113,24 @@ export function checkLineIntersection(segment1, segment2) {
97
113
  };
98
114
 
99
115
  const denominator =
100
- ((line2EndY - line2StartY) * (line1EndX - line1StartX)) -
101
- ((line2EndX - line2StartX) * (line1EndY - line1StartY));
116
+ (line2EndY - line2StartY) * (line1EndX - line1StartX) -
117
+ (line2EndX - line2StartX) * (line1EndY - line1StartY);
102
118
 
103
119
  if (denominator === 0) {
104
120
  return result;
105
121
  }
106
122
  a = line1StartY - line2StartY;
107
123
  b = line1StartX - line2StartX;
108
- const numerator1 = ((line2EndX - line2StartX) * a) - ((line2EndY - line2StartY) * b);
109
- const numerator2 = ((line1EndX - line1StartX) * a) - ((line1EndY - line1StartY) * b);
124
+ const numerator1 =
125
+ (line2EndX - line2StartX) * a - (line2EndY - line2StartY) * b;
126
+ const numerator2 =
127
+ (line1EndX - line1StartX) * a - (line1EndY - line1StartY) * b;
110
128
  a = numerator1 / denominator;
111
129
  b = numerator2 / denominator;
112
130
 
113
131
  // if we cast these lines infinitely in both directions, they intersect here:
114
- result.x = line1StartX + (a * (line1EndX - line1StartX));
115
- result.y = line1StartY + (a * (line1EndY - line1StartY));
132
+ result.x = line1StartX + a * (line1EndX - line1StartX);
133
+ result.y = line1StartY + a * (line1EndY - line1StartY);
116
134
  /*
117
135
  // it is worth noting that this should be the same as:
118
136
  x = line2StartX + (b * (line2EndX - line2StartX));
@@ -139,9 +157,21 @@ export function checkLineIntersection(segment1, segment2) {
139
157
  * @param {ObliqueViewDirection} viewDirection
140
158
  * @returns {{x: (number|null), y:(number|null), onLine1: boolean, onLine2: boolean}|null}
141
159
  */
142
- export function transformCWIFC(inputOrigin, inputTarget, originIsImage, coordinate2Transform, viewDirection) {
143
- const origin = sortRealWordEdgeCoordinates(inputOrigin, originIsImage ? false : viewDirection);
144
- const target = sortRealWordEdgeCoordinates(inputTarget, originIsImage ? viewDirection : false);
160
+ export function transformCWIFC(
161
+ inputOrigin,
162
+ inputTarget,
163
+ originIsImage,
164
+ coordinate2Transform,
165
+ viewDirection,
166
+ ) {
167
+ const origin = sortRealWordEdgeCoordinates(
168
+ inputOrigin,
169
+ originIsImage ? false : viewDirection,
170
+ );
171
+ const target = sortRealWordEdgeCoordinates(
172
+ inputTarget,
173
+ originIsImage ? viewDirection : false,
174
+ );
145
175
 
146
176
  // test intersections from all corner points over coordinate to all non neighbouring borders
147
177
  // and non side borders too - so actually remains only upper and lower border
@@ -153,58 +183,110 @@ export function transformCWIFC(inputOrigin, inputTarget, originIsImage, coordina
153
183
  // - distance ratio while negative means negative direction
154
184
  // to be able to recreate the situation in the target system
155
185
  const intersections = [];
156
- for (let cp = 0; cp < origin.length; ++cp) { // TODO write into a proper map and function
186
+ for (let cp = 0; cp < origin.length; ++cp) {
187
+ // TODO write into a proper map and function
157
188
  const intrCurrCP = [];
158
189
 
159
190
  for (let sp = 0; sp < origin.length; ++sp) {
160
191
  const ep = sp === origin.length - 1 ? 0 : sp + 1; // end point of edge
161
192
 
162
193
  // skip if cp is sp or ep - neighbouring edge
163
- if (cp === sp || cp === ep) { continue; }
194
+ if (cp === sp || cp === ep) {
195
+ continue;
196
+ }
164
197
 
165
198
  // skip also if sp is 3 and ep is 0 and also skip sp is 1 and ep is 2 since does only work over the upper and lower boundary
166
- if ((sp === 3 && ep === 0) || (sp === 1 && ep === 2)) { continue; }
199
+ if ((sp === 3 && ep === 0) || (sp === 1 && ep === 2)) {
200
+ continue;
201
+ }
167
202
 
168
203
  // get intersection from cp over coordinate2Transform to current border edge
169
- const currIntr = checkLineIntersection([origin[cp], coordinate2Transform], [origin[sp], origin[ep]]);
170
- if (currIntr.x == null || currIntr.y == null) { continue; }
204
+ const currIntr = checkLineIntersection(
205
+ [origin[cp], coordinate2Transform],
206
+ [origin[sp], origin[ep]],
207
+ );
208
+ if (currIntr.x == null || currIntr.y == null) {
209
+ continue;
210
+ }
171
211
 
172
212
  // get vector from current cp to coordinate2Transform to be able to determine if the intersection is in same direction
173
213
  // might be in different direction when point is outside - then we dont need this data
174
- const vectorCP2Coordinate = [coordinate2Transform[0] - origin[cp][0], coordinate2Transform[1] - origin[cp][1]];
175
- const vectorCP2Intr = [currIntr.x - origin[cp][0], currIntr.y - origin[cp][1]];
176
- const angleDirectionCheck = angleBetweenTwo2DVectors(vectorCP2Coordinate, vectorCP2Intr);
177
- if (angleDirectionCheck == null) { continue; }
214
+ const vectorCP2Coordinate = [
215
+ coordinate2Transform[0] - origin[cp][0],
216
+ coordinate2Transform[1] - origin[cp][1],
217
+ ];
218
+ const vectorCP2Intr = [
219
+ currIntr.x - origin[cp][0],
220
+ currIntr.y - origin[cp][1],
221
+ ];
222
+ const angleDirectionCheck = angleBetweenTwo2DVectors(
223
+ vectorCP2Coordinate,
224
+ vectorCP2Intr,
225
+ );
226
+ if (angleDirectionCheck == null) {
227
+ continue;
228
+ }
178
229
 
179
- if (angleDirectionCheck / (Math.PI * 180.0) > 5) { continue; }
230
+ if (angleDirectionCheck / (Math.PI * 180.0) > 5) {
231
+ continue;
232
+ }
180
233
 
181
- const sp2ep = [origin[sp][0] - origin[ep][0], origin[sp][1] - origin[ep][1]];
182
- const ep2sp = [origin[ep][0] - origin[sp][0], origin[ep][1] - origin[sp][1]];
234
+ const sp2ep = [
235
+ origin[sp][0] - origin[ep][0],
236
+ origin[sp][1] - origin[ep][1],
237
+ ];
238
+ const ep2sp = [
239
+ origin[ep][0] - origin[sp][0],
240
+ origin[ep][1] - origin[sp][1],
241
+ ];
183
242
  // regarding the angle find the smallest
184
- const angleStart2End = angleBetweenTwo2DVectors(vectorCP2Coordinate, sp2ep);
185
- if (angleStart2End == null) { continue; }
243
+ const angleStart2End = angleBetweenTwo2DVectors(
244
+ vectorCP2Coordinate,
245
+ sp2ep,
246
+ );
247
+ if (angleStart2End == null) {
248
+ continue;
249
+ }
186
250
 
187
- const angleEnd2Start = angleBetweenTwo2DVectors(vectorCP2Coordinate, ep2sp);
188
- if (angleEnd2Start == null) { continue; }
251
+ const angleEnd2Start = angleBetweenTwo2DVectors(
252
+ vectorCP2Coordinate,
253
+ ep2sp,
254
+ );
255
+ if (angleEnd2Start == null) {
256
+ continue;
257
+ }
189
258
 
190
259
  // regarding ratioStart2End get ratio and then direction
191
260
  const distStartEnd = cartesian2DDistance(origin[sp], origin[ep]);
192
- if (distStartEnd === 0) { continue; }
193
- const tempRatioStartEnd = cartesian2DDistance(origin[sp], [currIntr.x, currIntr.y]) / distStartEnd;
261
+ if (distStartEnd === 0) {
262
+ continue;
263
+ }
264
+ const tempRatioStartEnd =
265
+ cartesian2DDistance(origin[sp], [currIntr.x, currIntr.y]) /
266
+ distStartEnd;
194
267
  let angleEdge2Intr = 0;
195
268
  if (tempRatioStartEnd !== 0) {
196
- angleEdge2Intr = angleBetweenTwo2DVectors(ep2sp, [currIntr.x - origin[sp][0], currIntr.y - origin[sp][1]]);
197
- if (angleEdge2Intr == null) { continue; }
269
+ angleEdge2Intr = angleBetweenTwo2DVectors(ep2sp, [
270
+ currIntr.x - origin[sp][0],
271
+ currIntr.y - origin[sp][1],
272
+ ]);
273
+ if (angleEdge2Intr == null) {
274
+ continue;
275
+ }
198
276
  }
199
277
 
200
278
  intrCurrCP.push({
201
279
  cornerPoint: cp,
202
280
  intrX: currIntr.x,
203
281
  intrY: currIntr.y,
204
- angle: angleStart2End <= angleEnd2Start ? angleStart2End : angleEnd2Start,
282
+ angle:
283
+ angleStart2End <= angleEnd2Start ? angleStart2End : angleEnd2Start,
205
284
  edgeStart: sp,
206
285
  edgeEnd: ep,
207
- ratioStart2End: (angleEdge2Intr / Math.PI) * 180.0 > 5 ? tempRatioStartEnd * (-1) : tempRatioStartEnd,
286
+ ratioStart2End:
287
+ (angleEdge2Intr / Math.PI) * 180.0 > 5
288
+ ? tempRatioStartEnd * -1
289
+ : tempRatioStartEnd,
208
290
  });
209
291
  }
210
292
 
@@ -217,11 +299,15 @@ export function transformCWIFC(inputOrigin, inputTarget, originIsImage, coordina
217
299
  indLargestAngle = i;
218
300
  }
219
301
  }
220
- if (indLargestAngle !== -1) { intersections.push(intrCurrCP[indLargestAngle]); }
302
+ if (indLargestAngle !== -1) {
303
+ intersections.push(intrCurrCP[indLargestAngle]);
304
+ }
221
305
  }
222
306
 
223
307
  // if we don not have enough data to recreate the situation in target system stop
224
- if (intersections.length < 2) { return null; }
308
+ if (intersections.length < 2) {
309
+ return null;
310
+ }
225
311
 
226
312
  // make list with intersection combinations and sort after strength (add angles together)
227
313
  const intrCombis = []; // will contain [addedAngle, intersectionsIndex_i, intersectionsIndex_j]
@@ -236,7 +322,10 @@ export function transformCWIFC(inputOrigin, inputTarget, originIsImage, coordina
236
322
  .sort()
237
323
  .reverse()
238
324
  .find((intersection) => {
239
- const intersectionsSorted = [intersections[intersection[1]], intersections[intersection[2]]];
325
+ const intersectionsSorted = [
326
+ intersections[intersection[1]],
327
+ intersections[intersection[2]],
328
+ ];
240
329
 
241
330
  const targetEdgeEnd0 = target[intersectionsSorted[0].edgeEnd];
242
331
  const targetEdgeStart0 = target[intersectionsSorted[0].edgeStart];
@@ -247,17 +336,24 @@ export function transformCWIFC(inputOrigin, inputTarget, originIsImage, coordina
247
336
  ];
248
337
 
249
338
  const intrFor0InTarget = [
250
- targetEdgeStart0[0] + (targetEdgeVectorFor0[0] * intersectionsSorted[0].ratioStart2End),
251
- targetEdgeStart0[1] + (targetEdgeVectorFor0[1] * intersectionsSorted[0].ratioStart2End),
339
+ targetEdgeStart0[0] +
340
+ targetEdgeVectorFor0[0] * intersectionsSorted[0].ratioStart2End,
341
+ targetEdgeStart0[1] +
342
+ targetEdgeVectorFor0[1] * intersectionsSorted[0].ratioStart2End,
252
343
  ];
253
344
 
254
345
  const targetEdgeEnd1 = target[intersectionsSorted[1].edgeEnd];
255
346
  const targetEdgeStart1 = target[intersectionsSorted[1].edgeStart];
256
347
 
257
- const targetEdgeVectorFor1 = [targetEdgeEnd1[0] - targetEdgeStart1[0], targetEdgeEnd1[1] - targetEdgeStart1[1]];
348
+ const targetEdgeVectorFor1 = [
349
+ targetEdgeEnd1[0] - targetEdgeStart1[0],
350
+ targetEdgeEnd1[1] - targetEdgeStart1[1],
351
+ ];
258
352
  const intrFor1InTarget = [
259
- targetEdgeStart1[0] + (targetEdgeVectorFor1[0] * intersectionsSorted[1].ratioStart2End),
260
- targetEdgeStart1[1] + (targetEdgeVectorFor1[1] * intersectionsSorted[1].ratioStart2End),
353
+ targetEdgeStart1[0] +
354
+ targetEdgeVectorFor1[0] * intersectionsSorted[1].ratioStart2End,
355
+ targetEdgeStart1[1] +
356
+ targetEdgeVectorFor1[1] * intersectionsSorted[1].ratioStart2End,
261
357
  ];
262
358
 
263
359
  const vecCP0ToIntr0 = [
@@ -270,7 +366,9 @@ export function transformCWIFC(inputOrigin, inputTarget, originIsImage, coordina
270
366
  ];
271
367
 
272
368
  const angleCross = angleBetweenTwo2DVectors(vecCP0ToIntr0, vecCP1ToIntr1);
273
- if (angleCross == null) { return false; }
369
+ if (angleCross == null) {
370
+ return false;
371
+ }
274
372
  /* var thresholdInDegree = 3;
275
373
  if (angleCross/Math.PI*180.0 < thresholdInDegree || angleCross/Math.PI*180.0 > 180-thresholdInDegree)
276
374
  continue; */
@@ -306,16 +404,26 @@ export function transformCWIFC(inputOrigin, inputTarget, originIsImage, coordina
306
404
  * @param {import("ol/coordinate").Coordinate} worldCoordinate if not in web mercatpr, specify data-projection in options
307
405
  * @param {ImageTransformationOptions=} options
308
406
  * @returns {Promise<{coords: import("ol/coordinate").Coordinate, height: number, estimate: (boolean|undefined)}>}
309
- * @export
310
407
  */
311
408
  export function transformToImage(image, worldCoordinate, options = {}) {
312
409
  let gpInternalCoordinates;
313
- if (options.dataProjection && options.dataProjection === image.meta.projection) {
410
+ if (
411
+ options.dataProjection &&
412
+ options.dataProjection === image.meta.projection
413
+ ) {
314
414
  gpInternalCoordinates = worldCoordinate;
315
415
  } else {
316
- gpInternalCoordinates = options.dataProjection ?
317
- transform(worldCoordinate, options.dataProjection.proj, image.meta.projection.proj) :
318
- transform(worldCoordinate, mercatorProjection.proj, image.meta.projection.proj);
416
+ gpInternalCoordinates = options.dataProjection
417
+ ? transform(
418
+ worldCoordinate,
419
+ options.dataProjection.proj,
420
+ image.meta.projection.proj,
421
+ )
422
+ : transform(
423
+ worldCoordinate,
424
+ mercatorProjection.proj,
425
+ image.meta.projection.proj,
426
+ );
319
427
  }
320
428
 
321
429
  function useAverageHeight() {
@@ -324,19 +432,39 @@ export function transformToImage(image, worldCoordinate, options = {}) {
324
432
  }
325
433
 
326
434
  if (worldCoordinate[2]) {
327
- const coords = image.transformRealWorld2Image(gpInternalCoordinates, worldCoordinate[2]);
328
- return Promise.resolve({ coords, height: worldCoordinate[2], estimate: false });
435
+ const coords = image.transformRealWorld2Image(
436
+ gpInternalCoordinates,
437
+ worldCoordinate[2],
438
+ );
439
+ return Promise.resolve({
440
+ coords,
441
+ height: worldCoordinate[2],
442
+ estimate: false,
443
+ });
329
444
  }
330
445
 
331
446
  if (!options.dontUseTerrain && image.meta.terrainProvider) {
332
- return getHeightFromTerrainProvider(image.meta.terrainProvider, [gpInternalCoordinates], image.meta.projection)
447
+ return getHeightFromTerrainProvider(
448
+ image.meta.terrainProvider,
449
+ [gpInternalCoordinates],
450
+ image.meta.projection,
451
+ )
333
452
  .then(([gpWithHeight]) => {
334
453
  if (gpWithHeight[2]) {
335
- const imageCoordinates = image.transformRealWorld2Image(gpInternalCoordinates, gpWithHeight[2]);
336
- return { coords: imageCoordinates, height: gpInternalCoordinates[2], estimate: false };
454
+ const imageCoordinates = image.transformRealWorld2Image(
455
+ gpInternalCoordinates,
456
+ gpWithHeight[2],
457
+ );
458
+ return {
459
+ coords: imageCoordinates,
460
+ height: gpInternalCoordinates[2],
461
+ estimate: false,
462
+ };
337
463
  }
338
464
  // eslint-disable-next-line no-console
339
- console.warn('The configured terrain on the oblique layer could not be queried, position might be inaccurate');
465
+ console.warn(
466
+ 'The configured terrain on the oblique layer could not be queried, position might be inaccurate',
467
+ );
340
468
  return useAverageHeight();
341
469
  })
342
470
  .catch(() => useAverageHeight());
@@ -371,18 +499,24 @@ function pickTerrain(pickTerrainOptions) {
371
499
  height,
372
500
  } = pickTerrainOptions;
373
501
 
374
- return getHeightFromTerrainProvider(image.meta.terrainProvider, [worldCoordinate])
502
+ return getHeightFromTerrainProvider(image.meta.terrainProvider, [
503
+ worldCoordinate,
504
+ ])
375
505
  .then(([worldCoordinateWithHeights]) => {
376
506
  if (worldCoordinateWithHeights[2] != null) {
377
507
  const newWorldCoords = transform(
378
- image.transformImage2RealWorld(imageCoordinate, worldCoordinateWithHeights[2]),
508
+ image.transformImage2RealWorld(
509
+ imageCoordinate,
510
+ worldCoordinateWithHeights[2],
511
+ ),
379
512
  image.meta.projection.proj,
380
513
  wgs84Projection.proj,
381
514
  );
382
515
  newWorldCoords[2] = worldCoordinateWithHeights[2];
383
516
  if (
384
- Math.abs(height - worldCoordinateWithHeights[2]) < terrainErrorThreshold ||
385
- (count > terrainErrorCountThreshold)
517
+ Math.abs(height - worldCoordinateWithHeights[2]) <
518
+ terrainErrorThreshold ||
519
+ count > terrainErrorCountThreshold
386
520
  ) {
387
521
  return { coords: newWorldCoords, estimate: false };
388
522
  }
@@ -391,7 +525,9 @@ function pickTerrain(pickTerrainOptions) {
391
525
  return pickTerrain(pickTerrainOptions);
392
526
  }
393
527
  // eslint-disable-next-line no-console
394
- console.log('The configured terrain on the oblique layer could not be queried, position might be inaccurate');
528
+ console.log(
529
+ 'The configured terrain on the oblique layer could not be queried, position might be inaccurate',
530
+ );
395
531
  return { coords: worldCoordinateWithHeights, estimate: true };
396
532
  })
397
533
  .catch(() => ({ coords: worldCoordinate, estimate: true }));
@@ -404,7 +540,6 @@ function pickTerrain(pickTerrainOptions) {
404
540
  * @param {import("ol/coordinate").Coordinate} imageCoordinate
405
541
  * @param {ImageTransformationOptions=} options
406
542
  * @returns {Promise<PickTerrainReturn>} return coordinates are in mercator if not specified in options
407
- * @export
408
543
  */
409
544
  export async function transformFromImage(image, imageCoordinate, options = {}) {
410
545
  const initialWorldCoords = transform(
@@ -429,9 +564,17 @@ export async function transformFromImage(image, imageCoordinate, options = {}) {
429
564
  });
430
565
  }
431
566
 
432
- coordsObj.coords = options.dataProjection ?
433
- transform(coordsObj.coords, wgs84Projection.proj, options.dataProjection.proj) :
434
- transform(coordsObj.coords, wgs84Projection.proj, mercatorProjection.proj);
567
+ coordsObj.coords = options.dataProjection
568
+ ? transform(
569
+ coordsObj.coords,
570
+ wgs84Projection.proj,
571
+ options.dataProjection.proj,
572
+ )
573
+ : transform(
574
+ coordsObj.coords,
575
+ wgs84Projection.proj,
576
+ mercatorProjection.proj,
577
+ );
435
578
  return coordsObj;
436
579
  }
437
580
 
@@ -440,16 +583,16 @@ export async function transformFromImage(image, imageCoordinate, options = {}) {
440
583
  * @returns {boolean}
441
584
  */
442
585
  export function hasSameOrigin(url) {
443
- // relative Url, return true;
444
- if (!/^[a-z][a-z0-9+.-]*:/.test(url)) {
445
- return true;
446
- }
447
- // data uri, return true
448
- if (/^data:/.test(url)) {
586
+ const windowUrl = new URL(window.location.href);
587
+ const parsedUrl = new URL(url, window.location.href);
588
+
589
+ if (parsedUrl.protocol === 'data:') {
449
590
  return true;
450
591
  }
451
592
 
452
- const currentUri = new URL(window.location.href);
453
- const uri = new URL(url);
454
- return currentUri.host.toLowerCase() === uri.host.toLocaleLowerCase();
593
+ return (
594
+ windowUrl.origin === parsedUrl.origin &&
595
+ windowUrl.port === parsedUrl.port &&
596
+ windowUrl.protocol === parsedUrl.protocol
597
+ );
455
598
  }