@vcmap/core 6.2.0-rc.1 → 6.2.0-rc.3
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/dist/cesium.d.ts +5 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/src/interaction/coordinateAtPixel.js +2 -2
- package/dist/src/interaction/coordinateAtPixel.js.map +1 -1
- package/dist/src/layer/cesium/cogCesiumImpl.d.ts +14 -0
- package/dist/src/layer/cesium/cogCesiumImpl.js +28 -0
- package/dist/src/layer/cesium/cogCesiumImpl.js.map +1 -0
- package/dist/src/layer/cesium/cogImageryProvider.d.ts +31 -0
- package/dist/src/layer/cesium/cogImageryProvider.js +258 -0
- package/dist/src/layer/cesium/cogImageryProvider.js.map +1 -0
- package/dist/src/layer/cogLayer.d.ts +37 -0
- package/dist/src/layer/cogLayer.js +119 -0
- package/dist/src/layer/cogLayer.js.map +1 -0
- package/dist/src/layer/openlayers/cogOpenlayersImpl.d.ts +23 -0
- package/dist/src/layer/openlayers/cogOpenlayersImpl.js +54 -0
- package/dist/src/layer/openlayers/cogOpenlayersImpl.js.map +1 -0
- package/dist/src/layer/openlayers/layerOpenlayersImpl.d.ts +3 -1
- package/dist/src/layer/openlayers/layerOpenlayersImpl.js +5 -3
- package/dist/src/layer/openlayers/layerOpenlayersImpl.js.map +1 -1
- package/dist/src/layer/panoramaDatasetLayer.d.ts +0 -1
- package/dist/src/layer/panoramaDatasetLayer.js +1 -10
- package/dist/src/layer/panoramaDatasetLayer.js.map +1 -1
- package/dist/src/map/panoramaMap.js +7 -2
- package/dist/src/map/panoramaMap.js.map +1 -1
- package/dist/src/panorama/panoramaImage.d.ts +7 -0
- package/dist/src/panorama/panoramaImage.js +5 -0
- package/dist/src/panorama/panoramaImage.js.map +1 -1
- package/dist/src/panorama/panoramaImageView.js +29 -36
- package/dist/src/panorama/panoramaImageView.js.map +1 -1
- package/dist/src/panorama/panoramaTile.d.ts +8 -4
- package/dist/src/panorama/panoramaTile.js +53 -9
- package/dist/src/panorama/panoramaTile.js.map +1 -1
- package/dist/src/panorama/panoramaTileMaterial.d.ts +0 -6
- package/dist/src/panorama/panoramaTileMaterial.js +0 -12
- package/dist/src/panorama/panoramaTileMaterial.js.map +1 -1
- package/dist/src/panorama/panoramaTileProvider.js +7 -8
- package/dist/src/panorama/panoramaTileProvider.js.map +1 -1
- package/dist/src/util/flight/flightRecorder.d.ts +10 -0
- package/dist/src/util/flight/flightRecorder.js +175 -0
- package/dist/src/util/flight/flightRecorder.js.map +1 -0
- package/dist/src/util/mapCollection.d.ts +2 -0
- package/dist/src/util/mapCollection.js +3 -0
- package/dist/src/util/mapCollection.js.map +1 -1
- package/dist/src/util/math.d.ts +4 -1
- package/dist/src/util/math.js +20 -1
- package/dist/src/util/math.js.map +1 -1
- package/dist/tests/data/cog/test_grey_world.tif +0 -0
- package/dist/tests/data/cog/test_rgb.tif +0 -0
- package/dist/tests/data/cog/test_rgb_world.tif +0 -0
- package/index.ts +10 -1
- package/package.json +1 -1
- package/src/cesium/cesium.d.ts +5 -0
- package/src/interaction/coordinateAtPixel.ts +2 -2
- package/src/layer/cesium/cogCesiumImpl.ts +36 -0
- package/src/layer/cesium/cogImageryProvider.ts +389 -0
- package/src/layer/cogLayer.ts +162 -0
- package/src/layer/openlayers/cogOpenlayersImpl.ts +75 -0
- package/src/layer/openlayers/layerOpenlayersImpl.ts +7 -4
- package/src/layer/panoramaDatasetLayer.ts +1 -12
- package/src/map/panoramaMap.ts +7 -2
- package/src/panorama/panoramaImage.ts +14 -0
- package/src/panorama/panoramaImageView.ts +32 -40
- package/src/panorama/panoramaTile.ts +81 -16
- package/src/panorama/panoramaTileMaterial.ts +0 -14
- package/src/panorama/panoramaTileProvider.ts +7 -10
- package/src/util/flight/flightRecorder.ts +237 -0
- package/src/util/mapCollection.ts +4 -0
- package/src/util/math.ts +34 -0
- package/dist/src/panorama/panoramaImageCache.d.ts +0 -8
- package/dist/src/panorama/panoramaImageCache.js +0 -18
- package/dist/src/panorama/panoramaImageCache.js.map +0 -1
- package/src/panorama/panoramaImageCache.ts +0 -19
package/dist/src/util/math.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Cartesian3, Cartographic } from '@vcmap-cesium/engine';
|
|
1
|
+
import { Cartesian3, Cartographic, Rectangle } from '@vcmap-cesium/engine';
|
|
2
2
|
import type { Coordinate } from 'ol/coordinate.js';
|
|
3
|
+
import { type Extent } from 'ol/extent.js';
|
|
3
4
|
/**
|
|
4
5
|
* returns a new coordinate ([lon, lat] in degrees) from a distance, bearing and starting coordinate
|
|
5
6
|
* @param coord [lon, lat] in degrees
|
|
@@ -43,6 +44,8 @@ export declare function wgs84ToCartographic(wgs84Coordinates: Coordinate, result
|
|
|
43
44
|
export declare function mercatorToCartesian(mercatorCoordinates: Coordinate, result?: Cartesian3): Cartesian3;
|
|
44
45
|
export declare function mercatorToCartographic(mercatorCoordinates: Coordinate, result?: Cartographic): Cartographic;
|
|
45
46
|
export declare function cartesianToMercator(cartesian: Cartesian3): Coordinate;
|
|
47
|
+
export declare function mercatorExtentToRectangle(extent: Extent, result?: Rectangle): Rectangle;
|
|
48
|
+
export declare function rectangleToMercatorExtent(rectangle: Rectangle): Extent;
|
|
46
49
|
export declare function getMidPoint(p1: Coordinate, p2: Coordinate): Coordinate;
|
|
47
50
|
/**
|
|
48
51
|
* Gets the pitch between two points in degrees.
|
package/dist/src/util/math.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Math as CesiumMath, Cartesian3, Cartographic, } from '@vcmap-cesium/engine';
|
|
1
|
+
import { Math as CesiumMath, Cartesian3, Cartographic, Rectangle, } from '@vcmap-cesium/engine';
|
|
2
2
|
import { getDistance as haversineDistance } from 'ol/sphere.js';
|
|
3
|
+
import { getBottomLeft, getTopRight } from 'ol/extent.js';
|
|
3
4
|
import Projection from './projection.js';
|
|
4
5
|
/**
|
|
5
6
|
* returns a new coordinate ([lon, lat] in degrees) from a distance, bearing and starting coordinate
|
|
@@ -113,6 +114,24 @@ export function cartesianToMercator(cartesian) {
|
|
|
113
114
|
const wgs84 = cartographicToWgs84(cartographic);
|
|
114
115
|
return Projection.wgs84ToMercator(wgs84);
|
|
115
116
|
}
|
|
117
|
+
export function mercatorExtentToRectangle(extent, result) {
|
|
118
|
+
const bottomLeft = getBottomLeft(extent);
|
|
119
|
+
const topRight = getTopRight(extent);
|
|
120
|
+
Projection.mercatorToWgs84(bottomLeft, true);
|
|
121
|
+
Projection.mercatorToWgs84(topRight, true);
|
|
122
|
+
return Rectangle.fromDegrees(bottomLeft[0], bottomLeft[1], topRight[0], topRight[1], result);
|
|
123
|
+
}
|
|
124
|
+
export function rectangleToMercatorExtent(rectangle) {
|
|
125
|
+
const bottomLeft = Projection.wgs84ToMercator([
|
|
126
|
+
CesiumMath.toDegrees(rectangle.west),
|
|
127
|
+
CesiumMath.toDegrees(rectangle.south),
|
|
128
|
+
]);
|
|
129
|
+
const topRight = Projection.wgs84ToMercator([
|
|
130
|
+
CesiumMath.toDegrees(rectangle.east),
|
|
131
|
+
CesiumMath.toDegrees(rectangle.north),
|
|
132
|
+
]);
|
|
133
|
+
return [bottomLeft[0], bottomLeft[1], topRight[0], topRight[1]];
|
|
134
|
+
}
|
|
116
135
|
export function getMidPoint(p1, p2) {
|
|
117
136
|
const stride = p1.length;
|
|
118
137
|
const output = new Array(stride);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"math.js","sourceRoot":"","sources":["../../../src/util/math.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,IAAI,UAAU,EAClB,UAAU,EACV,YAAY,
|
|
1
|
+
{"version":3,"file":"math.js","sourceRoot":"","sources":["../../../src/util/math.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,IAAI,UAAU,EAClB,UAAU,EACV,YAAY,EACZ,SAAS,GACV,MAAM,sBAAsB,CAAC;AAE9B,O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,kBAAkB,CAAC,EAAc,EAAE,EAAc;IAC/D,OAAO,iBAAiB,CACtB,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC,EAC9B,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC,CAC/B,CAAC;AACJ,CAAC;AAED,IAAI,oBAAoB,GAAG,IAAI,UAAU,EAAE,CAAC;AAC5C,IAAI,oBAAoB,GAAG,IAAI,UAAU,EAAE,CAAC;AAE5C;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,EAAc,EAAE,EAAc;IAC3D,oBAAoB,GAAG,mBAAmB,CAAC,EAAE,EAAE,oBAAoB,CAAC,CAAC;IACrE,oBAAoB,GAAG,mBAAmB,CAAC,EAAE,EAAE,oBAAoB,CAAC,CAAC;IAErE,OAAO,UAAU,CAAC,QAAQ,CAAC,oBAAoB,EAAE,oBAAoB,CAAC,CAAC;AACzE,CAAC"}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/index.ts
CHANGED
|
@@ -61,13 +61,14 @@ export {
|
|
|
61
61
|
export { default as FeatureProviderInteraction } from './src/interaction/featureProviderInteraction.js';
|
|
62
62
|
export { default as InteractionChain } from './src/interaction/interactionChain.js';
|
|
63
63
|
export { default as PanoramaImageSelection } from './src/interaction/panoramaImageSelection.js';
|
|
64
|
-
export { default as
|
|
64
|
+
export { default as PanoramaFeatureHighlight } from './src/interaction/panoramaFeatureHighlight.js';
|
|
65
65
|
export * from './src/interaction/interactionType.js';
|
|
66
66
|
export {
|
|
67
67
|
cesiumTilesetLastUpdated,
|
|
68
68
|
getExtentFromTileset,
|
|
69
69
|
default as CesiumTilesetCesiumImpl,
|
|
70
70
|
} from './src/layer/cesium/cesiumTilesetCesiumImpl.js';
|
|
71
|
+
export { default as COGCesiumImpl } from './src/layer/cesium/cogCesiumImpl.js';
|
|
71
72
|
export { default as DataSourceCesiumImpl } from './src/layer/cesium/dataSourceCesiumImpl.js';
|
|
72
73
|
export { default as OpenStreetMapCesiumImpl } from './src/layer/cesium/openStreetMapCesiumImpl.js';
|
|
73
74
|
export { default as RasterLayerCesiumImpl } from './src/layer/cesium/rasterLayerCesiumImpl.js';
|
|
@@ -114,6 +115,11 @@ export {
|
|
|
114
115
|
} from './src/layer/cesium/vcsTile/vcsTileHelpers.js';
|
|
115
116
|
export type { SourceVectorContextSync } from './src/layer/cesium/sourceVectorContextSync.js';
|
|
116
117
|
export { createSourceVectorContextSync } from './src/layer/cesium/sourceVectorContextSync.js';
|
|
118
|
+
export {
|
|
119
|
+
default as COGLayer,
|
|
120
|
+
type COGLayerOptions,
|
|
121
|
+
type COGLayerImplementationOptions,
|
|
122
|
+
} from './src/layer/cogLayer.js';
|
|
117
123
|
export type { CzmlOptions } from './src/layer/czmlLayer.js';
|
|
118
124
|
export { default as CzmlLayer } from './src/layer/czmlLayer.js';
|
|
119
125
|
export type { DataSourceImplementationOptions } from './src/layer/dataSourceLayer.js';
|
|
@@ -201,6 +207,7 @@ export type { SourceObliqueSync } from './src/layer/oblique/sourceObliqueSync.js
|
|
|
201
207
|
export { createSourceObliqueSync } from './src/layer/oblique/sourceObliqueSync.js';
|
|
202
208
|
export type { OpenStreetMapOptions } from './src/layer/openStreetMapLayer.js';
|
|
203
209
|
export { default as OpenStreetMapLayer } from './src/layer/openStreetMapLayer.js';
|
|
210
|
+
export { default as COGOpenlayersImpl } from './src/layer/openlayers/cogOpenlayersImpl.js';
|
|
204
211
|
export type { LayerOpenlayersImplementationOptions } from './src/layer/openlayers/layerOpenlayersImpl.js';
|
|
205
212
|
export { default as LayerOpenlayersImpl } from './src/layer/openlayers/layerOpenlayersImpl.js';
|
|
206
213
|
export { default as OpenStreetMapOpenlayersImpl } from './src/layer/openlayers/openStreetMapOpenlayersImpl.js';
|
|
@@ -882,6 +889,8 @@ export {
|
|
|
882
889
|
getSplineAndTimesForInstance,
|
|
883
890
|
parseFlightOptionsFromGeoJson,
|
|
884
891
|
} from './src/util/flight/flightHelpers.js';
|
|
892
|
+
export { createFlightMovie } from './src/util/flight/flightRecorder.js';
|
|
893
|
+
export type { FlightPathRecorderOptions } from './src/util/flight/flightRecorder.js';
|
|
885
894
|
export type { FlightVisualization } from './src/util/flight/flightVisualizer.js';
|
|
886
895
|
export { createFlightVisualization } from './src/util/flight/flightVisualizer.js';
|
|
887
896
|
export { getTileLoadFunction } from './src/layer/openlayers/loadFunctionHelpers.js';
|
package/package.json
CHANGED
package/src/cesium/cesium.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ import { cartesianToMercator } from '../util/math.js';
|
|
|
22
22
|
import { windowPositionToImageSpherical } from '../panorama/fieldOfView.js';
|
|
23
23
|
|
|
24
24
|
const scratchPanoramaCartesian = new Cartesian3();
|
|
25
|
-
async function
|
|
25
|
+
async function getCoordinateFromPanoramaMap(
|
|
26
26
|
map: PanoramaMap,
|
|
27
27
|
event: InteractionEvent,
|
|
28
28
|
): Promise<InteractionEvent> {
|
|
@@ -73,7 +73,7 @@ class CoordinateAtPixel extends AbstractInteraction {
|
|
|
73
73
|
} else if (event.map.className === 'ObliqueMap') {
|
|
74
74
|
return CoordinateAtPixel.obliqueHandler(event);
|
|
75
75
|
} else if (event.map.className === 'PanoramaMap') {
|
|
76
|
-
return
|
|
76
|
+
return getCoordinateFromPanoramaMap(event.map as PanoramaMap, event);
|
|
77
77
|
}
|
|
78
78
|
return event;
|
|
79
79
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type GeoTIFFSource from 'ol/source/GeoTIFF.js';
|
|
2
|
+
import { ImageryLayer as CesiumImageryLayer } from '@vcmap-cesium/engine';
|
|
3
|
+
import RasterLayerCesiumImpl from './rasterLayerCesiumImpl.js';
|
|
4
|
+
import COGImageryProvider from './cogImageryProvider.js';
|
|
5
|
+
import type { COGLayerImplementationOptions } from '../cogLayer.js';
|
|
6
|
+
import type CesiumMap from '../../map/cesiumMap.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* COG Layer implementation for {@link CesiumMap}.
|
|
10
|
+
*/
|
|
11
|
+
class COGCesiumImpl extends RasterLayerCesiumImpl {
|
|
12
|
+
static get className(): string {
|
|
13
|
+
return 'COGCesiumImpl';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
private _source: GeoTIFFSource;
|
|
17
|
+
|
|
18
|
+
constructor(map: CesiumMap, options: COGLayerImplementationOptions) {
|
|
19
|
+
super(map, options);
|
|
20
|
+
this._source = options.source;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async getCesiumLayer(): Promise<CesiumImageryLayer> {
|
|
24
|
+
const imageryProvider = new COGImageryProvider(this._source);
|
|
25
|
+
const layerOptions = this.getCesiumLayerOptions();
|
|
26
|
+
return Promise.resolve(
|
|
27
|
+
// @ts-expect-error: other impl
|
|
28
|
+
new CesiumImageryLayer(imageryProvider, {
|
|
29
|
+
...layerOptions,
|
|
30
|
+
rectangle: imageryProvider.tilingScheme.rectangle,
|
|
31
|
+
}),
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default COGCesiumImpl;
|
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
import type { Projection } from 'ol/proj.js';
|
|
2
|
+
import type GeoTIFFSource from 'ol/source/GeoTIFF.js';
|
|
3
|
+
import {
|
|
4
|
+
createEmpty as createEmptyExtent,
|
|
5
|
+
extend as extendExtent,
|
|
6
|
+
getWidth as getExtentWidth,
|
|
7
|
+
getHeight as getExtentHeight,
|
|
8
|
+
getTopLeft as getTopLeftExtent,
|
|
9
|
+
} from 'ol/extent.js';
|
|
10
|
+
import TileState from 'ol/TileState.js';
|
|
11
|
+
import {
|
|
12
|
+
Cartesian2,
|
|
13
|
+
Event as CesiumEvent,
|
|
14
|
+
GeographicTilingScheme,
|
|
15
|
+
type ImageryTypes,
|
|
16
|
+
Math as CesiumMath,
|
|
17
|
+
Rectangle,
|
|
18
|
+
type TilingScheme,
|
|
19
|
+
WebMercatorTilingScheme,
|
|
20
|
+
} from '@vcmap-cesium/engine';
|
|
21
|
+
import EventType from 'ol/events/EventType.js';
|
|
22
|
+
import type TileGrid from 'ol/tilegrid/TileGrid.js';
|
|
23
|
+
import {
|
|
24
|
+
mercatorExtentToRectangle,
|
|
25
|
+
rectangleToMercatorExtent,
|
|
26
|
+
} from '../../util/math.js';
|
|
27
|
+
|
|
28
|
+
export function createEmptyCanvas(
|
|
29
|
+
width: number,
|
|
30
|
+
height: number,
|
|
31
|
+
): HTMLCanvasElement {
|
|
32
|
+
const canvas = document.createElement('canvas');
|
|
33
|
+
canvas.width = width;
|
|
34
|
+
canvas.height = height;
|
|
35
|
+
return canvas;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function areGridsAligned(
|
|
39
|
+
tileGrid: TileGrid,
|
|
40
|
+
tilingScheme: TilingScheme,
|
|
41
|
+
): boolean {
|
|
42
|
+
const olRectangle = mercatorExtentToRectangle(
|
|
43
|
+
tileGrid.getTileCoordExtent([0, 0, 0]),
|
|
44
|
+
);
|
|
45
|
+
const cesiumRectangle = tilingScheme.tileXYToRectangle(0, 0, 0);
|
|
46
|
+
|
|
47
|
+
return Rectangle.equalsEpsilon(
|
|
48
|
+
cesiumRectangle,
|
|
49
|
+
olRectangle,
|
|
50
|
+
CesiumMath.EPSILON8,
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function getTilingSchemeFromSource(source: GeoTIFFSource): TilingScheme {
|
|
55
|
+
const tileGrid = source.getTileGrid()!;
|
|
56
|
+
const projection = source.getProjection()!;
|
|
57
|
+
const extent = tileGrid.getExtent();
|
|
58
|
+
const level0TileRange = tileGrid.getTileRangeForExtentAndZ(extent, 0);
|
|
59
|
+
|
|
60
|
+
let tilingScheme: TilingScheme | undefined;
|
|
61
|
+
|
|
62
|
+
if (projection.getCode() === 'EPSG:4326') {
|
|
63
|
+
tilingScheme = new GeographicTilingScheme({
|
|
64
|
+
numberOfLevelZeroTilesX: level0TileRange.getWidth(),
|
|
65
|
+
numberOfLevelZeroTilesY: level0TileRange.getHeight(),
|
|
66
|
+
rectangle: mercatorExtentToRectangle(extent),
|
|
67
|
+
});
|
|
68
|
+
} else if (projection.getCode() === 'EPSG:3857') {
|
|
69
|
+
tilingScheme = new WebMercatorTilingScheme({
|
|
70
|
+
numberOfLevelZeroTilesX: level0TileRange.getWidth(),
|
|
71
|
+
numberOfLevelZeroTilesY: level0TileRange.getHeight(),
|
|
72
|
+
rectangleSouthwestInMeters: new Cartesian2(extent[0], extent[1]),
|
|
73
|
+
rectangleNortheastInMeters: new Cartesian2(extent[2], extent[3]),
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (!tilingScheme) {
|
|
78
|
+
throw new Error(`Unexpected code projection: ${projection.getCode()}`);
|
|
79
|
+
}
|
|
80
|
+
return tilingScheme;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export default class COGImageryProvider {
|
|
84
|
+
private _emptyCanvas: HTMLCanvasElement;
|
|
85
|
+
|
|
86
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
87
|
+
_reload: undefined | (() => void) = undefined;
|
|
88
|
+
|
|
89
|
+
private _projection: Projection;
|
|
90
|
+
|
|
91
|
+
private _tilingScheme: TilingScheme;
|
|
92
|
+
|
|
93
|
+
private _tileGrid: TileGrid;
|
|
94
|
+
|
|
95
|
+
private _boundTileLoader: (
|
|
96
|
+
x: number,
|
|
97
|
+
y: number,
|
|
98
|
+
level: number,
|
|
99
|
+
) => Promise<ImageryTypes>;
|
|
100
|
+
|
|
101
|
+
constructor(private _source: GeoTIFFSource) {
|
|
102
|
+
this._emptyCanvas = createEmptyCanvas(this.tileWidth, this.tileHeight);
|
|
103
|
+
this._projection = this._source.getProjection()!;
|
|
104
|
+
this._tileGrid = this._source.getTileGrid()!;
|
|
105
|
+
this._tilingScheme = getTilingSchemeFromSource(this._source);
|
|
106
|
+
if (areGridsAligned(this._tileGrid, this._tilingScheme)) {
|
|
107
|
+
this._boundTileLoader = this._loadAlignedTile.bind(this);
|
|
108
|
+
} else {
|
|
109
|
+
this._boundTileLoader = this._loadUnalignedTile.bind(this);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// eslint-disable-next-line class-methods-use-this,@typescript-eslint/naming-convention
|
|
114
|
+
get _ready(): boolean {
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// eslint-disable-next-line class-methods-use-this
|
|
119
|
+
get ready(): boolean {
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
get rectangle(): Rectangle {
|
|
124
|
+
return this._tilingScheme.rectangle;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
get tilingScheme(): TilingScheme {
|
|
128
|
+
return this._tilingScheme;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
readonly errorEvent: CesiumEvent = new CesiumEvent();
|
|
132
|
+
|
|
133
|
+
// eslint-disable-next-line class-methods-use-this
|
|
134
|
+
get credit(): undefined {
|
|
135
|
+
return undefined;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// eslint-disable-next-line class-methods-use-this
|
|
139
|
+
get proxy(): undefined {
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
get tileWidth(): number {
|
|
144
|
+
const tileGrid = this._source.getTileGrid();
|
|
145
|
+
if (tileGrid) {
|
|
146
|
+
const tileSizeAtZoom0 = tileGrid.getTileSize(0);
|
|
147
|
+
if (Array.isArray(tileSizeAtZoom0)) {
|
|
148
|
+
return Math.round(tileSizeAtZoom0[0]);
|
|
149
|
+
} else {
|
|
150
|
+
return Math.round(tileSizeAtZoom0); // same width and height
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return 256;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
get tileHeight(): number {
|
|
157
|
+
const tileGrid = this._source.getTileGrid();
|
|
158
|
+
if (tileGrid) {
|
|
159
|
+
const tileSizeAtZoom0 = tileGrid.getTileSize(0);
|
|
160
|
+
if (Array.isArray(tileSizeAtZoom0)) {
|
|
161
|
+
return Math.round(tileSizeAtZoom0[1]);
|
|
162
|
+
} else {
|
|
163
|
+
return Math.round(tileSizeAtZoom0); // same width and height
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return 256;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
get maximumLevel(): number {
|
|
170
|
+
const tileGrid = this._source.getTileGrid();
|
|
171
|
+
if (tileGrid) {
|
|
172
|
+
return tileGrid.getMaxZoom();
|
|
173
|
+
} else {
|
|
174
|
+
return 18; // some arbitrary value
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// eslint-disable-next-line class-methods-use-this
|
|
179
|
+
get minimumLevel(): number {
|
|
180
|
+
// WARNING: Do not use the minimum level (at least until the extent is
|
|
181
|
+
// properly set). Cesium assumes the minimumLevel to contain only
|
|
182
|
+
// a few tiles and tries to load them all at once -- this can
|
|
183
|
+
// freeze and/or crash the browser !
|
|
184
|
+
return 0;
|
|
185
|
+
//var tg = this._source.getTileGrid();
|
|
186
|
+
//return tg ? tg.getMinZoom() : 0;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
// eslint-disable-next-line class-methods-use-this
|
|
190
|
+
get tileDiscardPolicy(): undefined {
|
|
191
|
+
return undefined;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// eslint-disable-next-line class-methods-use-this
|
|
195
|
+
get hasAlphaChannel(): boolean {
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
private async _loadOLTile(
|
|
200
|
+
x: number,
|
|
201
|
+
y: number,
|
|
202
|
+
level: number,
|
|
203
|
+
): Promise<Uint8Array | undefined> {
|
|
204
|
+
const tile = this._source.getTile(level, x, y, 1, this._projection);
|
|
205
|
+
if (tile) {
|
|
206
|
+
return new Promise<Uint8Array | undefined>((resolve) => {
|
|
207
|
+
const listener = (): void => {
|
|
208
|
+
const data = tile.getData() as Uint8Array | null;
|
|
209
|
+
if (data) {
|
|
210
|
+
tile.removeEventListener(EventType.CHANGE, listener);
|
|
211
|
+
resolve(data);
|
|
212
|
+
} else if (
|
|
213
|
+
tile.getState() === TileState.EMPTY ||
|
|
214
|
+
tile.getState() === TileState.ERROR
|
|
215
|
+
) {
|
|
216
|
+
tile.removeEventListener(EventType.CHANGE, listener);
|
|
217
|
+
resolve(undefined);
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
if (tile.getState() === TileState.LOADED) {
|
|
221
|
+
listener();
|
|
222
|
+
} else if (
|
|
223
|
+
tile.getState() === TileState.EMPTY ||
|
|
224
|
+
tile.getState() === TileState.ERROR
|
|
225
|
+
) {
|
|
226
|
+
resolve(undefined);
|
|
227
|
+
} else {
|
|
228
|
+
tile.addEventListener(EventType.CHANGE, listener);
|
|
229
|
+
if (tile.getState() === TileState.IDLE) {
|
|
230
|
+
tile.load();
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
return Promise.resolve(undefined);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
private _drawData(
|
|
239
|
+
ctx: CanvasRenderingContext2D,
|
|
240
|
+
data: Uint8Array,
|
|
241
|
+
offsetX = 0,
|
|
242
|
+
offsetY = 0,
|
|
243
|
+
): void {
|
|
244
|
+
const imageData = ctx.createImageData(this.tileWidth, this.tileHeight);
|
|
245
|
+
let usedData = data;
|
|
246
|
+
// this is a grey image
|
|
247
|
+
if (data.length === imageData.data.length / 2) {
|
|
248
|
+
usedData = new Uint8Array(imageData.data.length);
|
|
249
|
+
for (let i = 0; i < data.length; i++) {
|
|
250
|
+
const value = data[i];
|
|
251
|
+
if (i % 2 === 0) {
|
|
252
|
+
const pixelOffset = (i / 2) * 4;
|
|
253
|
+
usedData[pixelOffset] = value;
|
|
254
|
+
usedData[pixelOffset + 1] = value;
|
|
255
|
+
usedData[pixelOffset + 2] = value;
|
|
256
|
+
} else {
|
|
257
|
+
const pixelOffset = ((i - 1) / 2) * 4;
|
|
258
|
+
usedData[pixelOffset + 3] = value;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
imageData.data.set(usedData);
|
|
264
|
+
ctx.putImageData(imageData, offsetX, offsetY);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
private async _loadAlignedTile(
|
|
268
|
+
x: number,
|
|
269
|
+
y: number,
|
|
270
|
+
level: number,
|
|
271
|
+
): Promise<ImageryTypes> {
|
|
272
|
+
const tileData = await this._loadOLTile(x, y, level);
|
|
273
|
+
if (tileData) {
|
|
274
|
+
const canvas = createEmptyCanvas(this.tileWidth, this.tileHeight);
|
|
275
|
+
const ctx = canvas.getContext('2d');
|
|
276
|
+
if (ctx) {
|
|
277
|
+
this._drawData(ctx, tileData);
|
|
278
|
+
}
|
|
279
|
+
return canvas;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
return this._emptyCanvas;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
private async _loadUnalignedTile(
|
|
286
|
+
x: number,
|
|
287
|
+
y: number,
|
|
288
|
+
level: number,
|
|
289
|
+
): Promise<ImageryTypes> {
|
|
290
|
+
const rectangle = this._tilingScheme.tileXYToRectangle(x, y, level);
|
|
291
|
+
const extent = rectangleToMercatorExtent(rectangle);
|
|
292
|
+
const resolution = Math.max(
|
|
293
|
+
getExtentWidth(extent) / this.tileWidth,
|
|
294
|
+
getExtentHeight(extent) / this.tileHeight,
|
|
295
|
+
);
|
|
296
|
+
const levelResolution = this._tileGrid.getZForResolution(resolution);
|
|
297
|
+
const tileRange = this._tileGrid.getTileRangeForExtentAndZ(
|
|
298
|
+
extent,
|
|
299
|
+
levelResolution,
|
|
300
|
+
);
|
|
301
|
+
const canvas = createEmptyCanvas(
|
|
302
|
+
this.tileWidth * tileRange.getWidth(),
|
|
303
|
+
this.tileHeight * tileRange.getHeight(),
|
|
304
|
+
);
|
|
305
|
+
const ctx = canvas.getContext('2d');
|
|
306
|
+
if (!ctx) {
|
|
307
|
+
return this._emptyCanvas;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
const promises: Promise<void>[] = [];
|
|
311
|
+
const tileRangeExtent = createEmptyExtent();
|
|
312
|
+
for (
|
|
313
|
+
let partialX = tileRange.minX;
|
|
314
|
+
partialX <= tileRange.maxX;
|
|
315
|
+
partialX++
|
|
316
|
+
) {
|
|
317
|
+
for (
|
|
318
|
+
let partialY = tileRange.minY;
|
|
319
|
+
partialY <= tileRange.maxY;
|
|
320
|
+
partialY++
|
|
321
|
+
) {
|
|
322
|
+
extendExtent(
|
|
323
|
+
tileRangeExtent,
|
|
324
|
+
this._tileGrid.getTileCoordExtent([
|
|
325
|
+
levelResolution,
|
|
326
|
+
partialX,
|
|
327
|
+
partialY,
|
|
328
|
+
]),
|
|
329
|
+
);
|
|
330
|
+
promises.push(
|
|
331
|
+
this._loadOLTile(partialX, partialY, levelResolution).then(
|
|
332
|
+
(tileData) => {
|
|
333
|
+
if (tileData) {
|
|
334
|
+
this._drawData(
|
|
335
|
+
ctx,
|
|
336
|
+
tileData,
|
|
337
|
+
(partialX - tileRange.minX) * this.tileWidth,
|
|
338
|
+
(partialY - tileRange.minY) * this.tileHeight,
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
},
|
|
342
|
+
),
|
|
343
|
+
);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
await Promise.all(promises);
|
|
347
|
+
|
|
348
|
+
const unitsPerPixelX =
|
|
349
|
+
getExtentWidth(tileRangeExtent) / (this.tileWidth * tileRange.getWidth());
|
|
350
|
+
const unitsPerPixelY =
|
|
351
|
+
getExtentHeight(tileRangeExtent) /
|
|
352
|
+
(this.tileHeight * tileRange.getHeight());
|
|
353
|
+
|
|
354
|
+
const tileRangeTopLeft = getTopLeftExtent(tileRangeExtent);
|
|
355
|
+
const extentTopLeft = getTopLeftExtent(extent);
|
|
356
|
+
|
|
357
|
+
const windowX =
|
|
358
|
+
Math.abs(tileRangeTopLeft[0] - extentTopLeft[0]) / unitsPerPixelX;
|
|
359
|
+
const windowY =
|
|
360
|
+
Math.abs(tileRangeTopLeft[1] - extentTopLeft[1]) / unitsPerPixelY;
|
|
361
|
+
const windowWidth = getExtentWidth(extent) / unitsPerPixelX;
|
|
362
|
+
const windowHeight = getExtentHeight(extent) / unitsPerPixelY;
|
|
363
|
+
|
|
364
|
+
const windowCanvas = createEmptyCanvas(this.tileWidth, this.tileHeight);
|
|
365
|
+
const windowCtx = windowCanvas.getContext('2d');
|
|
366
|
+
|
|
367
|
+
if (windowCtx) {
|
|
368
|
+
windowCtx.drawImage(
|
|
369
|
+
canvas,
|
|
370
|
+
windowX,
|
|
371
|
+
windowY,
|
|
372
|
+
windowWidth,
|
|
373
|
+
windowHeight,
|
|
374
|
+
0,
|
|
375
|
+
0,
|
|
376
|
+
this.tileWidth,
|
|
377
|
+
this.tileHeight,
|
|
378
|
+
);
|
|
379
|
+
|
|
380
|
+
return windowCanvas;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
return this._emptyCanvas;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
requestImage(x: number, y: number, level: number): Promise<ImageryTypes> {
|
|
387
|
+
return this._boundTileLoader(x, y, level);
|
|
388
|
+
}
|
|
389
|
+
}
|