mobility-toolbox-js 3.0.0-beta.36 → 3.0.0-beta.38

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/mbt.js CHANGED
@@ -17993,7 +17993,6 @@ uniform ${i3} ${a3} u_${s3};
17993
17993
  Layer: () => Layer_default4,
17994
17994
  MaplibreLayer: () => MaplibreLayer_default,
17995
17995
  MaplibreStyleLayer: () => MaplibreStyleLayer_default,
17996
- MobilityLayerMixin: () => MobilityLayerMixin_default,
17997
17996
  RealtimeAPI: () => RealtimeAPI_default,
17998
17997
  RealtimeLayer: () => RealtimeLayer_default,
17999
17998
  RealtimeModes: () => RealtimeModes,
@@ -25014,7 +25013,6 @@ uniform ${i3} ${a3} u_${s3};
25014
25013
  // src/common/utils/getVehiclePosition.ts
25015
25014
  var getVehiclePosition = (now, trajectory, noInterpolate) => {
25016
25015
  const {
25017
- // @ts-expect-error coordinate is added by the RealtimeLayer
25018
25016
  coordinate,
25019
25017
  // @ts-expect-error olGeometry is added by the RealtimeLayer
25020
25018
  olGeometry,
@@ -43225,13 +43223,13 @@ uniform ${i3} ${a3} u_${s3};
43225
43223
  }
43226
43224
  const map = this.getMap();
43227
43225
  if (map && map.isRendered() && this.getActive()) {
43228
- this.handlePointerAtPixel_(this.lastPixel_, map);
43226
+ this.handlePointerAtPixel_(map.getCoordinateFromPixel(this.lastPixel_));
43229
43227
  }
43230
43228
  feature2.addEventListener(EventType_default.CHANGE, this.boundHandleFeatureChange_);
43231
43229
  }
43232
43230
  /**
43233
43231
  * @param {import("../MapBrowserEvent.js").default} evt Map browser event.
43234
- * @param {Array<Array<SegmentData>>} segments The segments subject to modification.
43232
+ * @param {Array<SegmentData>} segments The segments subject to modification.
43235
43233
  * @private
43236
43234
  */
43237
43235
  willModifyFeatures_(evt, segments) {
@@ -43239,12 +43237,9 @@ uniform ${i3} ${a3} u_${s3};
43239
43237
  this.featuresBeingModified_ = new Collection_default();
43240
43238
  const features = this.featuresBeingModified_.getArray();
43241
43239
  for (let i = 0, ii = segments.length; i < ii; ++i) {
43242
- const segment = segments[i];
43243
- for (let s = 0, ss = segment.length; s < ss; ++s) {
43244
- const feature2 = segment[s].feature;
43245
- if (feature2 && !features.includes(feature2)) {
43246
- this.featuresBeingModified_.push(feature2);
43247
- }
43240
+ const feature2 = segments[i].feature;
43241
+ if (feature2 && !features.includes(feature2)) {
43242
+ this.featuresBeingModified_.push(feature2);
43248
43243
  }
43249
43244
  }
43250
43245
  if (this.featuresBeingModified_.getLength() === 0) {
@@ -43562,10 +43557,11 @@ uniform ${i3} ${a3} u_${s3};
43562
43557
  * @param {import("../coordinate.js").Coordinate} coordinates Coordinates.
43563
43558
  * @param {Array<Feature>} features The features being modified.
43564
43559
  * @param {Array<import("../geom/SimpleGeometry.js").default>} geometries The geometries being modified.
43560
+ * @param {boolean} existing The vertex represents an existing vertex.
43565
43561
  * @return {Feature} Vertex feature.
43566
43562
  * @private
43567
43563
  */
43568
- createOrUpdateVertexFeature_(coordinates2, features, geometries) {
43564
+ createOrUpdateVertexFeature_(coordinates2, features, geometries, existing) {
43569
43565
  let vertexFeature = this.vertexFeature_;
43570
43566
  if (!vertexFeature) {
43571
43567
  vertexFeature = new Feature_default(new Point_default(coordinates2));
@@ -43577,6 +43573,7 @@ uniform ${i3} ${a3} u_${s3};
43577
43573
  }
43578
43574
  vertexFeature.set("features", features);
43579
43575
  vertexFeature.set("geometries", geometries);
43576
+ vertexFeature.set("existing", existing);
43580
43577
  return vertexFeature;
43581
43578
  }
43582
43579
  /**
@@ -43606,6 +43603,80 @@ uniform ${i3} ${a3} u_${s3};
43606
43603
  }
43607
43604
  return super.handleEvent(mapBrowserEvent) && !handled;
43608
43605
  }
43606
+ findInsertVerticesAndUpdateDragSegments_(pixelCoordinate) {
43607
+ this.handlePointerAtPixel_(pixelCoordinate);
43608
+ this.dragSegments_.length = 0;
43609
+ this.featuresBeingModified_ = null;
43610
+ const vertexFeature = this.vertexFeature_;
43611
+ if (!vertexFeature) {
43612
+ return;
43613
+ }
43614
+ const projection = this.getMap().getView().getProjection();
43615
+ const insertVertices = [];
43616
+ const vertex = vertexFeature.getGeometry().getCoordinates();
43617
+ const vertexExtent = boundingExtent([vertex]);
43618
+ const segmentDataMatches = this.rBush_.getInExtent(vertexExtent);
43619
+ const componentSegments = {};
43620
+ segmentDataMatches.sort(compareIndexes);
43621
+ for (let i = 0, ii = segmentDataMatches.length; i < ii; ++i) {
43622
+ const segmentDataMatch = segmentDataMatches[i];
43623
+ const segment = segmentDataMatch.segment;
43624
+ let uid = getUid(segmentDataMatch.geometry);
43625
+ const depth = segmentDataMatch.depth;
43626
+ if (depth) {
43627
+ uid += "-" + depth.join("-");
43628
+ }
43629
+ if (!componentSegments[uid]) {
43630
+ componentSegments[uid] = new Array(2);
43631
+ }
43632
+ if (segmentDataMatch.geometry.getType() === "Circle" && segmentDataMatch.index === CIRCLE_CIRCUMFERENCE_INDEX) {
43633
+ const closestVertex = closestOnSegmentData(
43634
+ pixelCoordinate,
43635
+ segmentDataMatch,
43636
+ projection
43637
+ );
43638
+ if (equals3(closestVertex, vertex) && !componentSegments[uid][0]) {
43639
+ this.dragSegments_.push([segmentDataMatch, 0]);
43640
+ componentSegments[uid][0] = segmentDataMatch;
43641
+ }
43642
+ continue;
43643
+ }
43644
+ if (equals3(segment[0], vertex) && !componentSegments[uid][0]) {
43645
+ this.dragSegments_.push([segmentDataMatch, 0]);
43646
+ componentSegments[uid][0] = segmentDataMatch;
43647
+ continue;
43648
+ }
43649
+ if (equals3(segment[1], vertex) && !componentSegments[uid][1]) {
43650
+ if (componentSegments[uid][0] && componentSegments[uid][0].index === 0) {
43651
+ let coordinates2 = segmentDataMatch.geometry.getCoordinates();
43652
+ switch (segmentDataMatch.geometry.getType()) {
43653
+ // prevent dragging closed linestrings by the connecting node
43654
+ case "LineString":
43655
+ case "MultiLineString":
43656
+ continue;
43657
+ // if dragging the first vertex of a polygon, ensure the other segment
43658
+ // belongs to the closing vertex of the linear ring
43659
+ case "MultiPolygon":
43660
+ coordinates2 = coordinates2[depth[1]];
43661
+ /* falls through */
43662
+ case "Polygon":
43663
+ if (segmentDataMatch.index !== coordinates2[depth[0]].length - 2) {
43664
+ continue;
43665
+ }
43666
+ break;
43667
+ default:
43668
+ }
43669
+ }
43670
+ this.dragSegments_.push([segmentDataMatch, 1]);
43671
+ componentSegments[uid][1] = segmentDataMatch;
43672
+ continue;
43673
+ }
43674
+ if (getUid(segment) in this.vertexSegments_ && !componentSegments[uid][0] && !componentSegments[uid][1]) {
43675
+ insertVertices.push(segmentDataMatch);
43676
+ }
43677
+ }
43678
+ return insertVertices;
43679
+ }
43609
43680
  /**
43610
43681
  * Handle pointer drag events.
43611
43682
  * @param {import("../MapBrowserEvent.js").default} evt Event.
@@ -43613,7 +43684,10 @@ uniform ${i3} ${a3} u_${s3};
43613
43684
  */
43614
43685
  handleDragEvent(evt) {
43615
43686
  this.ignoreNextSingleClick_ = false;
43616
- this.willModifyFeatures_(evt, this.dragSegments_);
43687
+ this.willModifyFeatures_(
43688
+ evt,
43689
+ this.dragSegments_.map(([segment]) => segment)
43690
+ );
43617
43691
  const vertex = [
43618
43692
  evt.coordinate[0] + this.delta_[0],
43619
43693
  evt.coordinate[1] + this.delta_[1]
@@ -43671,26 +43745,30 @@ uniform ${i3} ${a3} u_${s3};
43671
43745
  segment[index] = vertex;
43672
43746
  break;
43673
43747
  case "Circle":
43748
+ const circle = (
43749
+ /** @type {import("../geom/Circle.js").default} */
43750
+ geometry
43751
+ );
43674
43752
  segment[0] = vertex;
43675
43753
  segment[1] = vertex;
43676
43754
  if (segmentData.index === CIRCLE_CENTER_INDEX) {
43677
43755
  this.changingFeature_ = true;
43678
- geometry.setCenter(vertex);
43756
+ circle.setCenter(vertex);
43679
43757
  this.changingFeature_ = false;
43680
43758
  } else {
43681
43759
  this.changingFeature_ = true;
43682
43760
  const projection = evt.map.getView().getProjection();
43683
43761
  let radius = distance(
43684
- fromUserCoordinate(geometry.getCenter(), projection),
43762
+ fromUserCoordinate(circle.getCenter(), projection),
43685
43763
  fromUserCoordinate(vertex, projection)
43686
43764
  );
43687
43765
  const userProjection2 = getUserProjection();
43688
43766
  if (userProjection2) {
43689
- const circleGeometry = geometry.clone().transform(userProjection2, projection);
43767
+ const circleGeometry = circle.clone().transform(userProjection2, projection);
43690
43768
  circleGeometry.setRadius(radius);
43691
43769
  radius = circleGeometry.transform(projection, userProjection2).getRadius();
43692
43770
  }
43693
- geometry.setRadius(radius);
43771
+ circle.setRadius(radius);
43694
43772
  this.changingFeature_ = false;
43695
43773
  }
43696
43774
  break;
@@ -43700,7 +43778,7 @@ uniform ${i3} ${a3} u_${s3};
43700
43778
  this.setGeometryCoordinates_(geometry, coordinates2);
43701
43779
  }
43702
43780
  }
43703
- this.createOrUpdateVertexFeature_(vertex, features, geometries);
43781
+ this.createOrUpdateVertexFeature_(vertex, features, geometries, true);
43704
43782
  }
43705
43783
  /**
43706
43784
  * Handle pointer down events.
@@ -43713,80 +43791,15 @@ uniform ${i3} ${a3} u_${s3};
43713
43791
  return false;
43714
43792
  }
43715
43793
  const pixelCoordinate = evt.coordinate;
43716
- this.handlePointerAtPixel_(evt.pixel, evt.map, pixelCoordinate);
43717
- this.dragSegments_.length = 0;
43718
- this.featuresBeingModified_ = null;
43719
- const vertexFeature = this.vertexFeature_;
43720
- if (vertexFeature) {
43721
- const projection = evt.map.getView().getProjection();
43722
- const insertVertices = [];
43723
- const vertex = vertexFeature.getGeometry().getCoordinates();
43724
- const vertexExtent = boundingExtent([vertex]);
43725
- const segmentDataMatches = this.rBush_.getInExtent(vertexExtent);
43726
- const componentSegments = {};
43727
- segmentDataMatches.sort(compareIndexes);
43728
- for (let i = 0, ii = segmentDataMatches.length; i < ii; ++i) {
43729
- const segmentDataMatch = segmentDataMatches[i];
43730
- const segment = segmentDataMatch.segment;
43731
- let uid = getUid(segmentDataMatch.geometry);
43732
- const depth = segmentDataMatch.depth;
43733
- if (depth) {
43734
- uid += "-" + depth.join("-");
43735
- }
43736
- if (!componentSegments[uid]) {
43737
- componentSegments[uid] = new Array(2);
43738
- }
43739
- if (segmentDataMatch.geometry.getType() === "Circle" && segmentDataMatch.index === CIRCLE_CIRCUMFERENCE_INDEX) {
43740
- const closestVertex = closestOnSegmentData(
43741
- pixelCoordinate,
43742
- segmentDataMatch,
43743
- projection
43744
- );
43745
- if (equals3(closestVertex, vertex) && !componentSegments[uid][0]) {
43746
- this.dragSegments_.push([segmentDataMatch, 0]);
43747
- componentSegments[uid][0] = segmentDataMatch;
43748
- }
43749
- continue;
43750
- }
43751
- if (equals3(segment[0], vertex) && !componentSegments[uid][0]) {
43752
- this.dragSegments_.push([segmentDataMatch, 0]);
43753
- componentSegments[uid][0] = segmentDataMatch;
43754
- continue;
43755
- }
43756
- if (equals3(segment[1], vertex) && !componentSegments[uid][1]) {
43757
- if (componentSegments[uid][0] && componentSegments[uid][0].index === 0) {
43758
- let coordinates2 = segmentDataMatch.geometry.getCoordinates();
43759
- switch (segmentDataMatch.geometry.getType()) {
43760
- // prevent dragging closed linestrings by the connecting node
43761
- case "LineString":
43762
- case "MultiLineString":
43763
- continue;
43764
- // if dragging the first vertex of a polygon, ensure the other segment
43765
- // belongs to the closing vertex of the linear ring
43766
- case "MultiPolygon":
43767
- coordinates2 = coordinates2[depth[1]];
43768
- /* falls through */
43769
- case "Polygon":
43770
- if (segmentDataMatch.index !== coordinates2[depth[0]].length - 2) {
43771
- continue;
43772
- }
43773
- break;
43774
- default:
43775
- }
43776
- }
43777
- this.dragSegments_.push([segmentDataMatch, 1]);
43778
- componentSegments[uid][1] = segmentDataMatch;
43779
- continue;
43794
+ const insertVertices = this.findInsertVerticesAndUpdateDragSegments_(pixelCoordinate);
43795
+ if (insertVertices?.length && this.insertVertexCondition_(evt)) {
43796
+ this.willModifyFeatures_(evt, insertVertices);
43797
+ if (this.vertexFeature_) {
43798
+ const vertex = this.vertexFeature_.getGeometry().getCoordinates();
43799
+ for (let j = insertVertices.length - 1; j >= 0; --j) {
43800
+ this.insertVertex_(insertVertices[j], vertex);
43780
43801
  }
43781
- if (getUid(segment) in this.vertexSegments_ && !componentSegments[uid][0] && !componentSegments[uid][1] && this.insertVertexCondition_(evt)) {
43782
- insertVertices.push(segmentDataMatch);
43783
- }
43784
- }
43785
- if (insertVertices.length) {
43786
- this.willModifyFeatures_(evt, [insertVertices]);
43787
- }
43788
- for (let j = insertVertices.length - 1; j >= 0; --j) {
43789
- this.insertVertex_(insertVertices[j], vertex);
43802
+ this.ignoreNextSingleClick_ = true;
43790
43803
  }
43791
43804
  }
43792
43805
  return !!this.vertexFeature_;
@@ -43802,7 +43815,11 @@ uniform ${i3} ${a3} u_${s3};
43802
43815
  const segmentData = this.dragSegments_[i][0];
43803
43816
  const geometry = segmentData.geometry;
43804
43817
  if (geometry.getType() === "Circle") {
43805
- const coordinates2 = geometry.getCenter();
43818
+ const circle = (
43819
+ /** @type {import("../geom/Circle.js").default} */
43820
+ geometry
43821
+ );
43822
+ const coordinates2 = circle.getCenter();
43806
43823
  const centerSegmentData = segmentData.featureSegments[0];
43807
43824
  const circumferenceSegmentData = segmentData.featureSegments[1];
43808
43825
  centerSegmentData.segment[0] = coordinates2;
@@ -43810,7 +43827,7 @@ uniform ${i3} ${a3} u_${s3};
43810
43827
  circumferenceSegmentData.segment[0] = coordinates2;
43811
43828
  circumferenceSegmentData.segment[1] = coordinates2;
43812
43829
  this.rBush_.update(createOrUpdateFromCoordinate(coordinates2), centerSegmentData);
43813
- let circleGeometry = geometry;
43830
+ let circleGeometry = circle;
43814
43831
  const userProjection2 = getUserProjection();
43815
43832
  if (userProjection2) {
43816
43833
  const projection = evt.map.getView().getProjection();
@@ -43846,16 +43863,15 @@ uniform ${i3} ${a3} u_${s3};
43846
43863
  */
43847
43864
  handlePointerMove_(evt) {
43848
43865
  this.lastPixel_ = evt.pixel;
43849
- this.handlePointerAtPixel_(evt.pixel, evt.map, evt.coordinate);
43866
+ this.handlePointerAtPixel_(evt.coordinate);
43850
43867
  }
43851
43868
  /**
43852
- * @param {import("../pixel.js").Pixel} pixel Pixel
43853
- * @param {import("../Map.js").default} map Map.
43854
- * @param {import("../coordinate.js").Coordinate} [coordinate] The pixel Coordinate.
43869
+ * @param {import("../coordinate.js").Coordinate} pixelCoordinate The pixel Coordinate.
43855
43870
  * @private
43856
43871
  */
43857
- handlePointerAtPixel_(pixel, map, coordinate) {
43858
- const pixelCoordinate = coordinate || map.getCoordinateFromPixel(pixel);
43872
+ handlePointerAtPixel_(pixelCoordinate) {
43873
+ const map = this.getMap();
43874
+ const pixel = map.getPixelFromCoordinate(pixelCoordinate);
43859
43875
  const projection = map.getView().getProjection();
43860
43876
  const sortByDistance = function(a, b) {
43861
43877
  return projectedDistanceToSegmentDataSquared(pixelCoordinate, a, projection) - projectedDistanceToSegmentDataSquared(pixelCoordinate, b, projection);
@@ -43873,10 +43889,10 @@ uniform ${i3} ${a3} u_${s3};
43873
43889
  );
43874
43890
  }
43875
43891
  const geom = geometry || feature2.getGeometry();
43876
- if (feature2 instanceof Feature_default && this.features_.getArray().includes(feature2)) {
43892
+ if (geom && geom.getType() === "Point" && feature2 instanceof Feature_default && this.features_.getArray().includes(feature2)) {
43877
43893
  hitPointGeometry = /** @type {Point} */
43878
43894
  geom;
43879
- const coordinate2 = (
43895
+ const coordinate = (
43880
43896
  /** @type {Point} */
43881
43897
  feature2.getGeometry().getFlatCoordinates().slice(0, 2)
43882
43898
  );
@@ -43884,7 +43900,7 @@ uniform ${i3} ${a3} u_${s3};
43884
43900
  {
43885
43901
  feature: feature2,
43886
43902
  geometry: hitPointGeometry,
43887
- segment: [coordinate2, coordinate2]
43903
+ segment: [coordinate, coordinate]
43888
43904
  }
43889
43905
  ];
43890
43906
  }
@@ -43923,7 +43939,8 @@ uniform ${i3} ${a3} u_${s3};
43923
43939
  this.createOrUpdateVertexFeature_(
43924
43940
  vertex,
43925
43941
  [node.feature],
43926
- [node.geometry]
43942
+ [node.geometry],
43943
+ this.snappedToVertex_
43927
43944
  );
43928
43945
  } else {
43929
43946
  const pixel1 = map.getPixelFromCoordinate(closestSegment[0]);
@@ -43938,7 +43955,8 @@ uniform ${i3} ${a3} u_${s3};
43938
43955
  this.createOrUpdateVertexFeature_(
43939
43956
  vertex,
43940
43957
  [node.feature],
43941
- [node.geometry]
43958
+ [node.geometry],
43959
+ this.snappedToVertex_
43942
43960
  );
43943
43961
  const geometries = {};
43944
43962
  geometries[getUid(node.geometry)] = true;
@@ -43967,6 +43985,7 @@ uniform ${i3} ${a3} u_${s3};
43967
43985
  /**
43968
43986
  * @param {SegmentData} segmentData Segment data.
43969
43987
  * @param {import("../coordinate.js").Coordinate} vertex Vertex.
43988
+ * @return {boolean} A vertex was inserted.
43970
43989
  * @private
43971
43990
  */
43972
43991
  insertVertex_(segmentData, vertex) {
@@ -43997,7 +44016,7 @@ uniform ${i3} ${a3} u_${s3};
43997
44016
  coordinates2.splice(index + 1, 0, vertex);
43998
44017
  break;
43999
44018
  default:
44000
- return;
44019
+ return false;
44001
44020
  }
44002
44021
  this.setGeometryCoordinates_(geometry, coordinates2);
44003
44022
  const rTree = this.rBush_;
@@ -44021,17 +44040,70 @@ uniform ${i3} ${a3} u_${s3};
44021
44040
  };
44022
44041
  rTree.insert(boundingExtent(newSegmentData2.segment), newSegmentData2);
44023
44042
  this.dragSegments_.push([newSegmentData2, 0]);
44024
- this.ignoreNextSingleClick_ = true;
44043
+ return true;
44044
+ }
44045
+ updatePointer_(coordinate) {
44046
+ if (coordinate) {
44047
+ this.findInsertVerticesAndUpdateDragSegments_(coordinate);
44048
+ }
44049
+ return this.vertexFeature_?.getGeometry().getCoordinates();
44050
+ }
44051
+ /**
44052
+ * Get the current pointer position.
44053
+ * @return {import("../coordinate.js").Coordinate | null} The current pointer coordinate.
44054
+ */
44055
+ getPoint() {
44056
+ const coordinate = this.vertexFeature_?.getGeometry().getCoordinates();
44057
+ if (!coordinate) {
44058
+ return null;
44059
+ }
44060
+ return toUserCoordinate(
44061
+ coordinate,
44062
+ this.getMap().getView().getProjection()
44063
+ );
44025
44064
  }
44026
44065
  /**
44027
- * Removes the vertex currently being pointed.
44066
+ * Check if a point can be removed from the current linestring or polygon at the current
44067
+ * pointer position.
44068
+ * @return {boolean} A point can be deleted at the current pointer position.
44069
+ * @api
44070
+ */
44071
+ canRemovePoint() {
44072
+ if (!this.vertexFeature_) {
44073
+ return false;
44074
+ }
44075
+ if (this.vertexFeature_.get("geometries").every(
44076
+ (geometry) => geometry.getType() === "Circle" || geometry.getType().endsWith("Point")
44077
+ )) {
44078
+ return false;
44079
+ }
44080
+ const coordinate = this.vertexFeature_.getGeometry().getCoordinates();
44081
+ const segments = this.rBush_.getInExtent(boundingExtent([coordinate]));
44082
+ return segments.some(
44083
+ ({ segment }) => equals3(segment[0], coordinate) || equals3(segment[1], coordinate)
44084
+ );
44085
+ }
44086
+ /**
44087
+ * Removes the vertex currently being pointed from the current linestring or polygon.
44088
+ * @param {import('../coordinate.js').Coordinate} [coordinate] If provided, the pointer
44089
+ * will be set to the provided coordinate. If not, the current pointer coordinate will be used.
44028
44090
  * @return {boolean} True when a vertex was removed.
44029
44091
  * @api
44030
44092
  */
44031
- removePoint() {
44032
- if (this.lastPointerEvent_ && this.lastPointerEvent_.type != MapBrowserEventType_default.POINTERDRAG) {
44093
+ removePoint(coordinate) {
44094
+ if (coordinate) {
44095
+ coordinate = fromUserCoordinate(
44096
+ coordinate,
44097
+ this.getMap().getView().getProjection()
44098
+ );
44099
+ this.updatePointer_(coordinate);
44100
+ }
44101
+ if (!this.lastPointerEvent_ || this.lastPointerEvent_ && this.lastPointerEvent_.type != MapBrowserEventType_default.POINTERDRAG) {
44033
44102
  const evt = this.lastPointerEvent_;
44034
- this.willModifyFeatures_(evt, this.dragSegments_);
44103
+ this.willModifyFeatures_(
44104
+ evt,
44105
+ this.dragSegments_.map(([segment]) => segment)
44106
+ );
44035
44107
  const removed = this.removeVertex_();
44036
44108
  if (this.featuresBeingModified_) {
44037
44109
  this.dispatchEvent(
@@ -44160,6 +44232,45 @@ uniform ${i3} ${a3} u_${s3};
44160
44232
  }
44161
44233
  return deleted;
44162
44234
  }
44235
+ /**
44236
+ * Check if a point can be inserted to the current linestring or polygon at the current
44237
+ * pointer position.
44238
+ * @return {boolean} A point can be inserted at the current pointer position.
44239
+ * @api
44240
+ */
44241
+ canInsertPoint() {
44242
+ if (!this.vertexFeature_) {
44243
+ return false;
44244
+ }
44245
+ if (this.vertexFeature_.get("geometries").every(
44246
+ (geometry) => geometry.getType() === "Circle" || geometry.getType().endsWith("Point")
44247
+ )) {
44248
+ return false;
44249
+ }
44250
+ const coordinate = this.vertexFeature_.getGeometry().getCoordinates();
44251
+ const segments = this.rBush_.getInExtent(boundingExtent([coordinate]));
44252
+ return segments.some(
44253
+ ({ segment }) => !(equals3(segment[0], coordinate) || equals3(segment[1], coordinate))
44254
+ );
44255
+ }
44256
+ /**
44257
+ * Inserts the vertex currently being pointed to the current linestring or polygon.
44258
+ * @param {import('../coordinate.js').Coordinate} [coordinate] If provided, the pointer
44259
+ * will be set to the provided coordinate. If not, the current pointer coordinate will be used.
44260
+ * @return {boolean} A vertex was inserted.
44261
+ * @api
44262
+ */
44263
+ insertPoint(coordinate) {
44264
+ const pixelCoordinate = coordinate ? fromUserCoordinate(coordinate, this.getMap().getView().getProjection()) : this.vertexFeature_?.getGeometry().getCoordinates();
44265
+ if (!pixelCoordinate) {
44266
+ return false;
44267
+ }
44268
+ const insertVertices = this.findInsertVerticesAndUpdateDragSegments_(pixelCoordinate);
44269
+ return insertVertices.reduce(
44270
+ (prev, segmentData) => prev || this.insertVertex_(segmentData, pixelCoordinate),
44271
+ false
44272
+ );
44273
+ }
44163
44274
  /**
44164
44275
  * @param {import("../geom/SimpleGeometry.js").default} geometry Geometry.
44165
44276
  * @param {Array} coordinates Coordinates.
@@ -44435,7 +44546,7 @@ uniform ${i3} ${a3} u_${s3};
44435
44546
  */
44436
44547
  createModifyInteraction() {
44437
44548
  this.modifyInteraction = new Modify_default({
44438
- // hitDetection: this.routingLayer, // Create a bug, the first point is always selected even if the mous eis far away
44549
+ // hitDetection: this.routingLayer, // TODO: wait for ol, fixed in https://github.com/openlayers/openlayers/pull/16393
44439
44550
  deleteCondition: (e) => {
44440
44551
  const feats = e.target?.getFeaturesAtPixel(e.pixel, {
44441
44552
  hitTolerance: 5
@@ -44475,7 +44586,7 @@ uniform ${i3} ${a3} u_${s3};
44475
44586
  */
44476
44587
  drawRoute() {
44477
44588
  this.abortRequests();
44478
- this.routingLayer?.getSource()?.clear(true);
44589
+ this.routingLayer?.getSource()?.clear();
44479
44590
  if (!this.viaPoints.length) {
44480
44591
  return null;
44481
44592
  }
@@ -45209,7 +45320,7 @@ uniform ${i3} ${a3} u_${s3};
45209
45320
  // src/ol/layers/MaplibreLayer.ts
45210
45321
  var import_lodash2 = __toESM(require_lodash());
45211
45322
 
45212
- // src/ol/mixins/PropertiesLayerMixin.ts
45323
+ // src/ol/utils/defineDeprecatedProperties.ts
45213
45324
  var import_lodash = __toESM(require_lodash());
45214
45325
  var deprecated = () => {
45215
45326
  };
@@ -45218,213 +45329,207 @@ uniform ${i3} ${a3} u_${s3};
45218
45329
  console.warn(message);
45219
45330
  }, 1e3);
45220
45331
  }
45221
- function PropertiesLayerMixin(Base) {
45222
- return class PropertiesLayer extends Base {
45223
- constructor(...args) {
45224
- const options = args[0];
45225
- super(options);
45226
- this.olEventsKeys = [];
45227
- this.options = {};
45228
- if (options.properties) {
45229
- deprecated(
45230
- "Deprecated. Don't use properties options. Pass the values directly in options object."
45231
- );
45232
- this.setProperties(options.properties);
45233
- }
45234
- this.on("propertychange", (evt) => {
45235
- if (evt.key === "children") {
45236
- this.onChildrenChange(evt.oldValue);
45237
- }
45238
- });
45239
- this.options = options;
45240
- this.set("children", options.children || []);
45241
- }
45242
- /**
45243
- * Initialize the layer with the map passed in parameters.
45244
- *
45245
- * @param {ol/Map~Map} map A map.
45246
- */
45247
- attachToMap(map) {
45248
- (super.attachToMap || (() => {
45249
- }))(map);
45250
- (this.get("children") || []).forEach((child) => {
45251
- map.addLayer(child);
45252
- });
45253
- }
45254
- /**
45255
- * Terminate what was initialized in init function. Remove layer, events...
45256
- */
45257
- detachFromMap() {
45258
- unByKey(this.olEventsKeys);
45259
- (this.get("children") || []).forEach((child) => {
45260
- this.map.removeLayer(child);
45261
- });
45262
- (super.detachFromMap || (() => {
45263
- }))();
45264
- }
45265
- /**
45266
- * Return the an array containing all the descendants of the layer in a flat array. Including the current layer.
45267
- * @deprecated
45268
- */
45269
- flat() {
45270
- deprecated(
45271
- "Layer.flat is deprecated. Use getLayersAsFlatArray utils method instead."
45272
- );
45273
- return getLayersAsFlatArray_default(this);
45274
- }
45275
- onChildrenChange(oldValue) {
45276
- (oldValue || []).forEach((child) => {
45277
- child.set("parent", void 0);
45278
- });
45279
- (this.get("children") || []).forEach((child) => {
45280
- child.set("parent", this);
45281
- });
45332
+ var onChildrenChange = (layer, oldValue) => {
45333
+ (oldValue || []).forEach((child) => {
45334
+ child.set("parent", void 0);
45335
+ });
45336
+ (layer.get("children") || []).forEach((child) => {
45337
+ child.set("parent", void 0);
45338
+ });
45339
+ };
45340
+ var defineDeprecatedProperties = (obj, options) => {
45341
+ if (options.properties) {
45342
+ deprecated(
45343
+ "Deprecated. Don't use properties options. Pass the values directly in options object."
45344
+ );
45345
+ obj.setProperties(options.properties);
45346
+ }
45347
+ obj.on("propertychange", (evt) => {
45348
+ if (evt.key === "children") {
45349
+ onChildrenChange(evt.target, evt.oldValue);
45282
45350
  }
45283
- // @ts-expect-error - this is a mixin
45284
- setMapInternal(map) {
45351
+ if (evt.key === "map") {
45352
+ const map = evt.target.get(evt.key);
45285
45353
  if (map) {
45286
- super.setMapInternal(map);
45287
- this.attachToMap(map);
45288
- } else {
45289
- this.detachFromMap();
45290
- super.setMapInternal(map);
45354
+ (evt.target.get("children") || []).forEach((child) => {
45355
+ map.addLayer(child);
45356
+ });
45357
+ } else if (evt.oldValue) {
45358
+ (evt.target.get("children") || []).forEach((child) => {
45359
+ evt.oldValue.removeLayer(child);
45360
+ });
45291
45361
  }
45292
45362
  }
45293
- /** @deprecated */
45294
- get children() {
45295
- deprecated(
45296
- "Layer.children is deprecated. Use the Layer.get('children') method instead."
45297
- );
45298
- return this.get("children") || [];
45299
- }
45300
- /** @deprecated */
45301
- set children(newValue) {
45302
- deprecated(
45303
- "Layer.children is deprecated. Use the Layer.set('children', children) method instead."
45304
- );
45305
- this.set("children", newValue || []);
45306
- }
45307
- /** @deprecated */
45308
- get copyrights() {
45309
- deprecated(
45310
- "Layer.copyrights is deprecated. Get the attributions from the source object"
45311
- );
45312
- return this.get("copyrights");
45313
- }
45314
- /** @deprecated */
45315
- set copyrights(newCopyrights) {
45316
- deprecated(
45317
- "Layer.copyrights is deprecated. Set the attributions to the source object."
45318
- );
45319
- const arrValue = newCopyrights && !Array.isArray(newCopyrights) ? [newCopyrights] : newCopyrights;
45320
- this.set("copyrights", arrValue || []);
45321
- }
45322
- /** @deprecated */
45323
- get disabled() {
45324
- deprecated(
45325
- "Layer.disabled is deprecated. Use the Layer.get('disabled') method instead."
45326
- );
45327
- return this.get("disabled");
45328
- }
45329
- /** @deprecated */
45330
- set disabled(newValue) {
45331
- deprecated(
45332
- "Layer.disabled is deprecated. Use the Layer.set('disabled', newValue) method instead."
45333
- );
45334
- this.set("disabled", newValue);
45335
- }
45336
- /** @deprecated */
45337
- get group() {
45338
- deprecated(
45339
- "Layer.group is deprecated. Use the Layer.get('group') method instead."
45340
- );
45341
- return this.get("group");
45342
- }
45343
- /** @deprecated */
45344
- get hitTolerance() {
45345
- deprecated(
45346
- "Layer.hitTolerance is deprecated.Pass the hitTolerance when you request the features."
45347
- );
45348
- return this.get("hitTolerance") || 5;
45349
- }
45350
- /** @deprecated */
45351
- set hitTolerance(newValue) {
45352
- deprecated(
45353
- "Layer.hitTolerance is deprecated.Pass the hitTolerance when you request the features."
45354
- );
45355
- this.set("hitTolerance", newValue);
45356
- }
45357
- get key() {
45358
- return this.get("key") || this.get("name");
45359
- }
45360
- get map() {
45361
- return this.getMapInternal();
45362
- }
45363
- /** @deprecated */
45364
- get name() {
45365
- deprecated(
45366
- "Layer.name is deprecated. Use the Layer.get('name') method instead."
45367
- );
45368
- return this.get("name");
45369
- }
45370
- /** @deprecated */
45371
- get olLayer() {
45372
- deprecated(
45373
- "Layer.olLayer is deprecated. mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. This getter is only a redirect to the current 'this' object."
45374
- );
45375
- return this;
45376
- }
45377
- // eslint-disable-next-line class-methods-use-this
45378
- set olLayer(newValue) {
45379
- deprecated(
45380
- "Layer.olLayer is deprecated. mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. This setter has no effect."
45381
- );
45382
- }
45383
- /** @deprecated */
45384
- // get olListenersKeys(): EventsKey[] {
45385
- // return this.olEventsKeys;
45386
- // }
45387
- /** @deprecated */
45388
- get parent() {
45389
- deprecated(
45390
- "Layer.parent is deprecated. Use the Layer.get('parent') method instead."
45391
- );
45392
- return this.get("parent");
45393
- }
45394
- /** @deprecated */
45395
- set parent(newValue) {
45396
- deprecated(
45397
- "Layer.parent is deprecated. Use the Layer.set('parent', parent) method instead."
45398
- );
45399
- this.set("parent", newValue);
45400
- }
45401
- /** @deprecated */
45402
- get visible() {
45403
- deprecated(
45404
- "Layer.visible is deprecated. Use the Layer.getVisible() method instead."
45405
- );
45406
- return this.getVisible();
45407
- }
45408
- /** @deprecated */
45409
- set visible(newValue) {
45410
- deprecated(
45411
- "Layer.visible is deprecated. Use the Layer.setVisible(newValue) method instead."
45412
- );
45413
- this.setVisible(newValue);
45363
+ });
45364
+ obj.set("options", options);
45365
+ obj.set("children", options.children || []);
45366
+ Object.defineProperties(obj, {
45367
+ children: {
45368
+ /** @deprecated */
45369
+ get: () => {
45370
+ deprecated(
45371
+ "Layer.children is deprecated. Use the Layer.get('children') method instead."
45372
+ );
45373
+ return obj.get("children") || [];
45374
+ },
45375
+ /** @deprecated */
45376
+ set: (newValue) => {
45377
+ deprecated(
45378
+ "Layer.children is deprecated. Use the Layer.set('children', children) method instead."
45379
+ );
45380
+ obj.set("children", newValue || []);
45381
+ }
45382
+ },
45383
+ copyrights: {
45384
+ /** @deprecated */
45385
+ get: () => {
45386
+ deprecated(
45387
+ "Layer.copyrights is deprecated. Get the attributions from the source object"
45388
+ );
45389
+ return obj.get("copyrights");
45390
+ },
45391
+ /** @deprecated */
45392
+ set: (newCopyrights) => {
45393
+ deprecated(
45394
+ "Layer.copyrights is deprecated. Set the attributions to the source object."
45395
+ );
45396
+ const arrValue = newCopyrights && !Array.isArray(newCopyrights) ? [newCopyrights] : newCopyrights;
45397
+ obj.set("copyrights", arrValue || []);
45398
+ }
45399
+ },
45400
+ disabled: {
45401
+ /** @deprecated */
45402
+ get() {
45403
+ deprecated(
45404
+ "Layer.disabled is deprecated. Use the Layer.get('disabled') method instead."
45405
+ );
45406
+ return obj.get("disabled");
45407
+ },
45408
+ /** @deprecated */
45409
+ set(newValue) {
45410
+ deprecated(
45411
+ "Layer.disabled is deprecated. Use the Layer.set('disabled', newValue) method instead."
45412
+ );
45413
+ obj.set("disabled", newValue);
45414
+ }
45415
+ },
45416
+ group: {
45417
+ /** @deprecated */
45418
+ get() {
45419
+ deprecated(
45420
+ "Layer.group is deprecated. Use the Layer.get('group') method instead."
45421
+ );
45422
+ return obj.get("group");
45423
+ }
45424
+ },
45425
+ hitTolerance: {
45426
+ /** @deprecated */
45427
+ get() {
45428
+ deprecated(
45429
+ "Layer.hitTolerance is deprecated. Pass the hitTolerance when you request the features."
45430
+ );
45431
+ return obj.get("hitTolerance") || 5;
45432
+ },
45433
+ /** @deprecated */
45434
+ set(newValue) {
45435
+ deprecated(
45436
+ "Layer.hitTolerance is deprecated. Pass the hitTolerance when you request the features."
45437
+ );
45438
+ obj.set("hitTolerance", newValue);
45439
+ }
45440
+ },
45441
+ key: {
45442
+ /** @deprecated */
45443
+ get() {
45444
+ deprecated(
45445
+ 'Layer.key is deprecated. Use the Layer.get("key") method instead.'
45446
+ );
45447
+ return obj.get("key") || obj.get("name");
45448
+ }
45449
+ },
45450
+ map: {
45451
+ /** @deprecated */
45452
+ get() {
45453
+ deprecated(
45454
+ 'Layer.map is deprecated. Use the Layer.get("map") method instead.'
45455
+ );
45456
+ return obj.getMapInternal();
45457
+ }
45458
+ },
45459
+ name: {
45460
+ /** @deprecated */
45461
+ get() {
45462
+ deprecated(
45463
+ "Layer.name is deprecated. Use the Layer.get('name') method instead."
45464
+ );
45465
+ return obj.get("name");
45466
+ }
45467
+ },
45468
+ olLayer: {
45469
+ /** @deprecated */
45470
+ get() {
45471
+ deprecated(
45472
+ "Layer.olLayer is deprecated. mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. obj getter is only a redirect to the current 'this' object."
45473
+ );
45474
+ return obj;
45475
+ },
45476
+ /** @deprecated */
45477
+ set() {
45478
+ deprecated(
45479
+ "Layer.olLayer is deprecated. mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. obj setter has no effect."
45480
+ );
45481
+ }
45482
+ },
45483
+ options: {
45484
+ /** @deprecated */
45485
+ get() {
45486
+ deprecated(
45487
+ 'Layer.options is deprecated. Use the Layer.get("options") method instead.'
45488
+ );
45489
+ return obj.get("options");
45490
+ },
45491
+ set(newValue) {
45492
+ deprecated(
45493
+ 'Layer.options is deprecated. Use the Layer.set("options", newValue) method instead.'
45494
+ );
45495
+ return obj.set("options", newValue);
45496
+ }
45497
+ },
45498
+ parent: {
45499
+ /** @deprecated */
45500
+ get() {
45501
+ deprecated(
45502
+ "Layer.parent is deprecated. Use the Layer.get('parent') method instead."
45503
+ );
45504
+ return obj.get("parent");
45505
+ },
45506
+ /** @deprecated */
45507
+ set(newValue) {
45508
+ deprecated(
45509
+ "Layer.parent is deprecated. Use the Layer.set('parent', parent) method instead."
45510
+ );
45511
+ obj.set("parent", newValue);
45512
+ }
45513
+ },
45514
+ visible: {
45515
+ /** @deprecated */
45516
+ get() {
45517
+ deprecated(
45518
+ "Layer.visible is deprecated. Use the Layer.getVisible() method instead."
45519
+ );
45520
+ return obj.getVisible();
45521
+ },
45522
+ /** @deprecated */
45523
+ set(newValue) {
45524
+ deprecated(
45525
+ "Layer.visible is deprecated. Use the Layer.setVisible(newValue) method instead."
45526
+ );
45527
+ obj.setVisible(newValue);
45528
+ }
45414
45529
  }
45415
- };
45416
- }
45417
- var PropertiesLayerMixin_default = PropertiesLayerMixin;
45418
-
45419
- // src/ol/mixins/MobilityLayerMixin.ts
45420
- function MobilityLayerMixin(Base) {
45421
- return class MobilityLayer extends PropertiesLayerMixin_default(Base) {
45422
- // constructor(options: MobilityLayerOptions = {}) {
45423
- // super(options);
45424
- // }
45425
- };
45426
- }
45427
- var MobilityLayerMixin_default = MobilityLayerMixin;
45530
+ });
45531
+ };
45532
+ var defineDeprecatedProperties_default = defineDeprecatedProperties;
45428
45533
 
45429
45534
  // src/ol/layers/MaplibreLayer.ts
45430
45535
  var buildStyleUrl = (url, style, apiKey, apiKeyName) => {
@@ -45439,7 +45544,7 @@ uniform ${i3} ${a3} u_${s3};
45439
45544
  console.warn(message);
45440
45545
  }, 1e3);
45441
45546
  }
45442
- var MaplibreLayer = class _MaplibreLayer extends MobilityLayerMixin_default(MapLibreLayer) {
45547
+ var MaplibreLayer = class _MaplibreLayer extends MapLibreLayer {
45443
45548
  /**
45444
45549
  * Constructor.
45445
45550
  *
@@ -45471,13 +45576,14 @@ uniform ${i3} ${a3} u_${s3};
45471
45576
  );
45472
45577
  }
45473
45578
  super(newOptions);
45579
+ this.olEventsKeys = [];
45580
+ defineDeprecatedProperties_default(this, options);
45581
+ this.set("options", options);
45474
45582
  }
45475
45583
  /**
45476
45584
  * Initialize the layer and listen to feature clicks.
45477
- * @param {ol/Map~Map} map An OpenLayers map.
45478
45585
  */
45479
- attachToMap(map) {
45480
- super.attachToMap(map);
45586
+ attachToMap() {
45481
45587
  const updateMaplibreMapDebounced = (0, import_lodash2.default)(
45482
45588
  this.updateMaplibreMap.bind(this),
45483
45589
  150
@@ -45491,14 +45597,6 @@ uniform ${i3} ${a3} u_${s3};
45491
45597
  })
45492
45598
  );
45493
45599
  }
45494
- // get queryRenderedFeaturesOptions(): maplibregl.QueryRenderedFeaturesOptions {
45495
- // return this.get('queryRenderedFeaturesOptions');
45496
- // }
45497
- // set queryRenderedFeaturesOptions(
45498
- // newValue: maplibregl.QueryRenderedFeaturesOptions,
45499
- // ) {
45500
- // this.set('queryRenderedFeaturesOptions', newValue);
45501
- // }
45502
45600
  /**
45503
45601
  * Create a copy of the MaplibreLayer.
45504
45602
  *
@@ -45508,10 +45606,13 @@ uniform ${i3} ${a3} u_${s3};
45508
45606
  */
45509
45607
  clone(newOptions) {
45510
45608
  return new _MaplibreLayer({
45511
- ...this.options || {},
45609
+ ...this.get("options") || {},
45512
45610
  ...newOptions || {}
45513
45611
  });
45514
45612
  }
45613
+ detachFromMap() {
45614
+ unByKey(this.olEventsKeys);
45615
+ }
45515
45616
  getStyle() {
45516
45617
  if (this.style && typeof this.style === "object" && this.style.name && this.style.version) {
45517
45618
  return this.style;
@@ -45519,11 +45620,28 @@ uniform ${i3} ${a3} u_${s3};
45519
45620
  if (this.url.includes("style.json")) {
45520
45621
  return this.url;
45521
45622
  }
45522
- if (this.get("mapLibreOptions")?.style) {
45523
- return this.get("mapLibreOptions").style;
45623
+ if (this.get("options")?.mapLibreOptions?.style) {
45624
+ return this.get("options").mapLibreOptions.style;
45524
45625
  }
45525
45626
  return buildStyleUrl(this.url, this.style, this.apiKey, this.apiKeyName);
45526
45627
  }
45628
+ // get queryRenderedFeaturesOptions(): maplibregl.QueryRenderedFeaturesOptions {
45629
+ // return this.get('queryRenderedFeaturesOptions');
45630
+ // }
45631
+ // set queryRenderedFeaturesOptions(
45632
+ // newValue: maplibregl.QueryRenderedFeaturesOptions,
45633
+ // ) {
45634
+ // this.set('queryRenderedFeaturesOptions', newValue);
45635
+ // }
45636
+ setMapInternal(map) {
45637
+ if (map) {
45638
+ super.setMapInternal(map);
45639
+ this.attachToMap();
45640
+ } else {
45641
+ this.detachFromMap();
45642
+ super.setMapInternal(map);
45643
+ }
45644
+ }
45527
45645
  updateMaplibreMap() {
45528
45646
  try {
45529
45647
  this.mapLibreMap?.setStyle(this.getStyle(), { diff: false });
@@ -45665,7 +45783,7 @@ uniform ${i3} ${a3} u_${s3};
45665
45783
  console.warn(...messages);
45666
45784
  }, 1e3);
45667
45785
  }
45668
- var MaplibreStyleLayer = class _MaplibreStyleLayer extends MobilityLayerMixin_default(Layer_default) {
45786
+ var MaplibreStyleLayer = class _MaplibreStyleLayer extends Layer_default {
45669
45787
  /**
45670
45788
  * Constructor.
45671
45789
  *
@@ -45704,7 +45822,10 @@ uniform ${i3} ${a3} u_${s3};
45704
45822
  }
45705
45823
  super({ source: new Source_default({}), ...options });
45706
45824
  this.highlightedFeatures = [];
45825
+ this.olEventsKeys = [];
45707
45826
  this.selectedFeatures = [];
45827
+ defineDeprecatedProperties_default(this, options);
45828
+ this.set("options", options);
45708
45829
  this.beforeId = options.beforeId;
45709
45830
  this.onLoad = this.onLoad.bind(this);
45710
45831
  if (!this.layersFilter && this.layers) {
@@ -45774,16 +45895,16 @@ uniform ${i3} ${a3} u_${s3};
45774
45895
  * @override
45775
45896
  */
45776
45897
  attachToMap(map) {
45777
- if (this.maplibreLayer && !this.maplibreLayer.map) {
45898
+ if (this.maplibreLayer && !this.maplibreLayer.getMapInternal()) {
45778
45899
  map.addLayer(this.maplibreLayer);
45779
45900
  }
45780
- super.attachToMap(map);
45781
- if (!this.map || !this.maplibreLayer) {
45901
+ const mapInternal = this.getMapInternal();
45902
+ if (!mapInternal || !this.maplibreLayer) {
45782
45903
  return;
45783
45904
  }
45784
- if (!this.map.getTargetElement()) {
45905
+ if (!mapInternal.getTargetElement()) {
45785
45906
  this.olEventsKeys.push(
45786
- this.map.on("change:target", () => {
45907
+ mapInternal.on("change:target", () => {
45787
45908
  this.attachToMap(map);
45788
45909
  })
45789
45910
  );
@@ -45829,7 +45950,7 @@ uniform ${i3} ${a3} u_${s3};
45829
45950
  * @public
45830
45951
  */
45831
45952
  clone(newOptions) {
45832
- return new _MaplibreStyleLayer({ ...this.options, ...newOptions });
45953
+ return new _MaplibreStyleLayer({ ...this.get("options"), ...newOptions });
45833
45954
  }
45834
45955
  createRenderer() {
45835
45956
  return new MaplibreStyleLayerRenderer(this);
@@ -45839,12 +45960,12 @@ uniform ${i3} ${a3} u_${s3};
45839
45960
  * @override
45840
45961
  */
45841
45962
  detachFromMap() {
45963
+ unByKey(this.olEventsKeys);
45842
45964
  if (this.maplibreLayer?.mapLibreMap) {
45843
45965
  this.maplibreLayer.mapLibreMap.off("load", this.onLoad);
45844
45966
  this.removeLayers();
45845
45967
  this.removeSources();
45846
45968
  }
45847
- super.detachFromMap();
45848
45969
  }
45849
45970
  /**
45850
45971
  * Request feature information for a given coordinate.
@@ -45995,6 +46116,15 @@ uniform ${i3} ${a3} u_${s3};
45995
46116
  );
45996
46117
  this.setFeatureState(features, { hover: state });
45997
46118
  }
46119
+ setMapInternal(map) {
46120
+ if (map) {
46121
+ super.setMapInternal(map);
46122
+ this.attachToMap(map);
46123
+ } else {
46124
+ this.detachFromMap();
46125
+ super.setMapInternal(map);
46126
+ }
46127
+ }
45998
46128
  get beforeId() {
45999
46129
  return this.get("beforeId");
46000
46130
  }
@@ -46871,17 +47001,24 @@ uniform ${i3} ${a3} u_${s3};
46871
47001
  if (minResolution && maxResolution && !inRange) {
46872
47002
  return [];
46873
47003
  }
47004
+ const zIndex = feature2?.getGeometry()?.getType() === "Point" ? 100 : 0;
47005
+ let styles = [blackBorder, redLine];
46874
47006
  const mot = feature2.get("mot");
46875
- if (mot !== "foot") {
46876
- return [blackBorder, redLine];
47007
+ if (mot === "foot") {
47008
+ styles = [dashedRedLine];
46877
47009
  }
46878
- return [dashedRedLine];
47010
+ styles = styles.map((style) => {
47011
+ const tmp = style.clone();
47012
+ tmp.setZIndex(zIndex);
47013
+ return tmp;
47014
+ });
47015
+ return styles;
46879
47016
  };
46880
47017
  var routingStyle_default = routingStyle;
46881
47018
 
46882
47019
  // src/ol/layers/RealtimeLayer.ts
46883
47020
  var format2 = new GeoJSON_default();
46884
- var RealtimeLayer = class _RealtimeLayer extends MobilityLayerMixin_default(Layer_default) {
47021
+ var RealtimeLayer = class _RealtimeLayer extends Layer_default {
46885
47022
  /**
46886
47023
  * Constructor.
46887
47024
  *
@@ -46899,6 +47036,8 @@ uniform ${i3} ${a3} u_${s3};
46899
47036
  });
46900
47037
  this.allowRenderWhenAnimating = false;
46901
47038
  this.maxNbFeaturesRequested = 100;
47039
+ this.olEventsKeys = [];
47040
+ defineDeprecatedProperties_default(this, options);
46902
47041
  this.engine = new RealtimeEngine_default({
46903
47042
  getViewState: this.getViewState.bind(this),
46904
47043
  onRender: this.onRealtimeEngineRender.bind(this),
@@ -46920,17 +47059,17 @@ uniform ${i3} ${a3} u_${s3};
46920
47059
  this.onZoomEndDebounced = (0, import_lodash6.default)(this.onZoomEnd, 100);
46921
47060
  this.onMoveEndDebounced = (0, import_lodash6.default)(this.onMoveEnd, 100);
46922
47061
  }
46923
- attachToMap(map) {
46924
- super.attachToMap(map);
47062
+ attachToMap() {
46925
47063
  this.engine.attachToMap();
46926
- if (this.map) {
47064
+ const mapInternal = this.getMapInternal();
47065
+ if (mapInternal) {
46927
47066
  if (this.getVisible()) {
46928
47067
  this.engine.start();
46929
47068
  }
46930
- const index = this.map.getLayers().getArray().indexOf(this);
46931
- this.map.getLayers().insertAt(index, this.vectorLayer);
47069
+ const index = mapInternal.getLayers().getArray().indexOf(this);
47070
+ mapInternal.getLayers().insertAt(index, this.vectorLayer);
46932
47071
  this.olEventsKeys.push(
46933
- ...this.map.on(
47072
+ ...mapInternal.on(
46934
47073
  ["moveend", "change:target"],
46935
47074
  // @ts-expect-error - bad ol definitions
46936
47075
  (evt) => {
@@ -46971,7 +47110,7 @@ uniform ${i3} ${a3} u_${s3};
46971
47110
  * @public
46972
47111
  */
46973
47112
  clone(newOptions) {
46974
- return new _RealtimeLayer({ ...this.options, ...newOptions });
47113
+ return new _RealtimeLayer({ ...this.get("options"), ...newOptions });
46975
47114
  }
46976
47115
  createRenderer() {
46977
47116
  return new RealtimeLayerRenderer(this);
@@ -46980,9 +47119,9 @@ uniform ${i3} ${a3} u_${s3};
46980
47119
  * Destroy the container of the tracker.
46981
47120
  */
46982
47121
  detachFromMap() {
46983
- this.map?.removeLayer(this.vectorLayer);
47122
+ unByKey(this.olEventsKeys);
47123
+ this.getMapInternal()?.removeLayer(this.vectorLayer);
46984
47124
  this.engine.detachFromMap();
46985
- super.detachFromMap();
46986
47125
  }
46987
47126
  /**
46988
47127
  * Get some informations about a trajectory.
@@ -46997,7 +47136,7 @@ uniform ${i3} ${a3} u_${s3};
46997
47136
  id,
46998
47137
  this.engine.mode,
46999
47138
  this.engine.getGeneralizationLevelByZoom(
47000
- Math.floor(this.map?.getView()?.getZoom() || 0)
47139
+ Math.floor(this.getMapInternal()?.getView()?.getZoom() || 0)
47001
47140
  )
47002
47141
  )
47003
47142
  ];
@@ -47013,17 +47152,18 @@ uniform ${i3} ${a3} u_${s3};
47013
47152
  return this.engine.getVehicles(filterFunc);
47014
47153
  }
47015
47154
  getViewState() {
47016
- if (!this.map?.getView()) {
47155
+ const mapInternal = this.getMapInternal();
47156
+ if (!mapInternal?.getView()) {
47017
47157
  return {};
47018
47158
  }
47019
- const view = this.map.getView();
47159
+ const view = mapInternal.getView();
47020
47160
  return {
47021
47161
  center: view.getCenter(),
47022
47162
  extent: view.calculateExtent(),
47023
47163
  pixelRatio: this.engine.pixelRatio,
47024
47164
  resolution: view.getResolution(),
47025
47165
  rotation: view.getRotation(),
47026
- size: this.map.getSize(),
47166
+ size: mapInternal.getSize(),
47027
47167
  visible: this.getVisible(),
47028
47168
  zoom: view.getZoom()
47029
47169
  };
@@ -47047,7 +47187,7 @@ uniform ${i3} ${a3} u_${s3};
47047
47187
  id,
47048
47188
  this.engine.mode,
47049
47189
  this.engine.getGeneralizationLevelByZoom(
47050
- Math.floor(this.map?.getView()?.getZoom() || 0)
47190
+ Math.floor(this.getMapInternal()?.getView()?.getZoom() || 0)
47051
47191
  )
47052
47192
  ).then((data) => {
47053
47193
  const fullTrajectory = data.content;
@@ -47098,8 +47238,17 @@ uniform ${i3} ${a3} u_${s3};
47098
47238
  }
47099
47239
  this.highlightTrajectory(id);
47100
47240
  }
47241
+ setMapInternal(map) {
47242
+ if (map) {
47243
+ super.setMapInternal(map);
47244
+ this.attachToMap();
47245
+ } else {
47246
+ this.detachFromMap();
47247
+ super.setMapInternal(map);
47248
+ }
47249
+ }
47101
47250
  shouldRender() {
47102
- return this.allowRenderWhenAnimating ? false : this.map.getView().getAnimating() || this.map.getView().getInteracting();
47251
+ return this.allowRenderWhenAnimating ? false : this.getMapInternal()?.getView().getAnimating() || this.getMapInternal()?.getView().getInteracting();
47103
47252
  }
47104
47253
  /**
47105
47254
  * Start the rendering.
@@ -47182,14 +47331,15 @@ uniform ${i3} ${a3} u_${s3};
47182
47331
  return null;
47183
47332
  }
47184
47333
  };
47185
- var Layer2 = class _Layer extends MobilityLayerMixin_default(Layer_default) {
47334
+ var Layer2 = class _Layer extends Layer_default {
47186
47335
  constructor(options) {
47187
47336
  super(options);
47337
+ defineDeprecatedProperties_default(this, options);
47188
47338
  deprecated4("Layer is deprecated. Use an OpenLayers Layer instead.");
47189
47339
  }
47190
47340
  clone(newOptions) {
47191
47341
  return new _Layer({
47192
- ...this.options || {},
47342
+ ...this.get("options") || {},
47193
47343
  ...newOptions || {}
47194
47344
  });
47195
47345
  }
@@ -47206,18 +47356,19 @@ uniform ${i3} ${a3} u_${s3};
47206
47356
  * @deprecated
47207
47357
  */
47208
47358
  clone(newOptions) {
47209
- return new _VectorLayer({ ...this.options, ...newOptions });
47359
+ return new _VectorLayer({ ...this.get("options"), ...newOptions });
47210
47360
  }
47211
47361
  /**
47212
47362
  * @deprecated
47213
47363
  */
47214
47364
  getFeatureInfoAtCoordinate(coordinate) {
47215
47365
  let features = [];
47216
- if (this.map) {
47217
- const pixel = this.map.getPixelFromCoordinate(coordinate);
47218
- features = this.map.getFeaturesAtPixel(pixel, {
47219
- hitTolerance: this.hitTolerance || 5,
47220
- layerFilter: (l) => l === this.olLayer
47366
+ const mapInternal = this.getMapInternal();
47367
+ if (mapInternal) {
47368
+ const pixel = mapInternal.getPixelFromCoordinate(coordinate);
47369
+ features = mapInternal.getFeaturesAtPixel(pixel, {
47370
+ hitTolerance: this.get("hitTolerance") || 5,
47371
+ layerFilter: (l) => l === this
47221
47372
  }) || [];
47222
47373
  }
47223
47374
  return Promise.resolve({