@vcmap/core 5.0.0-rc.28 → 5.0.0-rc.29
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/README.md +9 -3
- package/build/postinstall.js +13 -2
- package/index.d.ts +155 -106
- package/package.json +9 -4
- package/src/category/category.js +71 -32
- package/src/category/categoryCollection.js +27 -18
- package/src/cesium/cesiumVcsCameraPrimitive.js +13 -5
- package/src/cesium/entity.js +3 -1
- package/src/cesium/wallpaperMaterial.js +4 -2
- package/src/classRegistry.js +11 -4
- package/src/featureProvider/abstractFeatureProvider.js +43 -22
- package/src/featureProvider/tileProviderFeatureProvider.js +11 -5
- package/src/featureProvider/wmsFeatureProvider.js +37 -15
- package/src/interaction/abstractInteraction.js +5 -1
- package/src/interaction/coordinateAtPixel.js +34 -12
- package/src/interaction/eventHandler.js +63 -23
- package/src/interaction/featureAtPixelInteraction.js +96 -32
- package/src/interaction/featureProviderInteraction.js +23 -8
- package/src/interaction/interactionChain.js +19 -9
- package/src/interaction/interactionType.js +23 -26
- package/src/layer/cesium/cesiumTilesetCesiumImpl.js +45 -15
- package/src/layer/cesium/clusterContext.js +10 -3
- package/src/layer/cesium/dataSourceCesiumImpl.js +13 -4
- package/src/layer/cesium/openStreetMapCesiumImpl.js +7 -3
- package/src/layer/cesium/rasterLayerCesiumImpl.js +6 -2
- package/src/layer/cesium/singleImageCesiumImpl.js +14 -3
- package/src/layer/cesium/terrainCesiumImpl.js +3 -2
- package/src/layer/cesium/tmsCesiumImpl.js +15 -3
- package/src/layer/cesium/vectorCesiumImpl.js +69 -25
- package/src/layer/cesium/vectorContext.js +25 -5
- package/src/layer/cesium/vectorRasterTileCesiumImpl.js +15 -5
- package/src/layer/cesium/vectorTileImageryProvider.js +51 -13
- package/src/layer/cesium/wmsCesiumImpl.js +15 -3
- package/src/layer/cesium/wmtsCesiumImpl.js +18 -6
- package/src/layer/cesium/x3dmHelper.js +4 -1
- package/src/layer/cesiumTilesetLayer.js +55 -26
- package/src/layer/czmlLayer.js +11 -5
- package/src/layer/dataSourceLayer.js +25 -17
- package/src/layer/featureLayer.js +33 -18
- package/src/layer/featureStoreLayer.js +161 -99
- package/src/layer/featureStoreLayerChanges.js +57 -17
- package/src/layer/featureVisibility.js +89 -59
- package/src/layer/geojsonHelpers.js +70 -29
- package/src/layer/geojsonLayer.js +17 -11
- package/src/layer/globalHider.js +14 -4
- package/src/layer/layer.js +77 -44
- package/src/layer/layerImplementation.js +12 -4
- package/src/layer/oblique/layerObliqueImpl.js +3 -1
- package/src/layer/oblique/obliqueHelpers.js +75 -30
- package/src/layer/oblique/vectorObliqueImpl.js +175 -69
- package/src/layer/openStreetMapLayer.js +34 -20
- package/src/layer/openlayers/layerOpenlayersImpl.js +37 -15
- package/src/layer/openlayers/openStreetMapOpenlayersImpl.js +3 -1
- package/src/layer/openlayers/rasterLayerOpenlayersImpl.js +3 -1
- package/src/layer/openlayers/singleImageOpenlayersImpl.js +3 -1
- package/src/layer/openlayers/tileDebugOpenlayersImpl.js +3 -1
- package/src/layer/openlayers/tmsOpenlayersImpl.js +6 -3
- package/src/layer/openlayers/vectorOpenlayersImpl.js +14 -4
- package/src/layer/openlayers/vectorTileOpenlayersImpl.js +12 -5
- package/src/layer/openlayers/wmsOpenlayersImpl.js +3 -1
- package/src/layer/openlayers/wmtsOpenlayersImpl.js +12 -5
- package/src/layer/pointCloudLayer.js +21 -10
- package/src/layer/rasterLayer.js +73 -22
- package/src/layer/singleImageLayer.js +10 -7
- package/src/layer/terrainHelpers.js +30 -19
- package/src/layer/terrainLayer.js +16 -7
- package/src/layer/tileLoadedHelper.js +9 -4
- package/src/layer/tileProvider/mvtTileProvider.js +10 -4
- package/src/layer/tileProvider/staticGeojsonTileProvider.js +10 -4
- package/src/layer/tileProvider/tileProvider.js +163 -87
- package/src/layer/tileProvider/urlTemplateTileProvider.js +10 -4
- package/src/layer/tmsLayer.js +7 -6
- package/src/layer/vectorHelpers.js +34 -25
- package/src/layer/vectorLayer.js +77 -36
- package/src/layer/vectorProperties.js +245 -74
- package/src/layer/vectorSymbols.js +3 -1
- package/src/layer/vectorTileLayer.js +121 -70
- package/src/layer/wfsLayer.js +19 -8
- package/src/layer/wmsHelpers.js +11 -6
- package/src/layer/wmsLayer.js +36 -14
- package/src/layer/wmtsLayer.js +35 -20
- package/src/map/baseOLMap.js +57 -31
- package/src/map/cameraLimiter.js +67 -18
- package/src/map/cesiumMap.js +307 -95
- package/src/map/obliqueMap.js +84 -34
- package/src/map/openlayersMap.js +40 -19
- package/src/map/vcsMap.js +21 -8
- package/src/oblique/helpers.js +212 -64
- package/src/oblique/obliqueCollection.js +111 -48
- package/src/oblique/obliqueDataSet.js +53 -21
- package/src/oblique/obliqueImage.js +50 -17
- package/src/oblique/obliqueImageMeta.js +7 -6
- package/src/oblique/obliqueProvider.js +75 -27
- package/src/oblique/obliqueView.js +18 -7
- package/src/oblique/obliqueViewDirection.js +3 -2
- package/src/oblique/parseImageJson.js +57 -23
- package/src/ol/feature.js +8 -3
- package/src/ol/geom/circle.js +12 -3
- package/src/ol/geom/geometryCollection.js +11 -4
- package/src/ol/render/canvas/canvasTileRenderer.js +11 -9
- package/src/overrideClassRegistry.js +13 -3
- package/src/style/arcStyle.js +129 -36
- package/src/style/arrowStyle.js +57 -22
- package/src/style/declarativeStyleItem.js +107 -62
- package/src/style/shapesCategory.js +8 -6
- package/src/style/styleFactory.js +4 -1
- package/src/style/styleHelpers.js +17 -8
- package/src/style/styleItem.js +28 -10
- package/src/style/vectorStyleItem.js +160 -74
- package/src/style/writeStyle.js +5 -7
- package/src/util/clipping/clippingObject.js +72 -38
- package/src/util/clipping/clippingObjectManager.js +53 -19
- package/src/util/clipping/clippingPlaneHelper.js +120 -53
- package/src/util/collection.js +12 -6
- package/src/util/editor/createFeatureSession.js +21 -6
- package/src/util/editor/editFeaturesSession.js +41 -15
- package/src/util/editor/editGeometrySession.js +55 -30
- package/src/util/editor/editorHelpers.js +114 -29
- package/src/util/editor/editorSessionHelpers.js +8 -3
- package/src/util/editor/interactions/createBBoxInteraction.js +11 -3
- package/src/util/editor/interactions/createCircleInteraction.js +7 -2
- package/src/util/editor/interactions/createLineStringInteraction.js +7 -2
- package/src/util/editor/interactions/createPolygonInteraction.js +7 -2
- package/src/util/editor/interactions/editFeaturesMouseOverInteraction.js +7 -5
- package/src/util/editor/interactions/editGeometryMouseOverInteraction.js +8 -3
- package/src/util/editor/interactions/ensureHandlerSelectionInteraction.js +4 -2
- package/src/util/editor/interactions/insertVertexInteraction.js +17 -6
- package/src/util/editor/interactions/mapInteractionController.js +31 -14
- package/src/util/editor/interactions/removeVertexInteraction.js +4 -1
- package/src/util/editor/interactions/selectFeatureMouseOverInteraction.js +19 -10
- package/src/util/editor/interactions/selectMultiFeatureInteraction.js +33 -20
- package/src/util/editor/interactions/selectSingleFeatureInteraction.js +14 -8
- package/src/util/editor/selectFeaturesSession.js +37 -21
- package/src/util/editor/transformation/create2DHandlers.js +82 -37
- package/src/util/editor/transformation/create3DHandlers.js +187 -84
- package/src/util/editor/transformation/extrudeInteraction.js +20 -5
- package/src/util/editor/transformation/rotateInteraction.js +29 -16
- package/src/util/editor/transformation/scaleInteraction.js +31 -15
- package/src/util/editor/transformation/transformationHandler.js +23 -8
- package/src/util/editor/transformation/transformationTypes.js +8 -4
- package/src/util/editor/transformation/translateInteraction.js +86 -32
- package/src/util/editor/validateGeoemetry.js +3 -1
- package/src/util/exclusiveManager.js +6 -3
- package/src/util/extent.js +20 -10
- package/src/util/featureconverter/arcToCesium.js +46 -12
- package/src/util/featureconverter/circleToCesium.js +61 -27
- package/src/util/featureconverter/convert.js +85 -13
- package/src/util/featureconverter/extent3D.js +69 -28
- package/src/util/featureconverter/featureconverterHelper.js +232 -79
- package/src/util/featureconverter/lineStringToCesium.js +107 -35
- package/src/util/featureconverter/pointHelpers.js +117 -45
- package/src/util/featureconverter/pointToCesium.js +128 -31
- package/src/util/featureconverter/polygonToCesium.js +50 -16
- package/src/util/fetch.js +3 -1
- package/src/util/geometryHelpers.js +15 -10
- package/src/util/indexedCollection.js +7 -3
- package/src/util/isMobile.js +8 -2
- package/src/util/layerCollection.js +28 -12
- package/src/util/mapCollection.js +37 -18
- package/src/util/math.js +35 -19
- package/src/util/overrideCollection.js +57 -32
- package/src/util/projection.js +21 -5
- package/src/util/urlHelpers.js +5 -3
- package/src/util/viewpoint.js +66 -33
- package/src/vcsApp.js +133 -69
- package/src/vcsModule.js +3 -2
- package/src/vcsModuleHelpers.js +24 -9
- package/src/vcsObject.js +3 -2
- package/tests/data/dynamicPointCzml.json +24 -35
- package/tests/data/oblique/imageData/imagev34.json +56 -272
- package/tests/data/oblique/imageData/imagev35.json +272 -19
- package/tests/data/oblique/imageData/imagev35PerImageSize.json +299 -19
- package/tests/data/oblique/tiledImageData/12/2199/1342.json +11056 -1
- package/tests/data/oblique/tiledImageData/12/2199/1343.json +11236 -1
- package/tests/data/oblique/tiledImageData/12/2199/1344.json +11077 -1
- package/tests/data/oblique/tiledImageData/12/2200/1342.json +11036 -1
- package/tests/data/oblique/tiledImageData/12/2200/1343.json +11277 -1
- package/tests/data/oblique/tiledImageData/12/2200/1344.json +11131 -1
- package/tests/data/oblique/tiledImageData/12/2201/1342.json +10870 -1
- package/tests/data/oblique/tiledImageData/12/2201/1343.json +11492 -1
- package/tests/data/oblique/tiledImageData/12/2201/1344.json +10909 -1
- package/tests/data/oblique/tiledImageData/image.json +70 -1
- package/tests/data/terrain/layer.json +121 -130
- package/tests/data/testGeoJSON.json +4 -16
- package/tests/unit/helpers/cesiumHelpers.js +58 -33
- package/tests/unit/helpers/helpers.js +10 -2
- package/tests/unit/helpers/imageHelpers.js +8 -4
- package/tests/unit/helpers/obliqueData.js +39 -13
- package/tests/unit/helpers/obliqueHelpers.js +12 -9
- package/tests/unit/helpers/openlayersHelpers.js +4 -1
- package/tests/unit/helpers/terrain/terrainData.js +8 -7
package/src/oblique/helpers.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
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
11
|
import { Cartesian2 } from '@vcmap-cesium/engine';
|
|
6
12
|
import { ObliqueViewDirection } from './obliqueViewDirection.js';
|
|
@@ -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
|
|
|
@@ -96,22 +113,24 @@ export function checkLineIntersection(segment1, segment2) {
|
|
|
96
113
|
};
|
|
97
114
|
|
|
98
115
|
const denominator =
|
|
99
|
-
(
|
|
100
|
-
(
|
|
116
|
+
(line2EndY - line2StartY) * (line1EndX - line1StartX) -
|
|
117
|
+
(line2EndX - line2StartX) * (line1EndY - line1StartY);
|
|
101
118
|
|
|
102
119
|
if (denominator === 0) {
|
|
103
120
|
return result;
|
|
104
121
|
}
|
|
105
122
|
a = line1StartY - line2StartY;
|
|
106
123
|
b = line1StartX - line2StartX;
|
|
107
|
-
const numerator1 =
|
|
108
|
-
|
|
124
|
+
const numerator1 =
|
|
125
|
+
(line2EndX - line2StartX) * a - (line2EndY - line2StartY) * b;
|
|
126
|
+
const numerator2 =
|
|
127
|
+
(line1EndX - line1StartX) * a - (line1EndY - line1StartY) * b;
|
|
109
128
|
a = numerator1 / denominator;
|
|
110
129
|
b = numerator2 / denominator;
|
|
111
130
|
|
|
112
131
|
// if we cast these lines infinitely in both directions, they intersect here:
|
|
113
|
-
result.x = line1StartX +
|
|
114
|
-
result.y = line1StartY +
|
|
132
|
+
result.x = line1StartX + a * (line1EndX - line1StartX);
|
|
133
|
+
result.y = line1StartY + a * (line1EndY - line1StartY);
|
|
115
134
|
/*
|
|
116
135
|
// it is worth noting that this should be the same as:
|
|
117
136
|
x = line2StartX + (b * (line2EndX - line2StartX));
|
|
@@ -138,9 +157,21 @@ export function checkLineIntersection(segment1, segment2) {
|
|
|
138
157
|
* @param {ObliqueViewDirection} viewDirection
|
|
139
158
|
* @returns {{x: (number|null), y:(number|null), onLine1: boolean, onLine2: boolean}|null}
|
|
140
159
|
*/
|
|
141
|
-
export function transformCWIFC(
|
|
142
|
-
|
|
143
|
-
|
|
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
|
+
);
|
|
144
175
|
|
|
145
176
|
// test intersections from all corner points over coordinate to all non neighbouring borders
|
|
146
177
|
// and non side borders too - so actually remains only upper and lower border
|
|
@@ -152,58 +183,110 @@ export function transformCWIFC(inputOrigin, inputTarget, originIsImage, coordina
|
|
|
152
183
|
// - distance ratio while negative means negative direction
|
|
153
184
|
// to be able to recreate the situation in the target system
|
|
154
185
|
const intersections = [];
|
|
155
|
-
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
|
|
156
188
|
const intrCurrCP = [];
|
|
157
189
|
|
|
158
190
|
for (let sp = 0; sp < origin.length; ++sp) {
|
|
159
191
|
const ep = sp === origin.length - 1 ? 0 : sp + 1; // end point of edge
|
|
160
192
|
|
|
161
193
|
// skip if cp is sp or ep - neighbouring edge
|
|
162
|
-
if (cp === sp || cp === ep) {
|
|
194
|
+
if (cp === sp || cp === ep) {
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
163
197
|
|
|
164
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
|
|
165
|
-
if ((sp === 3 && ep === 0) || (sp === 1 && ep === 2)) {
|
|
199
|
+
if ((sp === 3 && ep === 0) || (sp === 1 && ep === 2)) {
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
166
202
|
|
|
167
203
|
// get intersection from cp over coordinate2Transform to current border edge
|
|
168
|
-
const currIntr = checkLineIntersection(
|
|
169
|
-
|
|
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
|
+
}
|
|
170
211
|
|
|
171
212
|
// get vector from current cp to coordinate2Transform to be able to determine if the intersection is in same direction
|
|
172
213
|
// might be in different direction when point is outside - then we dont need this data
|
|
173
|
-
const vectorCP2Coordinate = [
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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
|
+
}
|
|
177
229
|
|
|
178
|
-
if (angleDirectionCheck / (Math.PI * 180.0) > 5) {
|
|
230
|
+
if (angleDirectionCheck / (Math.PI * 180.0) > 5) {
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
179
233
|
|
|
180
|
-
const sp2ep = [
|
|
181
|
-
|
|
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
|
+
];
|
|
182
242
|
// regarding the angle find the smallest
|
|
183
|
-
const angleStart2End = angleBetweenTwo2DVectors(
|
|
184
|
-
|
|
243
|
+
const angleStart2End = angleBetweenTwo2DVectors(
|
|
244
|
+
vectorCP2Coordinate,
|
|
245
|
+
sp2ep,
|
|
246
|
+
);
|
|
247
|
+
if (angleStart2End == null) {
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
185
250
|
|
|
186
|
-
const angleEnd2Start = angleBetweenTwo2DVectors(
|
|
187
|
-
|
|
251
|
+
const angleEnd2Start = angleBetweenTwo2DVectors(
|
|
252
|
+
vectorCP2Coordinate,
|
|
253
|
+
ep2sp,
|
|
254
|
+
);
|
|
255
|
+
if (angleEnd2Start == null) {
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
188
258
|
|
|
189
259
|
// regarding ratioStart2End get ratio and then direction
|
|
190
260
|
const distStartEnd = cartesian2DDistance(origin[sp], origin[ep]);
|
|
191
|
-
if (distStartEnd === 0) {
|
|
192
|
-
|
|
261
|
+
if (distStartEnd === 0) {
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
const tempRatioStartEnd =
|
|
265
|
+
cartesian2DDistance(origin[sp], [currIntr.x, currIntr.y]) /
|
|
266
|
+
distStartEnd;
|
|
193
267
|
let angleEdge2Intr = 0;
|
|
194
268
|
if (tempRatioStartEnd !== 0) {
|
|
195
|
-
angleEdge2Intr = angleBetweenTwo2DVectors(ep2sp, [
|
|
196
|
-
|
|
269
|
+
angleEdge2Intr = angleBetweenTwo2DVectors(ep2sp, [
|
|
270
|
+
currIntr.x - origin[sp][0],
|
|
271
|
+
currIntr.y - origin[sp][1],
|
|
272
|
+
]);
|
|
273
|
+
if (angleEdge2Intr == null) {
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
197
276
|
}
|
|
198
277
|
|
|
199
278
|
intrCurrCP.push({
|
|
200
279
|
cornerPoint: cp,
|
|
201
280
|
intrX: currIntr.x,
|
|
202
281
|
intrY: currIntr.y,
|
|
203
|
-
angle:
|
|
282
|
+
angle:
|
|
283
|
+
angleStart2End <= angleEnd2Start ? angleStart2End : angleEnd2Start,
|
|
204
284
|
edgeStart: sp,
|
|
205
285
|
edgeEnd: ep,
|
|
206
|
-
ratioStart2End:
|
|
286
|
+
ratioStart2End:
|
|
287
|
+
(angleEdge2Intr / Math.PI) * 180.0 > 5
|
|
288
|
+
? tempRatioStartEnd * -1
|
|
289
|
+
: tempRatioStartEnd,
|
|
207
290
|
});
|
|
208
291
|
}
|
|
209
292
|
|
|
@@ -216,11 +299,15 @@ export function transformCWIFC(inputOrigin, inputTarget, originIsImage, coordina
|
|
|
216
299
|
indLargestAngle = i;
|
|
217
300
|
}
|
|
218
301
|
}
|
|
219
|
-
if (indLargestAngle !== -1) {
|
|
302
|
+
if (indLargestAngle !== -1) {
|
|
303
|
+
intersections.push(intrCurrCP[indLargestAngle]);
|
|
304
|
+
}
|
|
220
305
|
}
|
|
221
306
|
|
|
222
307
|
// if we don not have enough data to recreate the situation in target system stop
|
|
223
|
-
if (intersections.length < 2) {
|
|
308
|
+
if (intersections.length < 2) {
|
|
309
|
+
return null;
|
|
310
|
+
}
|
|
224
311
|
|
|
225
312
|
// make list with intersection combinations and sort after strength (add angles together)
|
|
226
313
|
const intrCombis = []; // will contain [addedAngle, intersectionsIndex_i, intersectionsIndex_j]
|
|
@@ -235,7 +322,10 @@ export function transformCWIFC(inputOrigin, inputTarget, originIsImage, coordina
|
|
|
235
322
|
.sort()
|
|
236
323
|
.reverse()
|
|
237
324
|
.find((intersection) => {
|
|
238
|
-
const intersectionsSorted = [
|
|
325
|
+
const intersectionsSorted = [
|
|
326
|
+
intersections[intersection[1]],
|
|
327
|
+
intersections[intersection[2]],
|
|
328
|
+
];
|
|
239
329
|
|
|
240
330
|
const targetEdgeEnd0 = target[intersectionsSorted[0].edgeEnd];
|
|
241
331
|
const targetEdgeStart0 = target[intersectionsSorted[0].edgeStart];
|
|
@@ -246,17 +336,24 @@ export function transformCWIFC(inputOrigin, inputTarget, originIsImage, coordina
|
|
|
246
336
|
];
|
|
247
337
|
|
|
248
338
|
const intrFor0InTarget = [
|
|
249
|
-
targetEdgeStart0[0] +
|
|
250
|
-
|
|
339
|
+
targetEdgeStart0[0] +
|
|
340
|
+
targetEdgeVectorFor0[0] * intersectionsSorted[0].ratioStart2End,
|
|
341
|
+
targetEdgeStart0[1] +
|
|
342
|
+
targetEdgeVectorFor0[1] * intersectionsSorted[0].ratioStart2End,
|
|
251
343
|
];
|
|
252
344
|
|
|
253
345
|
const targetEdgeEnd1 = target[intersectionsSorted[1].edgeEnd];
|
|
254
346
|
const targetEdgeStart1 = target[intersectionsSorted[1].edgeStart];
|
|
255
347
|
|
|
256
|
-
const targetEdgeVectorFor1 = [
|
|
348
|
+
const targetEdgeVectorFor1 = [
|
|
349
|
+
targetEdgeEnd1[0] - targetEdgeStart1[0],
|
|
350
|
+
targetEdgeEnd1[1] - targetEdgeStart1[1],
|
|
351
|
+
];
|
|
257
352
|
const intrFor1InTarget = [
|
|
258
|
-
targetEdgeStart1[0] +
|
|
259
|
-
|
|
353
|
+
targetEdgeStart1[0] +
|
|
354
|
+
targetEdgeVectorFor1[0] * intersectionsSorted[1].ratioStart2End,
|
|
355
|
+
targetEdgeStart1[1] +
|
|
356
|
+
targetEdgeVectorFor1[1] * intersectionsSorted[1].ratioStart2End,
|
|
260
357
|
];
|
|
261
358
|
|
|
262
359
|
const vecCP0ToIntr0 = [
|
|
@@ -269,7 +366,9 @@ export function transformCWIFC(inputOrigin, inputTarget, originIsImage, coordina
|
|
|
269
366
|
];
|
|
270
367
|
|
|
271
368
|
const angleCross = angleBetweenTwo2DVectors(vecCP0ToIntr0, vecCP1ToIntr1);
|
|
272
|
-
if (angleCross == null) {
|
|
369
|
+
if (angleCross == null) {
|
|
370
|
+
return false;
|
|
371
|
+
}
|
|
273
372
|
/* var thresholdInDegree = 3;
|
|
274
373
|
if (angleCross/Math.PI*180.0 < thresholdInDegree || angleCross/Math.PI*180.0 > 180-thresholdInDegree)
|
|
275
374
|
continue; */
|
|
@@ -308,12 +407,23 @@ export function transformCWIFC(inputOrigin, inputTarget, originIsImage, coordina
|
|
|
308
407
|
*/
|
|
309
408
|
export function transformToImage(image, worldCoordinate, options = {}) {
|
|
310
409
|
let gpInternalCoordinates;
|
|
311
|
-
if (
|
|
410
|
+
if (
|
|
411
|
+
options.dataProjection &&
|
|
412
|
+
options.dataProjection === image.meta.projection
|
|
413
|
+
) {
|
|
312
414
|
gpInternalCoordinates = worldCoordinate;
|
|
313
415
|
} else {
|
|
314
|
-
gpInternalCoordinates = options.dataProjection
|
|
315
|
-
transform(
|
|
316
|
-
|
|
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
|
+
);
|
|
317
427
|
}
|
|
318
428
|
|
|
319
429
|
function useAverageHeight() {
|
|
@@ -322,19 +432,39 @@ export function transformToImage(image, worldCoordinate, options = {}) {
|
|
|
322
432
|
}
|
|
323
433
|
|
|
324
434
|
if (worldCoordinate[2]) {
|
|
325
|
-
const coords = image.transformRealWorld2Image(
|
|
326
|
-
|
|
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
|
+
});
|
|
327
444
|
}
|
|
328
445
|
|
|
329
446
|
if (!options.dontUseTerrain && image.meta.terrainProvider) {
|
|
330
|
-
return getHeightFromTerrainProvider(
|
|
447
|
+
return getHeightFromTerrainProvider(
|
|
448
|
+
image.meta.terrainProvider,
|
|
449
|
+
[gpInternalCoordinates],
|
|
450
|
+
image.meta.projection,
|
|
451
|
+
)
|
|
331
452
|
.then(([gpWithHeight]) => {
|
|
332
453
|
if (gpWithHeight[2]) {
|
|
333
|
-
const imageCoordinates = image.transformRealWorld2Image(
|
|
334
|
-
|
|
454
|
+
const imageCoordinates = image.transformRealWorld2Image(
|
|
455
|
+
gpInternalCoordinates,
|
|
456
|
+
gpWithHeight[2],
|
|
457
|
+
);
|
|
458
|
+
return {
|
|
459
|
+
coords: imageCoordinates,
|
|
460
|
+
height: gpInternalCoordinates[2],
|
|
461
|
+
estimate: false,
|
|
462
|
+
};
|
|
335
463
|
}
|
|
336
464
|
// eslint-disable-next-line no-console
|
|
337
|
-
console.warn(
|
|
465
|
+
console.warn(
|
|
466
|
+
'The configured terrain on the oblique layer could not be queried, position might be inaccurate',
|
|
467
|
+
);
|
|
338
468
|
return useAverageHeight();
|
|
339
469
|
})
|
|
340
470
|
.catch(() => useAverageHeight());
|
|
@@ -369,18 +499,24 @@ function pickTerrain(pickTerrainOptions) {
|
|
|
369
499
|
height,
|
|
370
500
|
} = pickTerrainOptions;
|
|
371
501
|
|
|
372
|
-
return getHeightFromTerrainProvider(image.meta.terrainProvider, [
|
|
502
|
+
return getHeightFromTerrainProvider(image.meta.terrainProvider, [
|
|
503
|
+
worldCoordinate,
|
|
504
|
+
])
|
|
373
505
|
.then(([worldCoordinateWithHeights]) => {
|
|
374
506
|
if (worldCoordinateWithHeights[2] != null) {
|
|
375
507
|
const newWorldCoords = transform(
|
|
376
|
-
image.transformImage2RealWorld(
|
|
508
|
+
image.transformImage2RealWorld(
|
|
509
|
+
imageCoordinate,
|
|
510
|
+
worldCoordinateWithHeights[2],
|
|
511
|
+
),
|
|
377
512
|
image.meta.projection.proj,
|
|
378
513
|
wgs84Projection.proj,
|
|
379
514
|
);
|
|
380
515
|
newWorldCoords[2] = worldCoordinateWithHeights[2];
|
|
381
516
|
if (
|
|
382
|
-
Math.abs(height - worldCoordinateWithHeights[2]) <
|
|
383
|
-
|
|
517
|
+
Math.abs(height - worldCoordinateWithHeights[2]) <
|
|
518
|
+
terrainErrorThreshold ||
|
|
519
|
+
count > terrainErrorCountThreshold
|
|
384
520
|
) {
|
|
385
521
|
return { coords: newWorldCoords, estimate: false };
|
|
386
522
|
}
|
|
@@ -389,7 +525,9 @@ function pickTerrain(pickTerrainOptions) {
|
|
|
389
525
|
return pickTerrain(pickTerrainOptions);
|
|
390
526
|
}
|
|
391
527
|
// eslint-disable-next-line no-console
|
|
392
|
-
console.log(
|
|
528
|
+
console.log(
|
|
529
|
+
'The configured terrain on the oblique layer could not be queried, position might be inaccurate',
|
|
530
|
+
);
|
|
393
531
|
return { coords: worldCoordinateWithHeights, estimate: true };
|
|
394
532
|
})
|
|
395
533
|
.catch(() => ({ coords: worldCoordinate, estimate: true }));
|
|
@@ -426,9 +564,17 @@ export async function transformFromImage(image, imageCoordinate, options = {}) {
|
|
|
426
564
|
});
|
|
427
565
|
}
|
|
428
566
|
|
|
429
|
-
coordsObj.coords = options.dataProjection
|
|
430
|
-
transform(
|
|
431
|
-
|
|
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
|
+
);
|
|
432
578
|
return coordsObj;
|
|
433
579
|
}
|
|
434
580
|
|
|
@@ -444,7 +590,9 @@ export function hasSameOrigin(url) {
|
|
|
444
590
|
return true;
|
|
445
591
|
}
|
|
446
592
|
|
|
447
|
-
return
|
|
593
|
+
return (
|
|
594
|
+
windowUrl.origin === parsedUrl.origin &&
|
|
448
595
|
windowUrl.port === parsedUrl.port &&
|
|
449
|
-
windowUrl.protocol === parsedUrl.protocol
|
|
596
|
+
windowUrl.protocol === parsedUrl.protocol
|
|
597
|
+
);
|
|
450
598
|
}
|