@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.
- package/LICENSE.md +1 -1
- package/README.md +12 -5
- package/build/postinstall.js +14 -3
- package/index.d.ts +3480 -2008
- package/index.js +169 -131
- package/package.json +25 -27
- package/src/category/category.js +483 -0
- package/src/category/categoryCollection.js +153 -0
- package/src/cesium/cesium3DTileFeature.js +2 -2
- package/src/cesium/cesium3DTilePointFeature.js +1 -1
- package/src/cesium/cesiumVcsCameraPrimitive.js +16 -8
- package/src/cesium/entity.js +29 -0
- package/src/cesium/wallpaperMaterial.js +5 -3
- package/src/classRegistry.js +169 -0
- package/src/{vcs/vcm/util/featureProvider → featureProvider}/abstractFeatureProvider.js +49 -46
- package/src/{vcs/vcm/util/featureProvider → featureProvider}/tileProviderFeatureProvider.js +13 -5
- package/src/{vcs/vcm/util/featureProvider → featureProvider}/wmsFeatureProvider.js +56 -26
- package/src/{vcs/vcm/interaction → interaction}/abstractInteraction.js +33 -21
- package/src/{vcs/vcm/interaction → interaction}/coordinateAtPixel.js +40 -21
- package/src/{vcs/vcm/interaction → interaction}/eventHandler.js +131 -26
- package/src/{vcs/vcm/interaction → interaction}/featureAtPixelInteraction.js +108 -53
- package/src/interaction/featureProviderInteraction.js +58 -0
- package/src/{vcs/vcm/interaction → interaction}/interactionChain.js +40 -41
- package/src/{vcs/vcm/interaction → interaction}/interactionType.js +24 -31
- package/src/{vcs/vcm/layer/cesium/cesiumTilesetCesium.js → layer/cesium/cesiumTilesetCesiumImpl.js} +83 -70
- package/src/{vcs/vcm/layer → layer}/cesium/clusterContext.js +33 -8
- package/src/{vcs/vcm/layer/cesium/dataSourceCesium.js → layer/cesium/dataSourceCesiumImpl.js} +24 -13
- package/src/layer/cesium/openStreetMapCesiumImpl.js +32 -0
- package/src/{vcs/vcm/layer/cesium/rasterLayerCesium.js → layer/cesium/rasterLayerCesiumImpl.js} +12 -9
- package/src/{vcs/vcm/layer/cesium/singleImageCesium.js → layer/cesium/singleImageCesiumImpl.js} +19 -9
- package/src/{vcs/vcm/layer/cesium/terrainCesium.js → layer/cesium/terrainCesiumImpl.js} +8 -9
- package/src/{vcs/vcm/layer/cesium/tmsCesium.js → layer/cesium/tmsCesiumImpl.js} +21 -10
- package/src/{vcs/vcm/layer/cesium/vectorCesium.js → layer/cesium/vectorCesiumImpl.js} +93 -35
- package/src/layer/cesium/vectorContext.js +363 -0
- package/src/{vcs/vcm/layer/cesium/vectorRasterTileCesium.js → layer/cesium/vectorRasterTileCesiumImpl.js} +21 -13
- package/src/{vcs/vcm/layer → layer}/cesium/vectorTileImageryProvider.js +58 -21
- package/src/{vcs/vcm/layer/cesium/wmsCesium.js → layer/cesium/wmsCesiumImpl.js} +20 -9
- package/src/{vcs/vcm/layer/cesium/wmtsCesium.js → layer/cesium/wmtsCesiumImpl.js} +24 -13
- package/src/{vcs/vcm/layer → layer}/cesium/x3dmHelper.js +6 -3
- package/src/{vcs/vcm/layer/cesiumTileset.js → layer/cesiumTilesetLayer.js} +71 -112
- package/src/{vcs/vcm/layer/czml.js → layer/czmlLayer.js} +23 -20
- package/src/{vcs/vcm/layer/dataSource.js → layer/dataSourceLayer.js} +55 -90
- package/src/{vcs/vcm/layer → layer}/featureLayer.js +89 -74
- package/src/{vcs/vcm/layer/featureStore.js → layer/featureStoreLayer.js} +197 -150
- package/src/{vcs/vcm/layer/featureStoreChanges.js → layer/featureStoreLayerChanges.js} +150 -92
- package/src/{vcs/vcm/layer/featureStoreState.js → layer/featureStoreLayerState.js} +1 -2
- package/src/{vcs/vcm/layer → layer}/featureVisibility.js +114 -82
- package/src/{vcs/vcm/layer → layer}/geojsonHelpers.js +84 -69
- package/src/{vcs/vcm/layer/geojson.js → layer/geojsonLayer.js} +30 -27
- package/src/{vcs/vcm/layer → layer}/globalHider.js +25 -39
- package/src/{vcs/vcm/layer → layer}/layer.js +171 -96
- package/src/{vcs/vcm/layer → layer}/layerImplementation.js +13 -6
- package/src/{vcs/vcm/layer → layer}/layerState.js +0 -1
- package/src/{vcs/vcm/layer → layer}/layerSymbols.js +2 -1
- package/src/{vcs/vcm/layer/oblique/layerOblique.js → layer/oblique/layerObliqueImpl.js} +7 -5
- package/src/{vcs/vcm/layer → layer}/oblique/obliqueHelpers.js +76 -31
- package/src/{vcs/vcm/layer/oblique/vectorOblique.js → layer/oblique/vectorObliqueImpl.js} +198 -80
- package/src/{vcs/vcm/layer/openStreetMap.js → layer/openStreetMapLayer.js} +59 -40
- package/src/layer/openlayers/layerOpenlayersImpl.js +165 -0
- package/src/layer/openlayers/openStreetMapOpenlayersImpl.js +28 -0
- package/src/layer/openlayers/rasterLayerOpenlayersImpl.js +44 -0
- package/src/{vcs/vcm/layer/openlayers/singleImageOpenlayers.js → layer/openlayers/singleImageOpenlayersImpl.js} +8 -7
- package/src/{vcs/vcm/layer/openlayers/tileDebugOpenlayers.js → layer/openlayers/tileDebugOpenlayersImpl.js} +7 -6
- package/src/{vcs/vcm/layer/openlayers/tmsOpenlayers.js → layer/openlayers/tmsOpenlayersImpl.js} +12 -10
- package/src/{vcs/vcm/layer/openlayers/vectorOpenlayers.js → layer/openlayers/vectorOpenlayersImpl.js} +21 -12
- package/src/{vcs/vcm/layer/openlayers/vectorTileOpenlayers.js → layer/openlayers/vectorTileOpenlayersImpl.js} +18 -12
- package/src/{vcs/vcm/layer/openlayers/wmsOpenlayers.js → layer/openlayers/wmsOpenlayersImpl.js} +9 -8
- package/src/{vcs/vcm/layer/openlayers/wmtsOpenlayers.js → layer/openlayers/wmtsOpenlayersImpl.js} +19 -12
- package/src/{vcs/vcm/layer/pointCloud.js → layer/pointCloudLayer.js} +42 -39
- package/src/{vcs/vcm/layer → layer}/rasterLayer.js +86 -37
- package/src/{vcs/vcm/layer/singleImage.js → layer/singleImageLayer.js} +25 -22
- package/src/layer/terrainHelpers.js +95 -0
- package/src/{vcs/vcm/layer/terrain.js → layer/terrainLayer.js} +28 -21
- package/src/{vcs/vcm/layer → layer}/tileLoadedHelper.js +13 -8
- package/src/{vcs/vcm/layer → layer}/tileProvider/mvtTileProvider.js +51 -8
- package/src/layer/tileProvider/staticGeojsonTileProvider.js +87 -0
- package/src/{vcs/vcm/layer → layer}/tileProvider/tileProvider.js +200 -89
- package/src/{vcs/vcm/layer → layer}/tileProvider/urlTemplateTileProvider.js +54 -13
- package/src/{vcs/vcm/layer/tms.js → layer/tmsLayer.js} +22 -22
- package/src/layer/vectorHelpers.js +129 -0
- package/src/{vcs/vcm/layer/vector.js → layer/vectorLayer.js} +124 -94
- package/src/{vcs/vcm/layer → layer}/vectorProperties.js +419 -107
- package/src/{vcs/vcm/layer → layer}/vectorSymbols.js +11 -1
- package/src/{vcs/vcm/layer/vectorTile.js → layer/vectorTileLayer.js} +181 -116
- package/src/{vcs/vcm/layer/wfs.js → layer/wfsLayer.js} +33 -23
- package/src/{vcs/vcm/layer → layer}/wmsHelpers.js +14 -7
- package/src/{vcs/vcm/layer/wms.js → layer/wmsLayer.js} +53 -32
- package/src/{vcs/vcm/layer/wmts.js → layer/wmtsLayer.js} +56 -42
- package/src/{vcs/vcm/maps → map}/baseOLMap.js +83 -35
- package/src/{vcs/vcm/maps → map}/cameraLimiter.js +64 -37
- package/src/{vcs/vcm/maps/cesium.js → map/cesiumMap.js} +431 -277
- package/src/{vcs/vcm/maps → map}/mapState.js +0 -1
- package/src/{vcs/vcm/maps/oblique.js → map/obliqueMap.js} +132 -97
- package/src/{vcs/vcm/maps/openlayers.js → map/openlayersMap.js} +69 -45
- package/src/{vcs/vcm/maps/map.js → map/vcsMap.js} +118 -46
- package/src/oblique/defaultObliqueCollection.js +62 -0
- package/src/{vcs/vcm/oblique → oblique}/helpers.js +221 -78
- package/src/{vcs/vcm/oblique/ObliqueCollection.js → oblique/obliqueCollection.js} +151 -55
- package/src/{vcs/vcm/oblique/ObliqueDataSet.js → oblique/obliqueDataSet.js} +77 -46
- package/src/{vcs/vcm/oblique/ObliqueImage.js → oblique/obliqueImage.js} +58 -26
- package/src/{vcs/vcm/oblique/ObliqueImageMeta.js → oblique/obliqueImageMeta.js} +9 -9
- package/src/{vcs/vcm/oblique/ObliqueProvider.js → oblique/obliqueProvider.js} +85 -35
- package/src/{vcs/vcm/oblique/ObliqueView.js → oblique/obliqueView.js} +45 -5
- package/src/{vcs/vcm/oblique/ObliqueViewDirection.js → oblique/obliqueViewDirection.js} +3 -5
- package/src/{vcs/vcm/oblique → oblique}/parseImageJson.js +62 -28
- package/src/ol/feature.js +34 -1
- package/src/ol/geom/circle.js +14 -5
- package/src/ol/geom/geometryCollection.js +14 -8
- package/src/ol/render/canvas/canvasTileRenderer.js +11 -10
- package/src/overrideClassRegistry.js +214 -0
- package/src/style/arcStyle.js +453 -0
- package/src/style/arrowStyle.js +304 -0
- package/src/{vcs/vcm/util/style → style}/declarativeStyleItem.js +147 -82
- package/src/{vcs/vcm/util/style → style}/shapesCategory.js +8 -8
- package/src/style/styleFactory.js +32 -0
- package/src/{vcs/vcm/util/style → style}/styleHelpers.js +24 -26
- package/src/style/styleItem.js +174 -0
- package/src/{vcs/vcm/util/style → style}/vectorStyleItem.js +230 -156
- package/src/{vcs/vcm/util/style → style}/writeStyle.js +7 -12
- package/src/{vcs/vcm/util → util}/clipping/clippingObject.js +79 -49
- package/src/{vcs/vcm/util → util}/clipping/clippingObjectManager.js +56 -23
- package/src/{vcs/vcm/util → util}/clipping/clippingPlaneHelper.js +149 -88
- package/src/{vcs/vcm/util → util}/collection.js +28 -10
- package/src/util/editor/createFeatureSession.js +195 -0
- package/src/util/editor/editFeaturesSession.js +325 -0
- package/src/util/editor/editGeometrySession.js +452 -0
- package/src/util/editor/editorHelpers.js +300 -0
- package/src/util/editor/editorSessionHelpers.js +132 -0
- package/src/util/editor/editorSymbols.js +21 -0
- package/src/util/editor/interactions/createBBoxInteraction.js +154 -0
- package/src/util/editor/interactions/createCircleInteraction.js +119 -0
- package/src/util/editor/interactions/createLineStringInteraction.js +119 -0
- package/src/util/editor/interactions/createPointInteraction.js +73 -0
- package/src/util/editor/interactions/createPolygonInteraction.js +136 -0
- package/src/util/editor/interactions/editFeaturesMouseOverInteraction.js +88 -0
- package/src/util/editor/interactions/editGeometryMouseOverInteraction.js +119 -0
- package/src/util/editor/interactions/ensureHandlerSelectionInteraction.js +50 -0
- package/src/util/editor/interactions/insertVertexInteraction.js +103 -0
- package/src/util/editor/interactions/mapInteractionController.js +119 -0
- package/src/util/editor/interactions/removeVertexInteraction.js +42 -0
- package/src/util/editor/interactions/selectFeatureMouseOverInteraction.js +152 -0
- package/src/util/editor/interactions/selectMultiFeatureInteraction.js +165 -0
- package/src/util/editor/interactions/selectSingleFeatureInteraction.js +120 -0
- package/src/util/editor/interactions/translateVertexInteraction.js +60 -0
- package/src/util/editor/selectFeaturesSession.js +303 -0
- package/src/util/editor/transformation/create2DHandlers.js +339 -0
- package/src/util/editor/transformation/create3DHandlers.js +678 -0
- package/src/util/editor/transformation/extrudeInteraction.js +106 -0
- package/src/util/editor/transformation/rotateInteraction.js +201 -0
- package/src/util/editor/transformation/scaleInteraction.js +201 -0
- package/src/util/editor/transformation/transformationHandler.js +178 -0
- package/src/util/editor/transformation/transformationTypes.js +88 -0
- package/src/util/editor/transformation/translateInteraction.js +263 -0
- package/src/util/editor/validateGeoemetry.js +24 -0
- package/src/{vcs/vcm/util → util}/exclusiveManager.js +6 -3
- package/src/{vcs/vcm/util → util}/extent.js +26 -20
- package/src/util/featureconverter/arcToCesium.js +121 -0
- package/src/{vcs/vcm/util → util}/featureconverter/circleToCesium.js +70 -37
- package/src/{vcs/vcm/util → util}/featureconverter/convert.js +94 -16
- package/src/util/featureconverter/extent3D.js +284 -0
- package/src/{vcs/vcm/util → util}/featureconverter/featureconverterHelper.js +253 -94
- package/src/util/featureconverter/lineStringToCesium.js +343 -0
- package/src/util/featureconverter/pointHelpers.js +413 -0
- package/src/{vcs/vcm/util → util}/featureconverter/pointToCesium.js +157 -107
- package/src/{vcs/vcm/util → util}/featureconverter/polygonToCesium.js +57 -24
- package/src/util/fetch.js +34 -0
- package/src/{vcs/vcm/util → util}/geometryHelpers.js +25 -17
- package/src/{vcs/vcm/util → util}/indexedCollection.js +27 -8
- package/src/{vcs/vcm/util → util}/isMobile.js +8 -2
- package/src/{vcs/vcm/util → util}/layerCollection.js +109 -19
- package/src/util/locale.js +12 -0
- package/src/{vcs/vcm/util → util}/mapCollection.js +170 -63
- package/src/util/math.js +193 -0
- package/src/util/overrideCollection.js +261 -0
- package/src/{vcs/vcm/util → util}/projection.js +23 -31
- package/src/{vcs/vcm/util → util}/urlHelpers.js +5 -3
- package/src/{vcs/vcm/util → util}/viewpoint.js +83 -57
- package/src/vcsApp.js +657 -0
- package/src/{vcs/vcm/event/vcsEvent.js → vcsEvent.js} +2 -3
- package/src/vcsModule.js +130 -0
- package/src/vcsModuleHelpers.js +136 -0
- package/src/{vcs/vcm/object.js → vcsObject.js} +3 -10
- package/tests/data/dynamicPointCzml.json +53 -0
- package/tests/data/oblique/imageData/imagev34.json +136 -0
- package/tests/data/oblique/imageData/imagev35.json +307 -0
- package/tests/data/oblique/imageData/imagev35PerImageSize.json +333 -0
- package/tests/data/oblique/tiledImageData/12/2199/1342.json +11056 -0
- package/tests/data/oblique/tiledImageData/12/2199/1343.json +11236 -0
- package/tests/data/oblique/tiledImageData/12/2199/1344.json +11077 -0
- package/tests/data/oblique/tiledImageData/12/2200/1342.json +11036 -0
- package/tests/data/oblique/tiledImageData/12/2200/1343.json +11277 -0
- package/tests/data/oblique/tiledImageData/12/2200/1344.json +11131 -0
- package/tests/data/oblique/tiledImageData/12/2201/1342.json +10870 -0
- package/tests/data/oblique/tiledImageData/12/2201/1343.json +11492 -0
- package/tests/data/oblique/tiledImageData/12/2201/1344.json +10909 -0
- package/tests/data/oblique/tiledImageData/image.json +70 -0
- package/tests/data/terrain/13/8800/6485.terrain +0 -0
- package/tests/data/terrain/13/8800/6486.terrain +0 -0
- package/tests/data/terrain/13/8801/6485.terrain +0 -0
- package/tests/data/terrain/13/8801/6486.terrain +0 -0
- package/tests/data/terrain/layer.json +127 -0
- package/tests/data/testGeoJSON.json +149 -0
- package/tests/data/tile.pbf +0 -0
- package/tests/unit/helpers/cesiumHelpers.js +326 -0
- package/tests/unit/helpers/getFileNameFromUrl.js +12 -0
- package/tests/unit/helpers/helpers.js +32 -0
- package/tests/unit/helpers/imageHelpers.js +24 -0
- package/tests/unit/helpers/importJSON.js +15 -0
- package/tests/unit/helpers/obliqueData.js +102 -0
- package/tests/unit/helpers/obliqueHelpers.js +115 -0
- package/tests/unit/helpers/openlayersHelpers.js +25 -0
- package/tests/unit/helpers/terrain/terrainData.js +45 -0
- package/src/vcs/vcm/classRegistry.js +0 -106
- package/src/vcs/vcm/globalCollections.js +0 -11
- package/src/vcs/vcm/interaction/featureProviderInteraction.js +0 -54
- package/src/vcs/vcm/layer/buildings.js +0 -17
- package/src/vcs/vcm/layer/cesium/openStreetMapCesium.js +0 -29
- package/src/vcs/vcm/layer/cesium/pointCloudCesium.js +0 -58
- package/src/vcs/vcm/layer/cesium/vectorContext.js +0 -167
- package/src/vcs/vcm/layer/openlayers/layerOpenlayers.js +0 -79
- package/src/vcs/vcm/layer/openlayers/openStreetMapOpenlayers.js +0 -27
- package/src/vcs/vcm/layer/openlayers/rasterLayerOpenlayers.js +0 -121
- package/src/vcs/vcm/layer/terrainHelpers.js +0 -119
- package/src/vcs/vcm/layer/tileProvider/staticGeojsonTileProvider.js +0 -67
- package/src/vcs/vcm/layer/tileProvider/tileProviderFactory.js +0 -28
- package/src/vcs/vcm/layer/vectorHelpers.js +0 -206
- package/src/vcs/vcm/util/dateTime.js +0 -60
- package/src/vcs/vcm/util/featureProvider/featureProviderHelpers.js +0 -51
- package/src/vcs/vcm/util/featureconverter/extent3d.js +0 -154
- package/src/vcs/vcm/util/featureconverter/lineStringToCesium.js +0 -171
- package/src/vcs/vcm/util/locale.js +0 -53
- package/src/vcs/vcm/util/math.js +0 -71
- package/src/vcs/vcm/util/splitScreen.js +0 -233
- package/src/vcs/vcm/util/style/styleFactory.js +0 -48
- package/src/vcs/vcm/util/style/styleItem.js +0 -243
- /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 {
|
|
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/
|
|
6
|
-
import { ObliqueViewDirection } from './
|
|
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/
|
|
18
|
+
* @type {import("@vcmap-cesium/engine").Cartesian2}
|
|
13
19
|
*/
|
|
14
20
|
let scratchCartesian2A = new Cartesian2();
|
|
15
21
|
/**
|
|
16
|
-
* @type {import("@vcmap/
|
|
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(
|
|
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(
|
|
74
|
-
|
|
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
|
-
(
|
|
101
|
-
(
|
|
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 =
|
|
109
|
-
|
|
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 +
|
|
115
|
-
result.y = 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(
|
|
143
|
-
|
|
144
|
-
|
|
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) {
|
|
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) {
|
|
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)) {
|
|
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(
|
|
170
|
-
|
|
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 = [
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
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) {
|
|
230
|
+
if (angleDirectionCheck / (Math.PI * 180.0) > 5) {
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
180
233
|
|
|
181
|
-
const sp2ep = [
|
|
182
|
-
|
|
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(
|
|
185
|
-
|
|
243
|
+
const angleStart2End = angleBetweenTwo2DVectors(
|
|
244
|
+
vectorCP2Coordinate,
|
|
245
|
+
sp2ep,
|
|
246
|
+
);
|
|
247
|
+
if (angleStart2End == null) {
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
186
250
|
|
|
187
|
-
const angleEnd2Start = angleBetweenTwo2DVectors(
|
|
188
|
-
|
|
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) {
|
|
193
|
-
|
|
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, [
|
|
197
|
-
|
|
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:
|
|
282
|
+
angle:
|
|
283
|
+
angleStart2End <= angleEnd2Start ? angleStart2End : angleEnd2Start,
|
|
205
284
|
edgeStart: sp,
|
|
206
285
|
edgeEnd: ep,
|
|
207
|
-
ratioStart2End:
|
|
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) {
|
|
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) {
|
|
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 = [
|
|
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] +
|
|
251
|
-
|
|
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 = [
|
|
348
|
+
const targetEdgeVectorFor1 = [
|
|
349
|
+
targetEdgeEnd1[0] - targetEdgeStart1[0],
|
|
350
|
+
targetEdgeEnd1[1] - targetEdgeStart1[1],
|
|
351
|
+
];
|
|
258
352
|
const intrFor1InTarget = [
|
|
259
|
-
targetEdgeStart1[0] +
|
|
260
|
-
|
|
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) {
|
|
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 (
|
|
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(
|
|
318
|
-
|
|
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(
|
|
328
|
-
|
|
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(
|
|
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(
|
|
336
|
-
|
|
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(
|
|
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, [
|
|
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(
|
|
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]) <
|
|
385
|
-
|
|
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(
|
|
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(
|
|
434
|
-
|
|
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
|
-
|
|
444
|
-
|
|
445
|
-
|
|
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
|
-
|
|
453
|
-
|
|
454
|
-
|
|
593
|
+
return (
|
|
594
|
+
windowUrl.origin === parsedUrl.origin &&
|
|
595
|
+
windowUrl.port === parsedUrl.port &&
|
|
596
|
+
windowUrl.protocol === parsedUrl.protocol
|
|
597
|
+
);
|
|
455
598
|
}
|