aur-openlayers 19.6.10 → 19.6.11
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.
|
@@ -2665,6 +2665,117 @@ class BufferDecorationManager {
|
|
|
2665
2665
|
}
|
|
2666
2666
|
}
|
|
2667
2667
|
|
|
2668
|
+
/** Creates a point Feature at `coord` with the given style and id. */
|
|
2669
|
+
function makePoint(coord, style, id) {
|
|
2670
|
+
const f = new Feature({ geometry: new Point(coord) });
|
|
2671
|
+
f.setId(id);
|
|
2672
|
+
f.setStyle(Array.isArray(style) ? style : [style]);
|
|
2673
|
+
return f;
|
|
2674
|
+
}
|
|
2675
|
+
class StartFinishDecorationManager {
|
|
2676
|
+
source = new VectorSource();
|
|
2677
|
+
layer;
|
|
2678
|
+
config;
|
|
2679
|
+
map;
|
|
2680
|
+
parentLayer;
|
|
2681
|
+
parentApi;
|
|
2682
|
+
moveEndKey;
|
|
2683
|
+
visibilityKey;
|
|
2684
|
+
unsubCollection;
|
|
2685
|
+
unsubChanges;
|
|
2686
|
+
rafId = null;
|
|
2687
|
+
constructor(options) {
|
|
2688
|
+
this.config = options.config;
|
|
2689
|
+
this.map = options.map;
|
|
2690
|
+
this.parentLayer = options.parentLayer;
|
|
2691
|
+
this.parentApi = options.parentApi;
|
|
2692
|
+
const parentZ = this.parentLayer.getZIndex() ?? 0; // ?? 0 mirrors BufferDecorationManager: layers without explicit zIndex default to 0, so decoration sits at parentZ + 3
|
|
2693
|
+
this.layer = new VectorLayer({
|
|
2694
|
+
source: this.source,
|
|
2695
|
+
zIndex: parentZ + 3,
|
|
2696
|
+
});
|
|
2697
|
+
this.layer.set('id', '__decoration_start_finish');
|
|
2698
|
+
this.map.addLayer(this.layer);
|
|
2699
|
+
this.syncVisibility();
|
|
2700
|
+
this.syncOpacity();
|
|
2701
|
+
this.visibilityKey = this.parentLayer.on('change:visible', () => {
|
|
2702
|
+
this.syncVisibility();
|
|
2703
|
+
if (this.parentLayer.getVisible()) {
|
|
2704
|
+
this.scheduleUpdate();
|
|
2705
|
+
}
|
|
2706
|
+
});
|
|
2707
|
+
this.moveEndKey = this.map.on('moveend', () => this.scheduleUpdate());
|
|
2708
|
+
this.unsubCollection = this.parentApi.onModelsCollectionChanged(() => this.scheduleUpdate());
|
|
2709
|
+
this.unsubChanges = this.parentApi.onModelsChanged?.(() => this.scheduleUpdate());
|
|
2710
|
+
}
|
|
2711
|
+
scheduleUpdate() {
|
|
2712
|
+
if (this.rafId !== null)
|
|
2713
|
+
return;
|
|
2714
|
+
this.rafId = requestAnimationFrame(() => {
|
|
2715
|
+
this.rafId = null;
|
|
2716
|
+
this.rebuild();
|
|
2717
|
+
});
|
|
2718
|
+
}
|
|
2719
|
+
rebuild() {
|
|
2720
|
+
this.syncVisibility();
|
|
2721
|
+
this.syncOpacity();
|
|
2722
|
+
if (!this.parentLayer.getVisible()) {
|
|
2723
|
+
this.source.clear();
|
|
2724
|
+
return;
|
|
2725
|
+
}
|
|
2726
|
+
const parentSource = this.parentLayer.getSource();
|
|
2727
|
+
if (!parentSource) {
|
|
2728
|
+
this.source.clear();
|
|
2729
|
+
return;
|
|
2730
|
+
}
|
|
2731
|
+
const { start, finish, collapsed } = this.config;
|
|
2732
|
+
const features = [];
|
|
2733
|
+
parentSource.getFeatures().forEach((feature, i) => {
|
|
2734
|
+
const geom = feature.getGeometry();
|
|
2735
|
+
if (!geom)
|
|
2736
|
+
return;
|
|
2737
|
+
if (!(geom instanceof LineString) && !(geom instanceof MultiLineString))
|
|
2738
|
+
return;
|
|
2739
|
+
const first = geom.getFirstCoordinate();
|
|
2740
|
+
const last = geom.getLastCoordinate();
|
|
2741
|
+
if (!first || !last || first.length < 2 || last.length < 2)
|
|
2742
|
+
return;
|
|
2743
|
+
const isCollapsed = first[0] === last[0] && first[1] === last[1];
|
|
2744
|
+
if (isCollapsed) {
|
|
2745
|
+
const style = collapsed ?? start ?? finish;
|
|
2746
|
+
if (style)
|
|
2747
|
+
features.push(makePoint(first, style, `__startfinish_collapsed_${i}`));
|
|
2748
|
+
return;
|
|
2749
|
+
}
|
|
2750
|
+
if (start)
|
|
2751
|
+
features.push(makePoint(first, start, `__startfinish_start_${i}`));
|
|
2752
|
+
if (finish)
|
|
2753
|
+
features.push(makePoint(last, finish, `__startfinish_finish_${i}`));
|
|
2754
|
+
});
|
|
2755
|
+
this.source.clear();
|
|
2756
|
+
if (features.length > 0) {
|
|
2757
|
+
this.source.addFeatures(features);
|
|
2758
|
+
}
|
|
2759
|
+
}
|
|
2760
|
+
syncVisibility() {
|
|
2761
|
+
this.layer.setVisible(this.parentLayer.getVisible());
|
|
2762
|
+
}
|
|
2763
|
+
syncOpacity() {
|
|
2764
|
+
this.layer.setOpacity(this.parentLayer.getOpacity());
|
|
2765
|
+
}
|
|
2766
|
+
dispose() {
|
|
2767
|
+
if (this.rafId !== null) {
|
|
2768
|
+
cancelAnimationFrame(this.rafId);
|
|
2769
|
+
this.rafId = null;
|
|
2770
|
+
}
|
|
2771
|
+
unByKey(this.moveEndKey);
|
|
2772
|
+
unByKey(this.visibilityKey);
|
|
2773
|
+
this.unsubCollection();
|
|
2774
|
+
this.unsubChanges?.();
|
|
2775
|
+
this.map.removeLayer(this.layer);
|
|
2776
|
+
}
|
|
2777
|
+
}
|
|
2778
|
+
|
|
2668
2779
|
class LayerManager {
|
|
2669
2780
|
map;
|
|
2670
2781
|
layers = {};
|
|
@@ -2740,6 +2851,17 @@ class LayerManager {
|
|
|
2740
2851
|
});
|
|
2741
2852
|
this.decorationManagers.push(decorationManager);
|
|
2742
2853
|
}
|
|
2854
|
+
if (descriptor.feature.decorations?.startFinish) {
|
|
2855
|
+
const sf = descriptor.feature.decorations.startFinish;
|
|
2856
|
+
if (sf.start || sf.finish || sf.collapsed) {
|
|
2857
|
+
this.decorationManagers.push(new StartFinishDecorationManager({
|
|
2858
|
+
map: this.map,
|
|
2859
|
+
parentLayer: layer,
|
|
2860
|
+
parentApi: api,
|
|
2861
|
+
config: sf,
|
|
2862
|
+
}));
|
|
2863
|
+
}
|
|
2864
|
+
}
|
|
2743
2865
|
});
|
|
2744
2866
|
this.interactions = new InteractionManager({
|
|
2745
2867
|
ctx,
|