@vcmap/core 5.0.2 → 5.1.0-rc.1
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 +257 -0
- package/dist/geojson.d.ts +27 -0
- package/dist/index.d.ts +15 -2
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/ol.d.ts +138 -0
- package/dist/src/classRegistry.js +2 -2
- package/dist/src/classRegistry.js.map +1 -1
- package/dist/src/featureProvider/abstractFeatureProvider.d.ts +2 -1
- package/dist/src/featureProvider/abstractFeatureProvider.js +2 -1
- package/dist/src/featureProvider/abstractFeatureProvider.js.map +1 -1
- package/dist/src/featureProvider/tileProviderFeatureProvider.d.ts +1 -1
- package/dist/src/featureProvider/tileProviderFeatureProvider.js +2 -2
- package/dist/src/featureProvider/tileProviderFeatureProvider.js.map +1 -1
- package/dist/src/featureProvider/wmsFeatureProvider.d.ts +1 -1
- package/dist/src/featureProvider/wmsFeatureProvider.js +4 -3
- package/dist/src/featureProvider/wmsFeatureProvider.js.map +1 -1
- package/dist/src/interaction/eventHandler.js +3 -3
- package/dist/src/interaction/eventHandler.js.map +1 -1
- package/dist/src/interaction/featureProviderInteraction.js +1 -1
- package/dist/src/interaction/featureProviderInteraction.js.map +1 -1
- package/dist/src/layer/cesium/cesiumTilesetCesiumImpl.d.ts +4 -1
- package/dist/src/layer/cesium/cesiumTilesetCesiumImpl.js +31 -2
- package/dist/src/layer/cesium/cesiumTilesetCesiumImpl.js.map +1 -1
- package/dist/src/layer/cesium/resourceHelper.d.ts +2 -0
- package/dist/src/layer/cesium/resourceHelper.js +12 -0
- package/dist/src/layer/cesium/resourceHelper.js.map +1 -0
- package/dist/src/layer/cesium/singleImageCesiumImpl.js +2 -1
- package/dist/src/layer/cesium/singleImageCesiumImpl.js.map +1 -1
- package/dist/src/layer/cesium/terrainCesiumImpl.js +1 -1
- package/dist/src/layer/cesium/terrainCesiumImpl.js.map +1 -1
- package/dist/src/layer/cesium/tmsCesiumImpl.js +2 -1
- package/dist/src/layer/cesium/tmsCesiumImpl.js.map +1 -1
- package/dist/src/layer/cesium/vectorRasterTileCesiumImpl.js +1 -0
- package/dist/src/layer/cesium/vectorRasterTileCesiumImpl.js.map +1 -1
- package/dist/src/layer/cesium/vectorTileImageryProvider.d.ts +2 -0
- package/dist/src/layer/cesium/vectorTileImageryProvider.js +3 -1
- package/dist/src/layer/cesium/vectorTileImageryProvider.js.map +1 -1
- package/dist/src/layer/cesium/wmsCesiumImpl.js +2 -1
- package/dist/src/layer/cesium/wmsCesiumImpl.js.map +1 -1
- package/dist/src/layer/cesium/wmtsCesiumImpl.js +2 -1
- package/dist/src/layer/cesium/wmtsCesiumImpl.js.map +1 -1
- package/dist/src/layer/cesiumTilesetLayer.d.ts +5 -1
- package/dist/src/layer/cesiumTilesetLayer.js +17 -7
- package/dist/src/layer/cesiumTilesetLayer.js.map +1 -1
- package/dist/src/layer/czmlLayer.js +2 -1
- package/dist/src/layer/czmlLayer.js.map +1 -1
- package/dist/src/layer/featureLayer.js +2 -2
- package/dist/src/layer/featureLayer.js.map +1 -1
- package/dist/src/layer/featureStoreLayer.js +8 -5
- package/dist/src/layer/featureStoreLayer.js.map +1 -1
- package/dist/src/layer/featureStoreLayerChanges.d.ts +20 -8
- package/dist/src/layer/featureStoreLayerChanges.js +26 -26
- package/dist/src/layer/featureStoreLayerChanges.js.map +1 -1
- package/dist/src/layer/featureStoreLayerState.d.ts +1 -5
- package/dist/src/layer/featureStoreLayerState.js +0 -9
- package/dist/src/layer/featureStoreLayerState.js.map +1 -1
- package/dist/src/layer/geojsonLayer.js +3 -2
- package/dist/src/layer/geojsonLayer.js.map +1 -1
- package/dist/src/layer/layer.d.ts +15 -0
- package/dist/src/layer/layer.js +30 -4
- package/dist/src/layer/layer.js.map +1 -1
- package/dist/src/layer/layerImplementation.d.ts +1 -0
- package/dist/src/layer/layerImplementation.js +2 -0
- package/dist/src/layer/layerImplementation.js.map +1 -1
- package/dist/src/layer/oblique/vectorObliqueImpl.js +9 -6
- package/dist/src/layer/oblique/vectorObliqueImpl.js.map +1 -1
- package/dist/src/layer/openlayers/loadFunctionHelpers.d.ts +2 -0
- package/dist/src/layer/openlayers/loadFunctionHelpers.js +20 -0
- package/dist/src/layer/openlayers/loadFunctionHelpers.js.map +1 -0
- package/dist/src/layer/openlayers/singleImageOpenlayersImpl.js +25 -1
- package/dist/src/layer/openlayers/singleImageOpenlayersImpl.js.map +1 -1
- package/dist/src/layer/openlayers/tmsOpenlayersImpl.js +9 -1
- package/dist/src/layer/openlayers/tmsOpenlayersImpl.js.map +1 -1
- package/dist/src/layer/openlayers/vectorTileOpenlayersImpl.js +1 -1
- package/dist/src/layer/openlayers/vectorTileOpenlayersImpl.js.map +1 -1
- package/dist/src/layer/openlayers/wmsOpenlayersImpl.d.ts +4 -1
- package/dist/src/layer/openlayers/wmsOpenlayersImpl.js +20 -1
- package/dist/src/layer/openlayers/wmsOpenlayersImpl.js.map +1 -1
- package/dist/src/layer/openlayers/wmtsOpenlayersImpl.js +9 -1
- package/dist/src/layer/openlayers/wmtsOpenlayersImpl.js.map +1 -1
- package/dist/src/layer/pointCloudLayer.js +2 -2
- package/dist/src/layer/pointCloudLayer.js.map +1 -1
- package/dist/src/layer/terrainHelpers.d.ts +3 -3
- package/dist/src/layer/terrainHelpers.js +12 -7
- package/dist/src/layer/terrainHelpers.js.map +1 -1
- package/dist/src/layer/terrainLayer.js +1 -1
- package/dist/src/layer/terrainLayer.js.map +1 -1
- package/dist/src/layer/tileProvider/mvtTileProvider.d.ts +1 -1
- package/dist/src/layer/tileProvider/mvtTileProvider.js +4 -3
- package/dist/src/layer/tileProvider/mvtTileProvider.js.map +1 -1
- package/dist/src/layer/tileProvider/staticGeojsonTileProvider.d.ts +1 -1
- package/dist/src/layer/tileProvider/staticGeojsonTileProvider.js +4 -3
- package/dist/src/layer/tileProvider/staticGeojsonTileProvider.js.map +1 -1
- package/dist/src/layer/tileProvider/tileProvider.d.ts +14 -11
- package/dist/src/layer/tileProvider/tileProvider.js +23 -20
- package/dist/src/layer/tileProvider/tileProvider.js.map +1 -1
- package/dist/src/layer/tileProvider/urlTemplateTileProvider.d.ts +1 -1
- package/dist/src/layer/tileProvider/urlTemplateTileProvider.js +4 -3
- package/dist/src/layer/tileProvider/urlTemplateTileProvider.js.map +1 -1
- package/dist/src/layer/vectorLayer.d.ts +1 -2
- package/dist/src/layer/vectorLayer.js +3 -3
- package/dist/src/layer/vectorLayer.js.map +1 -1
- package/dist/src/layer/vectorProperties.d.ts +11 -16
- package/dist/src/layer/vectorProperties.js +16 -13
- package/dist/src/layer/vectorProperties.js.map +1 -1
- package/dist/src/layer/wfsLayer.js +9 -6
- package/dist/src/layer/wfsLayer.js.map +1 -1
- package/dist/src/layer/wmsHelpers.d.ts +10 -0
- package/dist/src/layer/wmsHelpers.js +53 -12
- package/dist/src/layer/wmsHelpers.js.map +1 -1
- package/dist/src/layer/wmsLayer.d.ts +6 -0
- package/dist/src/layer/wmsLayer.js +5 -2
- package/dist/src/layer/wmsLayer.js.map +1 -1
- package/dist/src/map/cameraLimiter.d.ts +5 -0
- package/dist/src/map/cameraLimiter.js +11 -4
- package/dist/src/map/cameraLimiter.js.map +1 -1
- package/dist/src/map/cesiumMap.d.ts +20 -1
- package/dist/src/map/cesiumMap.js +51 -2
- package/dist/src/map/cesiumMap.js.map +1 -1
- package/dist/src/map/vcsMap.js +2 -2
- package/dist/src/map/vcsMap.js.map +1 -1
- package/dist/src/oblique/helpers.d.ts +1 -1
- package/dist/src/oblique/helpers.js +5 -9
- package/dist/src/oblique/helpers.js.map +1 -1
- package/dist/src/oblique/obliqueCollection.d.ts +1 -0
- package/dist/src/oblique/obliqueCollection.js +1 -1
- package/dist/src/oblique/obliqueCollection.js.map +1 -1
- package/dist/src/oblique/obliqueDataSet.d.ts +3 -1
- package/dist/src/oblique/obliqueDataSet.js +13 -6
- package/dist/src/oblique/obliqueDataSet.js.map +1 -1
- package/dist/src/oblique/obliqueImageMeta.d.ts +2 -0
- package/dist/src/oblique/obliqueImageMeta.js +2 -0
- package/dist/src/oblique/obliqueImageMeta.js.map +1 -1
- package/dist/src/oblique/obliqueView.d.ts +1 -0
- package/dist/src/oblique/obliqueView.js +12 -2
- package/dist/src/oblique/obliqueView.js.map +1 -1
- package/dist/src/oblique/parseImageJson.d.ts +6 -5
- package/dist/src/oblique/parseImageJson.js +7 -5
- package/dist/src/oblique/parseImageJson.js.map +1 -1
- package/dist/src/ol/geom/circle.js.map +1 -1
- package/dist/src/style/declarativeStyleItem.js +10 -2
- package/dist/src/style/declarativeStyleItem.js.map +1 -1
- package/dist/src/style/styleFactory.js +2 -2
- package/dist/src/style/styleFactory.js.map +1 -1
- package/dist/src/style/styleHelpers.js +13 -3
- package/dist/src/style/styleHelpers.js.map +1 -1
- package/dist/src/style/vectorStyleItem.js +29 -16
- package/dist/src/style/vectorStyleItem.js.map +1 -1
- package/dist/src/util/clipping/clippingPlaneHelper.js +3 -3
- package/dist/src/util/clipping/clippingPlaneHelper.js.map +1 -1
- package/dist/src/util/editor/createFeatureSession.d.ts +2 -2
- package/dist/src/util/editor/createFeatureSession.js +2 -2
- package/dist/src/util/editor/createFeatureSession.js.map +1 -1
- package/dist/src/util/editor/editFeaturesSession.d.ts +2 -2
- package/dist/src/util/editor/editGeometrySession.d.ts +2 -2
- package/dist/src/util/editor/editorSessionHelpers.d.ts +2 -2
- package/dist/src/util/editor/selectFeaturesSession.d.ts +2 -2
- package/dist/src/util/editor/selectFeaturesSession.js +2 -2
- package/dist/src/util/editor/selectFeaturesSession.js.map +1 -1
- package/dist/src/util/featureconverter/arcToCesium.d.ts +1 -1
- package/dist/src/util/featureconverter/arcToCesium.js +5 -2
- package/dist/src/util/featureconverter/arcToCesium.js.map +1 -1
- package/dist/src/util/featureconverter/circleToCesium.d.ts +4 -2
- package/dist/src/util/featureconverter/circleToCesium.js +8 -3
- package/dist/src/util/featureconverter/circleToCesium.js.map +1 -1
- package/dist/src/util/featureconverter/extent3D.js.map +1 -1
- package/dist/src/util/featureconverter/featureconverterHelper.js +2 -2
- package/dist/src/util/featureconverter/featureconverterHelper.js.map +1 -1
- package/dist/src/util/featureconverter/lineStringToCesium.d.ts +3 -1
- package/dist/src/util/featureconverter/lineStringToCesium.js +7 -2
- package/dist/src/util/featureconverter/lineStringToCesium.js.map +1 -1
- package/dist/src/util/featureconverter/pointToCesium.js +1 -1
- package/dist/src/util/featureconverter/pointToCesium.js.map +1 -1
- package/dist/src/util/featureconverter/polygonToCesium.d.ts +3 -3
- package/dist/src/util/featureconverter/polygonToCesium.js +9 -15
- package/dist/src/util/featureconverter/polygonToCesium.js.map +1 -1
- package/dist/src/util/fetch.d.ts +2 -0
- package/dist/src/util/fetch.js +16 -0
- package/dist/src/util/fetch.js.map +1 -1
- package/dist/src/util/flight/flightAnchor.d.ts +23 -0
- package/dist/src/util/flight/flightAnchor.js +152 -0
- package/dist/src/util/flight/flightAnchor.js.map +1 -0
- package/dist/src/util/flight/flightCollection.d.ts +25 -0
- package/dist/src/util/flight/flightCollection.js +63 -0
- package/dist/src/util/flight/flightCollection.js.map +1 -0
- package/dist/src/util/flight/flightHelpers.d.ts +29 -0
- package/dist/src/util/flight/flightHelpers.js +134 -0
- package/dist/src/util/flight/flightHelpers.js.map +1 -0
- package/dist/src/util/flight/flightInstance.d.ts +57 -0
- package/dist/src/util/flight/flightInstance.js +166 -0
- package/dist/src/util/flight/flightInstance.js.map +1 -0
- package/dist/src/util/flight/flightPlayer.d.ts +30 -0
- package/dist/src/util/flight/flightPlayer.js +247 -0
- package/dist/src/util/flight/flightPlayer.js.map +1 -0
- package/dist/src/util/flight/flightVisualizer.d.ts +18 -0
- package/dist/src/util/flight/flightVisualizer.js +151 -0
- package/dist/src/util/flight/flightVisualizer.js.map +1 -0
- package/dist/src/util/hiddenObjects.d.ts +8 -0
- package/dist/src/util/hiddenObjects.js +17 -0
- package/dist/src/util/hiddenObjects.js.map +1 -0
- package/dist/src/util/mapCollection.js +2 -2
- package/dist/src/util/mapCollection.js.map +1 -1
- package/dist/src/util/overrideCollection.d.ts +8 -3
- package/dist/src/util/overrideCollection.js +17 -0
- package/dist/src/util/overrideCollection.js.map +1 -1
- package/dist/src/util/projection.js +5 -2
- package/dist/src/util/projection.js.map +1 -1
- package/dist/src/util/viewpoint.d.ts +1 -0
- package/dist/src/util/viewpoint.js +24 -7
- package/dist/src/util/viewpoint.js.map +1 -1
- package/dist/src/vcsApp.d.ts +10 -3
- package/dist/src/vcsApp.js +34 -15
- package/dist/src/vcsApp.js.map +1 -1
- package/dist/src/vcsModule.d.ts +4 -0
- package/dist/src/vcsModule.js.map +1 -1
- package/dist/tests/unit/helpers/cesiumHelpers.d.ts +2 -2
- package/dist/tests/unit/helpers/cesiumHelpers.js +2 -1
- package/dist/tests/unit/helpers/cesiumHelpers.js.map +1 -1
- package/dist/tests/unit/helpers/terrain/terrainData.d.ts +7 -0
- package/dist/tests/unit/helpers/terrain/terrainData.js +2 -2
- package/dist/tests/unit/helpers/terrain/terrainData.js.map +1 -1
- package/index.ts +39 -1
- package/package.json +4 -2
- package/src/classRegistry.ts +2 -2
- package/src/featureProvider/abstractFeatureProvider.ts +2 -0
- package/src/featureProvider/tileProviderFeatureProvider.ts +2 -0
- package/src/featureProvider/wmsFeatureProvider.ts +4 -2
- package/src/interaction/eventHandler.ts +3 -3
- package/src/interaction/featureProviderInteraction.ts +1 -0
- package/src/layer/cesium/cesiumTilesetCesiumImpl.ts +44 -5
- package/src/layer/cesium/resourceHelper.ts +15 -0
- package/src/layer/cesium/singleImageCesiumImpl.ts +2 -1
- package/src/layer/cesium/terrainCesiumImpl.ts +2 -1
- package/src/layer/cesium/tmsCesiumImpl.ts +2 -1
- package/src/layer/cesium/vectorRasterTileCesiumImpl.ts +1 -0
- package/src/layer/cesium/vectorTileImageryProvider.ts +10 -1
- package/src/layer/cesium/wmsCesiumImpl.ts +2 -1
- package/src/layer/cesium/wmtsCesiumImpl.ts +4 -2
- package/src/layer/cesiumTilesetLayer.ts +25 -7
- package/src/layer/czmlLayer.ts +2 -1
- package/src/layer/featureLayer.ts +2 -2
- package/src/layer/featureStoreLayer.ts +8 -8
- package/src/layer/featureStoreLayerChanges.ts +63 -45
- package/src/layer/featureStoreLayerState.ts +6 -5
- package/src/layer/geojsonLayer.ts +3 -3
- package/src/layer/layer.ts +41 -4
- package/src/layer/layerImplementation.ts +3 -0
- package/src/layer/oblique/vectorObliqueImpl.ts +9 -8
- package/src/layer/openlayers/loadFunctionHelpers.ts +24 -0
- package/src/layer/openlayers/singleImageOpenlayersImpl.ts +25 -1
- package/src/layer/openlayers/tmsOpenlayersImpl.ts +8 -1
- package/src/layer/openlayers/vectorTileOpenlayersImpl.ts +1 -0
- package/src/layer/openlayers/wmsOpenlayersImpl.ts +23 -2
- package/src/layer/openlayers/wmtsOpenlayersImpl.ts +8 -1
- package/src/layer/pointCloudLayer.ts +2 -2
- package/src/layer/terrainHelpers.ts +19 -6
- package/src/layer/terrainLayer.ts +8 -4
- package/src/layer/tileProvider/mvtTileProvider.ts +9 -3
- package/src/layer/tileProvider/staticGeojsonTileProvider.ts +9 -3
- package/src/layer/tileProvider/tileProvider.ts +49 -13
- package/src/layer/tileProvider/urlTemplateTileProvider.ts +10 -3
- package/src/layer/vectorLayer.ts +9 -9
- package/src/layer/vectorProperties.ts +46 -22
- package/src/layer/wfsLayer.ts +9 -6
- package/src/layer/wmsHelpers.ts +78 -10
- package/src/layer/wmsLayer.ts +11 -2
- package/src/map/cameraLimiter.ts +21 -2
- package/src/map/cesiumMap.ts +67 -2
- package/src/map/vcsMap.ts +2 -2
- package/src/oblique/helpers.ts +5 -13
- package/src/oblique/obliqueCollection.ts +2 -0
- package/src/oblique/obliqueDataSet.ts +16 -2
- package/src/oblique/obliqueImageMeta.ts +4 -0
- package/src/oblique/obliqueView.ts +12 -2
- package/src/oblique/parseImageJson.ts +7 -4
- package/src/ol/geojson.d.ts +1 -2
- package/src/ol/geom/circle.ts +1 -1
- package/src/style/declarativeStyleItem.ts +10 -2
- package/src/style/styleFactory.ts +2 -2
- package/src/style/styleHelpers.ts +13 -4
- package/src/style/vectorStyleItem.ts +32 -20
- package/src/util/clipping/clippingPlaneHelper.ts +3 -3
- package/src/util/editor/createFeatureSession.ts +9 -8
- package/src/util/editor/editFeaturesSession.ts +1 -1
- package/src/util/editor/editGeometrySession.ts +1 -1
- package/src/util/editor/editorSessionHelpers.ts +2 -2
- package/src/util/editor/selectFeaturesSession.ts +3 -3
- package/src/util/featureconverter/arcToCesium.ts +5 -1
- package/src/util/featureconverter/circleToCesium.ts +8 -2
- package/src/util/featureconverter/extent3D.ts +1 -1
- package/src/util/featureconverter/featureconverterHelper.ts +3 -5
- package/src/util/featureconverter/lineStringToCesium.ts +8 -1
- package/src/util/featureconverter/pointToCesium.ts +1 -1
- package/src/util/featureconverter/polygonToCesium.ts +6 -15
- package/src/util/fetch.ts +25 -0
- package/src/util/flight/flightAnchor.ts +195 -0
- package/src/util/flight/flightCollection.ts +78 -0
- package/src/util/flight/flightHelpers.ts +208 -0
- package/src/util/flight/flightInstance.ts +240 -0
- package/src/util/flight/flightPlayer.ts +326 -0
- package/src/util/flight/flightVisualizer.ts +202 -0
- package/src/util/hiddenObjects.ts +35 -0
- package/src/util/mapCollection.ts +2 -2
- package/src/util/overrideCollection.ts +26 -3
- package/src/util/projection.ts +5 -2
- package/src/util/viewpoint.ts +27 -7
- package/src/vcsApp.ts +56 -15
- package/src/vcsModule.ts +4 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { check, is, maybe, PatternFor } from '@vcsuite/check';
|
|
2
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
3
|
+
import type { Feature as GeojsonFeature, Point as GeojsonPoint } from 'geojson';
|
|
4
|
+
import { type Coordinate, equals as coordinateEquals } from 'ol/coordinate.js';
|
|
5
|
+
import VcsEvent from '../../vcsEvent.js';
|
|
6
|
+
import Viewpoint from '../viewpoint.js';
|
|
7
|
+
|
|
8
|
+
type FlightAnchorFeatureProperties = {
|
|
9
|
+
heading: number;
|
|
10
|
+
pitch: number;
|
|
11
|
+
roll: number;
|
|
12
|
+
duration: number;
|
|
13
|
+
title?: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type FlightAnchorGeojsonFeature = GeojsonFeature<
|
|
17
|
+
GeojsonPoint,
|
|
18
|
+
FlightAnchorFeatureProperties
|
|
19
|
+
>;
|
|
20
|
+
|
|
21
|
+
export type FlightAnchor = FlightAnchorFeatureProperties & {
|
|
22
|
+
readonly changed: VcsEvent<void>;
|
|
23
|
+
readonly name: string;
|
|
24
|
+
coordinate: Coordinate;
|
|
25
|
+
destroy(): void;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
type FlightAnchorOptions = Omit<FlightAnchor, 'changed' | 'destroy'>;
|
|
29
|
+
|
|
30
|
+
const flightAnchorOptionsPattern: PatternFor<FlightAnchorOptions> = {
|
|
31
|
+
name: String,
|
|
32
|
+
coordinate: [Number],
|
|
33
|
+
heading: Number,
|
|
34
|
+
pitch: Number,
|
|
35
|
+
roll: Number,
|
|
36
|
+
duration: Number,
|
|
37
|
+
title: maybe(String),
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
function isOptions(options: unknown): options is FlightAnchorOptions {
|
|
41
|
+
return (
|
|
42
|
+
is(options, flightAnchorOptionsPattern) && options.coordinate.length === 3
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function fromOptions(options: FlightAnchorOptions): FlightAnchor {
|
|
47
|
+
check(options, flightAnchorOptionsPattern);
|
|
48
|
+
|
|
49
|
+
const changed = new VcsEvent<void>();
|
|
50
|
+
const { name } = options;
|
|
51
|
+
let { title, heading, pitch, roll, coordinate, duration } = options;
|
|
52
|
+
coordinate = coordinate.slice();
|
|
53
|
+
|
|
54
|
+
return {
|
|
55
|
+
get changed(): VcsEvent<void> {
|
|
56
|
+
return changed;
|
|
57
|
+
},
|
|
58
|
+
get name(): string {
|
|
59
|
+
return name;
|
|
60
|
+
},
|
|
61
|
+
get coordinate(): Coordinate {
|
|
62
|
+
return coordinate;
|
|
63
|
+
},
|
|
64
|
+
set coordinate(value: Coordinate) {
|
|
65
|
+
check(value, [Number]);
|
|
66
|
+
check(value.length, 3);
|
|
67
|
+
|
|
68
|
+
if (!coordinateEquals(coordinate, value)) {
|
|
69
|
+
coordinate = value.slice();
|
|
70
|
+
changed.raiseEvent();
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
get heading(): number {
|
|
74
|
+
return heading;
|
|
75
|
+
},
|
|
76
|
+
set heading(value: number) {
|
|
77
|
+
check(value, Number);
|
|
78
|
+
if (heading !== value) {
|
|
79
|
+
heading = value;
|
|
80
|
+
changed.raiseEvent();
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
get pitch(): number {
|
|
84
|
+
return pitch;
|
|
85
|
+
},
|
|
86
|
+
set pitch(value: number) {
|
|
87
|
+
check(value, Number);
|
|
88
|
+
if (pitch !== value) {
|
|
89
|
+
pitch = value;
|
|
90
|
+
changed.raiseEvent();
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
get roll(): number {
|
|
94
|
+
return roll;
|
|
95
|
+
},
|
|
96
|
+
set roll(value: number) {
|
|
97
|
+
check(value, Number);
|
|
98
|
+
if (roll !== value) {
|
|
99
|
+
roll = value;
|
|
100
|
+
changed.raiseEvent();
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
get duration(): number {
|
|
104
|
+
return duration;
|
|
105
|
+
},
|
|
106
|
+
set duration(value: number) {
|
|
107
|
+
check(value, Number);
|
|
108
|
+
if (duration !== value) {
|
|
109
|
+
duration = value;
|
|
110
|
+
changed.raiseEvent();
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
get title(): string | undefined {
|
|
114
|
+
return title;
|
|
115
|
+
},
|
|
116
|
+
set title(value: string | undefined) {
|
|
117
|
+
check(value, maybe(String));
|
|
118
|
+
|
|
119
|
+
if (title !== value) {
|
|
120
|
+
title = value;
|
|
121
|
+
changed.raiseEvent();
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
destroy(): void {
|
|
125
|
+
changed.destroy();
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function anchorFromViewpoint(
|
|
131
|
+
viewpoint: Viewpoint,
|
|
132
|
+
): FlightAnchor | undefined {
|
|
133
|
+
if (!viewpoint.cameraPosition) {
|
|
134
|
+
return undefined;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return fromOptions({
|
|
138
|
+
...viewpoint,
|
|
139
|
+
coordinate: viewpoint.cameraPosition,
|
|
140
|
+
duration: viewpoint.duration ?? 1,
|
|
141
|
+
title: viewpoint.properties.title as string | undefined,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export function anchorFromGeojsonFeature(
|
|
146
|
+
feature: FlightAnchorGeojsonFeature,
|
|
147
|
+
): FlightAnchor | undefined {
|
|
148
|
+
const options = {
|
|
149
|
+
...feature.properties,
|
|
150
|
+
name: String(feature.id) || uuidv4(),
|
|
151
|
+
coordinate: feature.geometry.coordinates,
|
|
152
|
+
};
|
|
153
|
+
if (isOptions(options)) {
|
|
154
|
+
return fromOptions(options);
|
|
155
|
+
}
|
|
156
|
+
return undefined;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export function anchorToViewpoint(anchor: FlightAnchor): Viewpoint {
|
|
160
|
+
return new Viewpoint({
|
|
161
|
+
name: anchor.name,
|
|
162
|
+
cameraPosition: anchor.coordinate.slice(),
|
|
163
|
+
heading: anchor.heading,
|
|
164
|
+
pitch: anchor.pitch,
|
|
165
|
+
roll: anchor.roll,
|
|
166
|
+
duration: anchor.duration,
|
|
167
|
+
properties: {
|
|
168
|
+
title: anchor.title,
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export function anchorToGeojsonFeature(
|
|
174
|
+
anchor: FlightAnchor,
|
|
175
|
+
): FlightAnchorGeojsonFeature {
|
|
176
|
+
const properties: FlightAnchorFeatureProperties = {
|
|
177
|
+
heading: anchor.heading,
|
|
178
|
+
pitch: anchor.pitch,
|
|
179
|
+
roll: anchor.roll,
|
|
180
|
+
duration: anchor.duration,
|
|
181
|
+
};
|
|
182
|
+
if (anchor.title) {
|
|
183
|
+
properties.title = anchor.title;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return {
|
|
187
|
+
type: 'Feature',
|
|
188
|
+
id: anchor.name,
|
|
189
|
+
geometry: {
|
|
190
|
+
type: 'Point',
|
|
191
|
+
coordinates: anchor.coordinate.slice(),
|
|
192
|
+
},
|
|
193
|
+
properties,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import Collection from '../collection.js';
|
|
2
|
+
import { createFlightPlayer, FlightPlayer } from './flightPlayer.js';
|
|
3
|
+
import VcsEvent from '../../vcsEvent.js';
|
|
4
|
+
import FlightInstance from './flightInstance.js';
|
|
5
|
+
import type VcsApp from '../../vcsApp.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A collection of flights. Provides playFlight API, which returns a FlightPlayer.
|
|
9
|
+
* Emits playerChanged event, whenever another flight is played.
|
|
10
|
+
*/
|
|
11
|
+
class FlightCollection extends Collection<FlightInstance> {
|
|
12
|
+
private readonly _app: VcsApp;
|
|
13
|
+
|
|
14
|
+
private _player: FlightPlayer | undefined;
|
|
15
|
+
|
|
16
|
+
playerChanged: VcsEvent<FlightPlayer | undefined>;
|
|
17
|
+
|
|
18
|
+
private _playerDestroyedListener: () => void;
|
|
19
|
+
|
|
20
|
+
constructor(app: VcsApp) {
|
|
21
|
+
super();
|
|
22
|
+
|
|
23
|
+
this._app = app;
|
|
24
|
+
this._player = undefined;
|
|
25
|
+
this.playerChanged = new VcsEvent<FlightPlayer | undefined>();
|
|
26
|
+
this._playerDestroyedListener = (): void => {};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
get player(): FlightPlayer | undefined {
|
|
30
|
+
return this._player;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
remove(item: FlightInstance): void {
|
|
34
|
+
if (this._player?.flightInstanceName === item.name) {
|
|
35
|
+
this._player.stop();
|
|
36
|
+
this._player.destroy();
|
|
37
|
+
}
|
|
38
|
+
super.remove(item);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Creates a FlightPlayer for a flight instance, if not already existing for provided instance
|
|
43
|
+
* @param flight
|
|
44
|
+
*/
|
|
45
|
+
async setPlayerForFlight(
|
|
46
|
+
flight: FlightInstance,
|
|
47
|
+
): Promise<FlightPlayer | undefined> {
|
|
48
|
+
if (this._player?.flightInstanceName === flight.name) {
|
|
49
|
+
return this._player;
|
|
50
|
+
} else if (this._player) {
|
|
51
|
+
this._playerDestroyedListener();
|
|
52
|
+
this._player.stop();
|
|
53
|
+
this._player.destroy();
|
|
54
|
+
}
|
|
55
|
+
this._player = await createFlightPlayer(flight, this._app);
|
|
56
|
+
this.playerChanged.raiseEvent(this._player);
|
|
57
|
+
this._playerDestroyedListener = this._player.destroyed.addEventListener(
|
|
58
|
+
() => {
|
|
59
|
+
this._player = undefined;
|
|
60
|
+
this.playerChanged.raiseEvent(undefined);
|
|
61
|
+
},
|
|
62
|
+
);
|
|
63
|
+
return this._player;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
destroy(): void {
|
|
67
|
+
if (this._player) {
|
|
68
|
+
this._player.stop();
|
|
69
|
+
this._player.destroy();
|
|
70
|
+
this._player = undefined;
|
|
71
|
+
}
|
|
72
|
+
this.playerChanged.destroy();
|
|
73
|
+
this._playerDestroyedListener();
|
|
74
|
+
super.destroy();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export default FlightCollection;
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HeadingPitchRoll,
|
|
3
|
+
Cartesian3,
|
|
4
|
+
Quaternion,
|
|
5
|
+
CatmullRomSpline,
|
|
6
|
+
LinearSpline,
|
|
7
|
+
QuaternionSpline,
|
|
8
|
+
Cartographic,
|
|
9
|
+
Math as CesiumMath,
|
|
10
|
+
} from '@vcmap-cesium/engine';
|
|
11
|
+
import type {
|
|
12
|
+
FeatureCollection,
|
|
13
|
+
Point as GeojsonPoint,
|
|
14
|
+
LineString as GeojsonLineString,
|
|
15
|
+
} from 'geojson';
|
|
16
|
+
import type { Coordinate } from 'ol/coordinate.js';
|
|
17
|
+
import type {
|
|
18
|
+
// eslint-disable-next-line import/no-named-default
|
|
19
|
+
default as FlightInstance,
|
|
20
|
+
FlightInstanceMeta,
|
|
21
|
+
FlightInstanceOptions,
|
|
22
|
+
} from './flightInstance.js';
|
|
23
|
+
import { vcsMetaVersion } from '../../layer/vectorProperties.js';
|
|
24
|
+
import { FlightAnchorGeojsonFeature } from './flightAnchor.js';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* exports a flight as GeoJson FeatureCollection
|
|
28
|
+
* {Object} vcsMeta.flightOptions: flight settings
|
|
29
|
+
* {Array} feature: viewpoints
|
|
30
|
+
*
|
|
31
|
+
* @param flightInstance
|
|
32
|
+
*/
|
|
33
|
+
export function exportFlightAsGeoJson(
|
|
34
|
+
flightInstance: FlightInstance,
|
|
35
|
+
): FeatureCollection<GeojsonPoint> {
|
|
36
|
+
const options = flightInstance.toJSON();
|
|
37
|
+
const flightOptions: FlightInstanceMeta = {};
|
|
38
|
+
if (options.loop != null) {
|
|
39
|
+
flightOptions.loop = options.loop;
|
|
40
|
+
}
|
|
41
|
+
if (options.interpolation != null) {
|
|
42
|
+
flightOptions.interpolation = options.interpolation;
|
|
43
|
+
}
|
|
44
|
+
if (options.multiplier != null) {
|
|
45
|
+
flightOptions.multiplier = options.multiplier;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
type: 'FeatureCollection',
|
|
50
|
+
features: options.anchors ?? [],
|
|
51
|
+
vcsMeta: {
|
|
52
|
+
version: vcsMetaVersion,
|
|
53
|
+
flightOptions: options,
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function getSplineAndTimesForInstance(flightInstance: FlightInstance): {
|
|
59
|
+
destinationSpline: CatmullRomSpline | LinearSpline;
|
|
60
|
+
quaternionSpline: QuaternionSpline;
|
|
61
|
+
times: number[];
|
|
62
|
+
} {
|
|
63
|
+
const { loop, anchors } = flightInstance;
|
|
64
|
+
const anchorsArray = [...anchors];
|
|
65
|
+
const length = loop ? anchors.size + 1 : anchors.size;
|
|
66
|
+
const points = new Array(length) as Cartesian3[];
|
|
67
|
+
const quaternions = new Array(length) as Quaternion[];
|
|
68
|
+
const times = new Array(length) as number[];
|
|
69
|
+
|
|
70
|
+
anchorsArray.forEach((anchor, index) => {
|
|
71
|
+
points[index] = Cartesian3.fromDegrees(
|
|
72
|
+
anchor.coordinate[0],
|
|
73
|
+
anchor.coordinate[1],
|
|
74
|
+
anchor.coordinate[2],
|
|
75
|
+
);
|
|
76
|
+
quaternions[index] = Quaternion.fromHeadingPitchRoll(
|
|
77
|
+
HeadingPitchRoll.fromDegrees(anchor.heading, anchor.pitch, anchor.roll),
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
if (index > 0) {
|
|
81
|
+
let previousDuration = anchorsArray[index - 1].duration;
|
|
82
|
+
if (!previousDuration) {
|
|
83
|
+
previousDuration =
|
|
84
|
+
Cartesian3.distance(points[index - 1], points[index]) / 300 || 1;
|
|
85
|
+
}
|
|
86
|
+
times[index] = times[index - 1] + previousDuration;
|
|
87
|
+
} else {
|
|
88
|
+
times[index] = 0;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
if (loop) {
|
|
93
|
+
points[length - 1] = Cartesian3.fromDegrees(
|
|
94
|
+
anchorsArray[0].coordinate[0],
|
|
95
|
+
anchorsArray[0].coordinate[1],
|
|
96
|
+
anchorsArray[0].coordinate[2],
|
|
97
|
+
);
|
|
98
|
+
quaternions[length - 1] = Quaternion.fromHeadingPitchRoll(
|
|
99
|
+
HeadingPitchRoll.fromDegrees(
|
|
100
|
+
anchorsArray[0].heading,
|
|
101
|
+
anchorsArray[0].pitch,
|
|
102
|
+
anchorsArray[0].roll,
|
|
103
|
+
),
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
let loopDuration = anchorsArray[length - 2].duration;
|
|
107
|
+
if (!loopDuration) {
|
|
108
|
+
loopDuration =
|
|
109
|
+
Cartesian3.distance(points[length - 2], points[length - 1]) / 300 || 1;
|
|
110
|
+
}
|
|
111
|
+
times[length - 1] = times[length - 2] + loopDuration;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const destinationSpline =
|
|
115
|
+
flightInstance.interpolation === 'spline'
|
|
116
|
+
? new CatmullRomSpline({ times, points })
|
|
117
|
+
: new LinearSpline({ times, points });
|
|
118
|
+
const quaternionSpline = new QuaternionSpline({ times, points: quaternions });
|
|
119
|
+
|
|
120
|
+
return {
|
|
121
|
+
destinationSpline,
|
|
122
|
+
quaternionSpline,
|
|
123
|
+
times,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function getFlightPathCoordinatesFromInstance(
|
|
128
|
+
flightInstance: FlightInstance,
|
|
129
|
+
): Coordinate[] {
|
|
130
|
+
const pathCoordinates: Coordinate[] = [];
|
|
131
|
+
|
|
132
|
+
if (flightInstance.interpolation === 'spline') {
|
|
133
|
+
const { destinationSpline, times } =
|
|
134
|
+
getSplineAndTimesForInstance(flightInstance);
|
|
135
|
+
const scratchCartographic = new Cartographic();
|
|
136
|
+
const addCoordinateFromTime = (time: number): void => {
|
|
137
|
+
Cartographic.fromCartesian(
|
|
138
|
+
destinationSpline.evaluate(time) as Cartesian3,
|
|
139
|
+
undefined,
|
|
140
|
+
scratchCartographic,
|
|
141
|
+
);
|
|
142
|
+
pathCoordinates.push([
|
|
143
|
+
CesiumMath.toDegrees(scratchCartographic.longitude),
|
|
144
|
+
CesiumMath.toDegrees(scratchCartographic.latitude),
|
|
145
|
+
scratchCartographic.height,
|
|
146
|
+
]);
|
|
147
|
+
};
|
|
148
|
+
const endTime = times[times.length - 1];
|
|
149
|
+
const step = endTime / 0.2 > 500 ? endTime / 500 : 0.2;
|
|
150
|
+
for (let i = 0; i < endTime; i += step) {
|
|
151
|
+
addCoordinateFromTime(i);
|
|
152
|
+
}
|
|
153
|
+
addCoordinateFromTime(endTime);
|
|
154
|
+
} else {
|
|
155
|
+
for (const anchor of flightInstance.anchors) {
|
|
156
|
+
pathCoordinates.push(anchor.coordinate);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (flightInstance.loop) {
|
|
160
|
+
pathCoordinates.push(pathCoordinates[0]);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return pathCoordinates;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export function exportFlightPathAsGeoJson(
|
|
168
|
+
flightInstance: FlightInstance,
|
|
169
|
+
): FeatureCollection<GeojsonLineString> {
|
|
170
|
+
const coordinates = getFlightPathCoordinatesFromInstance(flightInstance);
|
|
171
|
+
|
|
172
|
+
return {
|
|
173
|
+
type: 'FeatureCollection',
|
|
174
|
+
features: [
|
|
175
|
+
{
|
|
176
|
+
type: 'Feature',
|
|
177
|
+
geometry: {
|
|
178
|
+
type: 'LineString',
|
|
179
|
+
coordinates,
|
|
180
|
+
},
|
|
181
|
+
properties: {},
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* parses source and creates a flight Object
|
|
189
|
+
* @param {Object} collection GeoJSON
|
|
190
|
+
* containing:
|
|
191
|
+
* {Object} vcsMeta containing flightOptions
|
|
192
|
+
* {Array} features anchors of flightInstance
|
|
193
|
+
* @returns
|
|
194
|
+
*/
|
|
195
|
+
export function parseFlightOptionsFromGeoJson(
|
|
196
|
+
collection: FeatureCollection<
|
|
197
|
+
GeojsonPoint,
|
|
198
|
+
FlightAnchorGeojsonFeature['properties']
|
|
199
|
+
>,
|
|
200
|
+
): FlightInstanceOptions {
|
|
201
|
+
const flightOptions: Partial<FlightInstanceOptions> =
|
|
202
|
+
collection.vcsMeta && collection.vcsMeta.flightOptions
|
|
203
|
+
? collection.vcsMeta.flightOptions
|
|
204
|
+
: {};
|
|
205
|
+
|
|
206
|
+
flightOptions.anchors = collection.features;
|
|
207
|
+
return flightOptions;
|
|
208
|
+
}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import type { FeatureCollection, Point as GeojsonPoint } from 'geojson';
|
|
2
|
+
import { parseBoolean, parseNumber } from '@vcsuite/parsers';
|
|
3
|
+
import { check, oneOf } from '@vcsuite/check';
|
|
4
|
+
import VcsObject, { VcsObjectOptions } from '../../vcsObject.js';
|
|
5
|
+
import VcsEvent from '../../vcsEvent.js';
|
|
6
|
+
import { parseFlightOptionsFromGeoJson } from './flightHelpers.js';
|
|
7
|
+
import { requestJson } from '../fetch.js';
|
|
8
|
+
import {
|
|
9
|
+
FlightAnchor,
|
|
10
|
+
anchorFromGeojsonFeature,
|
|
11
|
+
anchorToGeojsonFeature,
|
|
12
|
+
FlightAnchorGeojsonFeature,
|
|
13
|
+
} from './flightAnchor.js';
|
|
14
|
+
import IndexedCollection from '../indexedCollection.js';
|
|
15
|
+
import { destroyCollection } from '../../vcsModuleHelpers.js';
|
|
16
|
+
|
|
17
|
+
export type FlightInterpolation = 'spline' | 'linear';
|
|
18
|
+
|
|
19
|
+
export type FlightInstanceMeta = VcsObjectOptions & {
|
|
20
|
+
multiplier?: number;
|
|
21
|
+
interpolation?: FlightInterpolation;
|
|
22
|
+
loop?: boolean;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type FlightInstanceOptions = FlightInstanceMeta & {
|
|
26
|
+
anchors?: FlightAnchorGeojsonFeature[];
|
|
27
|
+
url?: string;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
class FlightInstance extends VcsObject {
|
|
31
|
+
static get className(): string {
|
|
32
|
+
return 'FlightInstance';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
anchors: IndexedCollection<FlightAnchor>;
|
|
36
|
+
|
|
37
|
+
private _multiplier: number;
|
|
38
|
+
|
|
39
|
+
private _loop: boolean;
|
|
40
|
+
|
|
41
|
+
private _interpolation: FlightInterpolation;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Raised when anchors are added, removed, moved or changed
|
|
45
|
+
*/
|
|
46
|
+
anchorsChanged = new VcsEvent<void>();
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Raised when multiplier, loop or interpolation changes.
|
|
50
|
+
*/
|
|
51
|
+
propertyChanged = new VcsEvent<'multiplier' | 'loop' | 'interpolation'>();
|
|
52
|
+
|
|
53
|
+
private readonly _url: string | undefined;
|
|
54
|
+
|
|
55
|
+
private _readyPromise: Promise<void> | null = null;
|
|
56
|
+
|
|
57
|
+
private _anchorListeners: Map<string, () => void> = new Map();
|
|
58
|
+
|
|
59
|
+
static getDefaultOptions(): FlightInstanceOptions {
|
|
60
|
+
return {
|
|
61
|
+
multiplier: 1,
|
|
62
|
+
loop: false,
|
|
63
|
+
interpolation: 'spline',
|
|
64
|
+
anchors: [],
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
constructor(options: FlightInstanceOptions) {
|
|
69
|
+
super(options);
|
|
70
|
+
|
|
71
|
+
const defaultOptions = FlightInstance.getDefaultOptions();
|
|
72
|
+
const anchorsArray = (options.anchors ?? defaultOptions.anchors!)
|
|
73
|
+
.map(anchorFromGeojsonFeature)
|
|
74
|
+
.filter((a): a is FlightAnchor => !!a);
|
|
75
|
+
|
|
76
|
+
this.anchors = IndexedCollection.from(anchorsArray);
|
|
77
|
+
|
|
78
|
+
this._multiplier = parseNumber(
|
|
79
|
+
options.multiplier,
|
|
80
|
+
defaultOptions.multiplier,
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
this._loop = parseBoolean(options.loop, defaultOptions.loop);
|
|
84
|
+
|
|
85
|
+
this._interpolation =
|
|
86
|
+
options.interpolation || defaultOptions.interpolation!;
|
|
87
|
+
|
|
88
|
+
this.anchorsChanged = new VcsEvent();
|
|
89
|
+
|
|
90
|
+
this._url = options.url;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
get initialized(): boolean {
|
|
94
|
+
return !!this._readyPromise;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
get multiplier(): number {
|
|
98
|
+
return this._multiplier;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
set multiplier(value: number) {
|
|
102
|
+
check(value, Number);
|
|
103
|
+
|
|
104
|
+
if (this._multiplier !== value) {
|
|
105
|
+
this._multiplier = value;
|
|
106
|
+
this.propertyChanged.raiseEvent('multiplier');
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Whether this flight represents a circular flight path or not
|
|
112
|
+
*/
|
|
113
|
+
get loop(): boolean {
|
|
114
|
+
return this._loop;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
set loop(value: boolean) {
|
|
118
|
+
check(value, Boolean);
|
|
119
|
+
|
|
120
|
+
if (this._loop !== value) {
|
|
121
|
+
this._loop = value;
|
|
122
|
+
this.propertyChanged.raiseEvent('loop');
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
get interpolation(): FlightInterpolation {
|
|
127
|
+
return this._interpolation;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
set interpolation(value: FlightInterpolation) {
|
|
131
|
+
check(value, oneOf('linear', 'spline'));
|
|
132
|
+
|
|
133
|
+
if (this._interpolation !== value) {
|
|
134
|
+
this._interpolation = value;
|
|
135
|
+
this.propertyChanged.raiseEvent('interpolation');
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
initialize(): Promise<void> {
|
|
140
|
+
if (!this._readyPromise) {
|
|
141
|
+
if (this._url) {
|
|
142
|
+
this._readyPromise = requestJson<
|
|
143
|
+
FeatureCollection<
|
|
144
|
+
GeojsonPoint,
|
|
145
|
+
FlightAnchorGeojsonFeature['properties']
|
|
146
|
+
>
|
|
147
|
+
>(this._url).then((collection) => {
|
|
148
|
+
const instance = parseFlightOptionsFromGeoJson(collection);
|
|
149
|
+
(instance.anchors ?? [])
|
|
150
|
+
.map(anchorFromGeojsonFeature)
|
|
151
|
+
.filter((a): a is FlightAnchor => !!a)
|
|
152
|
+
.forEach((anchor) => this.anchors.add(anchor));
|
|
153
|
+
this._multiplier = instance.multiplier ?? this._multiplier;
|
|
154
|
+
this._loop = instance.loop ?? this._loop;
|
|
155
|
+
this._interpolation = instance.interpolation ?? this._interpolation;
|
|
156
|
+
});
|
|
157
|
+
} else {
|
|
158
|
+
this._readyPromise = Promise.resolve();
|
|
159
|
+
}
|
|
160
|
+
for (const anchor of this.anchors) {
|
|
161
|
+
this._anchorListeners.set(
|
|
162
|
+
anchor.name,
|
|
163
|
+
anchor.changed.addEventListener(() => {
|
|
164
|
+
this.anchorsChanged.raiseEvent();
|
|
165
|
+
}),
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
this.anchors.added.addEventListener((anchor) => {
|
|
170
|
+
this._anchorListeners.set(
|
|
171
|
+
anchor.name,
|
|
172
|
+
anchor.changed.addEventListener(() => {
|
|
173
|
+
this.anchorsChanged.raiseEvent();
|
|
174
|
+
}),
|
|
175
|
+
);
|
|
176
|
+
this.anchorsChanged.raiseEvent();
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
this.anchors.removed.addEventListener((anchor) => {
|
|
180
|
+
this._anchorListeners.get(anchor.name)?.();
|
|
181
|
+
this._anchorListeners.delete(anchor.name);
|
|
182
|
+
this.anchorsChanged.raiseEvent();
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
this.anchors.moved.addEventListener(() => {
|
|
186
|
+
this.anchorsChanged.raiseEvent();
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return this._readyPromise;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* checks if this flightInstance is valid. To be valid, a flight must have at least 2 anchors.
|
|
195
|
+
* @returns
|
|
196
|
+
*/
|
|
197
|
+
isValid(): boolean {
|
|
198
|
+
return this.anchors.size >= 2;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* returns an options object for this flight. if this flight was configured via an URL, only the url will be configured.
|
|
203
|
+
* @returns
|
|
204
|
+
*/
|
|
205
|
+
toJSON(): FlightInstanceOptions {
|
|
206
|
+
const config = super.toJSON() as FlightInstanceOptions;
|
|
207
|
+
|
|
208
|
+
if (this._url) {
|
|
209
|
+
config.url = this._url;
|
|
210
|
+
return config;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const defaultOptions = FlightInstance.getDefaultOptions();
|
|
214
|
+
if (this._multiplier !== defaultOptions.multiplier) {
|
|
215
|
+
config.multiplier = this._multiplier;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (this._loop !== defaultOptions.loop) {
|
|
219
|
+
config.loop = this._loop;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (this._interpolation !== defaultOptions.interpolation) {
|
|
223
|
+
config.interpolation = this._interpolation;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
if (this.anchors.size > 0) {
|
|
227
|
+
config.anchors = [...this.anchors].map(anchorToGeojsonFeature);
|
|
228
|
+
}
|
|
229
|
+
return config;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
destroy(): void {
|
|
233
|
+
this.anchorsChanged.destroy();
|
|
234
|
+
destroyCollection(this.anchors);
|
|
235
|
+
this._anchorListeners.clear();
|
|
236
|
+
super.destroy();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export default FlightInstance;
|