forked from hpi-sam/digital-fuesim-manv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
feature-manager.ts
48 lines (43 loc) · 1.67 KB
/
feature-manager.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import type { Feature, MapBrowserEvent } from 'ol';
import type { Geometry } from 'ol/geom';
import type { TranslateEvent } from 'ol/interaction/Translate';
import type VectorLayer from 'ol/layer/Vector';
import type VectorSource from 'ol/source/Vector';
import type { Subject } from 'rxjs';
// eslint-disable-next-line @typescript-eslint/no-shadow
import type { Element } from 'digital-fuesim-manv-shared';
import type { OlMapInteractionsManager } from './ol-map-interactions-manager';
/**
* The Api to interact with a feature
*/
export interface FeatureManager<T extends Geometry> {
readonly layer: VectorLayer<VectorSource>;
/**
* This method is called when the user clicks on a feature on this layer.
* @param event The click event that triggered the call
* @param feature The feature that was clicked on
*/
onFeatureClicked: (
event: MapBrowserEvent<any>,
feature: Feature<T>
) => void;
/**
* @returns whether the feature can be moved by the user
*/
isFeatureTranslatable: (feature: Feature<T>) => boolean;
/**
* @param dropEvent The drop event that triggered the call
* @param droppedFeature is dropped on {@link droppedOnFeature}
* @param droppedOnFeature is the feature that {@link droppedFeature} is dropped on
* @returns wether the event should not propagate further (to the features behind {@link droppedOnFeature}).
*/
onFeatureDrop: (
droppedElement: Element,
droppedOnFeature: Feature<T>,
dropEvent?: TranslateEvent
) => boolean;
register: (
destroy$: Subject<void>,
mapInteractionsManager: OlMapInteractionsManager
) => void;
}