@vcmap/core 5.0.0-rc.6 → 5.0.0-rc.7
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/index.d.ts +2 -0
- package/package.json +4 -4
- package/src/vcs/vcm/event/vcsEvent.js +2 -2
- package/src/vcs/vcm/layer/featureVisibility.js +3 -2
- package/src/vcs/vcm/layer/openlayers/rasterLayerOpenlayers.js +3 -2
- package/src/vcs/vcm/maps/oblique.js +2 -1
- package/src/vcs/vcm/maps/openlayers.js +6 -3
- package/src/vcs/vcm/oblique/ObliqueCollection.js +8 -4
- package/src/vcs/vcm/oblique/ObliqueProvider.js +4 -2
- package/src/vcs/vcm/util/featureProvider/wmsFeatureProvider.js +2 -1
- package/src/vcs/vcm/util/projection.js +5 -2
package/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vcmap/core",
|
|
3
|
-
"version": "5.0.0-rc.
|
|
3
|
+
"version": "5.0.0-rc.7",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -54,11 +54,11 @@
|
|
|
54
54
|
"node-fetch": "^3.2.0",
|
|
55
55
|
"sinon": "^9.2.4",
|
|
56
56
|
"sinon-chai": "^3.6.0",
|
|
57
|
-
"typescript": "^4.
|
|
57
|
+
"typescript": "^4.6.2"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"@vcmap/cesium": "~1.87.3",
|
|
61
|
-
"ol": "
|
|
61
|
+
"ol": "~6.13.0"
|
|
62
62
|
},
|
|
63
63
|
"eslintConfig": {
|
|
64
64
|
"extends": [
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"@vcsuite/logger": "^1.0.1",
|
|
78
78
|
"@vcsuite/parsers": "^1.0.1",
|
|
79
79
|
"fast-deep-equal": "^3.1.3",
|
|
80
|
-
"proj4": "^2.7.
|
|
80
|
+
"proj4": "^2.7.5",
|
|
81
81
|
"rbush": ">=3.0.1",
|
|
82
82
|
"rbush-knn": "^3.0.1",
|
|
83
83
|
"underscore.template": "^0.1.7",
|
|
@@ -58,7 +58,7 @@ class VcsEvent {
|
|
|
58
58
|
* @api
|
|
59
59
|
*/
|
|
60
60
|
raiseEvent(event) {
|
|
61
|
-
this._listeners.forEach((cb) => {
|
|
61
|
+
[...this._listeners].forEach((cb) => {
|
|
62
62
|
cb(event);
|
|
63
63
|
});
|
|
64
64
|
}
|
|
@@ -70,7 +70,7 @@ class VcsEvent {
|
|
|
70
70
|
async awaitRaisedEvent(event) {
|
|
71
71
|
const promises = new Array(this._listeners.size);
|
|
72
72
|
let i = 0;
|
|
73
|
-
this._listeners.forEach((cb) => {
|
|
73
|
+
[...this._listeners].forEach((cb) => {
|
|
74
74
|
promises[i] = cb(event);
|
|
75
75
|
i += 1;
|
|
76
76
|
});
|
|
@@ -264,8 +264,9 @@ class FeatureVisibility {
|
|
|
264
264
|
usedStyle = fromCesiumColor(style);
|
|
265
265
|
} else if (style instanceof Style) {
|
|
266
266
|
usedStyle = new VectorStyleItem({});
|
|
267
|
-
if (style.getText() && style.getText().getText()) {
|
|
268
|
-
|
|
267
|
+
if (style.getText() && style.getText().getText() && !Array.isArray(style.getText().getText())) {
|
|
268
|
+
// getText can return a rich Text Array<string> We do not support this at the moment.
|
|
269
|
+
usedStyle.label = String(style.getText().getText());
|
|
269
270
|
}
|
|
270
271
|
usedStyle.style = style;
|
|
271
272
|
}
|
|
@@ -77,7 +77,7 @@ class RasterLayerOpenlayers extends LayerOpenlayers {
|
|
|
77
77
|
this._splitDirectionRenderListeners
|
|
78
78
|
.push(/** @type {import("ol/events").EventsKey} */
|
|
79
79
|
(this.olLayer.on('postrender', (/** @type {import("ol/render/Event").default} */ event) => {
|
|
80
|
-
event.context.restore();
|
|
80
|
+
/** @type {CanvasRenderingContext2D} */ (event.context).restore();
|
|
81
81
|
})),
|
|
82
82
|
);
|
|
83
83
|
this.olLayer.changed();
|
|
@@ -93,7 +93,8 @@ class RasterLayerOpenlayers extends LayerOpenlayers {
|
|
|
93
93
|
if (!this.map.splitScreen) {
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
|
-
|
|
96
|
+
// eslint-disable-next-line prefer-destructuring
|
|
97
|
+
const context = /** @type {CanvasRenderingContext2D} */ (event.context);
|
|
97
98
|
const width = context.canvas.width * this.map.splitScreen.position;
|
|
98
99
|
context.save();
|
|
99
100
|
context.beginPath();
|
|
@@ -420,7 +420,8 @@ class Oblique extends BaseOLMap {
|
|
|
420
420
|
const gpInternalProjection = image.transformImage2RealWorld(gpImageCoordinates, image.averageHeight);
|
|
421
421
|
|
|
422
422
|
const transfrom = getTransform(image.meta.projection.proj, wgs84Projection.proj);
|
|
423
|
-
|
|
423
|
+
// getText can return a rich Text Array<string> We do not support this at the moment.
|
|
424
|
+
const gpWGS84 = transfrom(gpInternalProjection.slice(0, 2), undefined, undefined);
|
|
424
425
|
return this._computeViewpointInternal(gpWGS84);
|
|
425
426
|
}
|
|
426
427
|
|
|
@@ -87,7 +87,8 @@ class Openlayers extends BaseOLMap {
|
|
|
87
87
|
size.width = viewport.offsetWidth || 1;
|
|
88
88
|
const aspectRatio = size.width / size.height;
|
|
89
89
|
const fovy = Math.atan(Math.tan(fov * 0.5) / aspectRatio) * 2.0;
|
|
90
|
-
|
|
90
|
+
// error in TransformFunction type definition, remove undefined after openlayer fixed the type
|
|
91
|
+
const latlon = toLatLon(coord.slice(0, 2), undefined, undefined);
|
|
91
92
|
const metersPerUnit = view.getProjection().getMetersPerUnit();
|
|
92
93
|
|
|
93
94
|
const resolution = view.getResolution();
|
|
@@ -129,7 +130,8 @@ class Openlayers extends BaseOLMap {
|
|
|
129
130
|
coords = viewpoint.cameraPosition.slice(0, 2);
|
|
130
131
|
}
|
|
131
132
|
const { distance } = viewpoint;
|
|
132
|
-
|
|
133
|
+
// error in TransformFunction type definition, remove undefined after openlayer fixed the type
|
|
134
|
+
const center = fromLatLon(coords, undefined, undefined);
|
|
133
135
|
|
|
134
136
|
const fov = Math.PI / 3.0;
|
|
135
137
|
const viewport = this.olMap.getViewport();
|
|
@@ -180,7 +182,8 @@ class Openlayers extends BaseOLMap {
|
|
|
180
182
|
const toLatLon = getTransform(view.getProjection(), 'EPSG:4326');
|
|
181
183
|
const topLeft = [extent[0], extent[3]];
|
|
182
184
|
const bottomRight = [extent[2], extent[1]];
|
|
183
|
-
|
|
185
|
+
// error in TransformFunction type definition, remove undefined after openlayer fixed the type
|
|
186
|
+
const bbox = [toLatLon(topLeft, undefined, undefined), toLatLon(bottomRight, undefined, undefined)];
|
|
184
187
|
|
|
185
188
|
return containsXY(boundingExtent(bbox), coords[0], coords[1]);
|
|
186
189
|
}
|
|
@@ -79,7 +79,8 @@ function getImageFeatures(images) {
|
|
|
79
79
|
return images.map((image) => {
|
|
80
80
|
const transform = getTransform(image.meta.projection.proj, mercatorProjection.proj);
|
|
81
81
|
const feature = new Feature({
|
|
82
|
-
|
|
82
|
+
// error in TransformFunction type definition, remove undefined after openlayer fixed the type
|
|
83
|
+
geometry: new Polygon([image.groundCoordinates.map(c => transform(c.slice(0, 2), undefined, undefined))]),
|
|
83
84
|
viewDirection: image.viewDirection,
|
|
84
85
|
});
|
|
85
86
|
feature.setId(image.name);
|
|
@@ -370,7 +371,8 @@ class ObliqueCollection extends VcsObject {
|
|
|
370
371
|
|
|
371
372
|
const transform = getTransform(image.meta.projection.proj, mercatorProjection.proj);
|
|
372
373
|
const coord = image.centerPointOnGround.slice(0, 2);
|
|
373
|
-
|
|
374
|
+
// error in TransformFunction type definition, remove undefined after openlayer fixed the type
|
|
375
|
+
transform(coord, coord, undefined);
|
|
374
376
|
directions.get(image.viewDirection).push({
|
|
375
377
|
minX: coord[0],
|
|
376
378
|
minY: coord[1],
|
|
@@ -539,7 +541,8 @@ class ObliqueCollection extends VcsObject {
|
|
|
539
541
|
if (image) {
|
|
540
542
|
const transform = getTransform(mercatorProjection.proj, image.meta.projection.proj);
|
|
541
543
|
const internalCoordinates = mercatorCoordinate.slice(0, 2);
|
|
542
|
-
|
|
544
|
+
// error in TransformFunction type definition, remove undefined after openlayer fixed the type
|
|
545
|
+
transform(internalCoordinates, internalCoordinates, undefined);
|
|
543
546
|
const extent = boundingExtent(image.groundCoordinates);
|
|
544
547
|
return containsCoordinate(extent, internalCoordinates);
|
|
545
548
|
}
|
|
@@ -560,7 +563,8 @@ class ObliqueCollection extends VcsObject {
|
|
|
560
563
|
const tree = this._directionTrees.get(image.viewDirection);
|
|
561
564
|
if (tree) {
|
|
562
565
|
const transform = getTransform(image.meta.projection.proj, mercatorProjection.proj);
|
|
563
|
-
|
|
566
|
+
// error in TransformFunction type definition, remove undefined after openlayer fixed the type
|
|
567
|
+
const coords = image.groundCoordinates.map(c => transform(c.slice(0, 2), undefined, undefined));
|
|
564
568
|
const extent = boundingExtent(coords);
|
|
565
569
|
await this.loadDataForExtent(buffer(extent, 200));
|
|
566
570
|
const center = getCenter(extent);
|
|
@@ -234,7 +234,8 @@ class ObliqueProvider {
|
|
|
234
234
|
const pulledCenter = this._pullCoordinateToImageCenter(imageCoordinates.slice());
|
|
235
235
|
const worldCoords = this._currentImage.transformImage2RealWorld(pulledCenter).slice(0, 2);
|
|
236
236
|
const transform = getTransform(this._currentImage.meta.projection.proj, mercatorProjection.proj);
|
|
237
|
-
|
|
237
|
+
// error in TransformFunction type definition, remove undefined after openlayer fixed the type
|
|
238
|
+
const mercatorCoords = transform(worldCoords, undefined, undefined);
|
|
238
239
|
const buffer = 200; // XXX make configurable?
|
|
239
240
|
const extent = [
|
|
240
241
|
mercatorCoords[0] - buffer, mercatorCoords[1] - buffer,
|
|
@@ -300,10 +301,11 @@ class ObliqueProvider {
|
|
|
300
301
|
const [width, height] = this._currentImage.meta.size;
|
|
301
302
|
let center = [width / 2, height / 2];
|
|
302
303
|
if (optCenter) {
|
|
304
|
+
// error in TransformFunction type definition, remove undefined after openlayer fixed the type
|
|
303
305
|
const worldCenter = getTransform(
|
|
304
306
|
mercatorProjection.proj,
|
|
305
307
|
this._currentImage.meta.projection.proj,
|
|
306
|
-
)(optCenter.slice(0, 2));
|
|
308
|
+
)(optCenter.slice(0, 2), undefined, undefined);
|
|
307
309
|
const imageCenter = this._currentImage.transformRealWorld2Image(worldCenter, optCenter[2]);
|
|
308
310
|
imageCenter[0] = withinBounds(imageCenter[0], width);
|
|
309
311
|
imageCenter[1] = withinBounds(imageCenter[1], height);
|
|
@@ -198,7 +198,8 @@ class WMSFeatureProvider extends AbstractFeatureProvider {
|
|
|
198
198
|
let coords = coordinate;
|
|
199
199
|
if (projection) {
|
|
200
200
|
const transform = getTransform(mercatorProjection.proj, projection);
|
|
201
|
-
|
|
201
|
+
// error in TransformFunction type definition, remove undefined after openlayer fixed the type
|
|
202
|
+
coords = transform(coordinate.slice(), undefined, undefined);
|
|
202
203
|
}
|
|
203
204
|
|
|
204
205
|
const metersPerUnit = 111194.87428468118;
|
|
@@ -14,9 +14,12 @@ import { VcsClassRegistry } from '../classRegistry.js';
|
|
|
14
14
|
* @property {string|undefined} [prefix='EPSG:'] - an alternate prefix to use for custom projection
|
|
15
15
|
* @api stable
|
|
16
16
|
*/
|
|
17
|
+
/**
|
|
18
|
+
* @typedef {function(Array<number>, Array<number>=, number=): Array<number>} CorrectTransformFunction
|
|
19
|
+
*/
|
|
17
20
|
|
|
18
|
-
export const wgs84ToMercatorTransformer = getTransform('EPSG:4326', 'EPSG:3857');
|
|
19
|
-
export const mercatorToWgs84Transformer = getTransform('EPSG:3857', 'EPSG:4326');
|
|
21
|
+
export const wgs84ToMercatorTransformer = /** @type {CorrectTransformFunction} */ (getTransform('EPSG:4326', 'EPSG:3857'));
|
|
22
|
+
export const mercatorToWgs84Transformer = /** @type {CorrectTransformFunction} */ (getTransform('EPSG:3857', 'EPSG:4326'));
|
|
20
23
|
|
|
21
24
|
|
|
22
25
|
/**
|