aur-openlayers 19.6.9 → 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.
@@ -2360,7 +2360,12 @@ class ArrowDecorationManager {
2360
2360
  this.map.addLayer(this.layer);
2361
2361
  this.syncVisibility();
2362
2362
  this.syncOpacity();
2363
- this.visibilityKey = this.parentLayer.on('change:visible', () => this.syncVisibility());
2363
+ this.visibilityKey = this.parentLayer.on('change:visible', () => {
2364
+ this.syncVisibility();
2365
+ if (this.parentLayer.getVisible()) {
2366
+ this.scheduleUpdate();
2367
+ }
2368
+ });
2364
2369
  this.moveEndKey = this.map.on('moveend', () => this.scheduleUpdate());
2365
2370
  this.unsubCollection = this.parentApi.onModelsCollectionChanged(() => this.scheduleUpdate());
2366
2371
  this.unsubChanges = this.parentApi.onModelsChanged?.(() => this.scheduleUpdate());
@@ -2589,7 +2594,12 @@ class BufferDecorationManager {
2589
2594
  this.map.addLayer(this.layer);
2590
2595
  this.syncVisibility();
2591
2596
  this.syncOpacity();
2592
- this.visibilityKey = this.parentLayer.on('change:visible', () => this.syncVisibility());
2597
+ this.visibilityKey = this.parentLayer.on('change:visible', () => {
2598
+ this.syncVisibility();
2599
+ if (this.parentLayer.getVisible()) {
2600
+ this.scheduleUpdate();
2601
+ }
2602
+ });
2593
2603
  this.moveEndKey = this.map.on('moveend', () => this.scheduleUpdate());
2594
2604
  this.unsubCollection = this.parentApi.onModelsCollectionChanged(() => this.scheduleUpdate());
2595
2605
  this.unsubChanges = this.parentApi.onModelsChanged?.(() => this.scheduleUpdate());
@@ -2655,6 +2665,117 @@ class BufferDecorationManager {
2655
2665
  }
2656
2666
  }
2657
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
+
2658
2779
  class LayerManager {
2659
2780
  map;
2660
2781
  layers = {};
@@ -2730,6 +2851,17 @@ class LayerManager {
2730
2851
  });
2731
2852
  this.decorationManagers.push(decorationManager);
2732
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
+ }
2733
2865
  });
2734
2866
  this.interactions = new InteractionManager({
2735
2867
  ctx,