mobility-toolbox-js 3.0.0-beta.35 → 3.0.0-beta.37

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/README.md CHANGED
@@ -10,7 +10,7 @@ The tools in this library have been inspired by many projects realized for publi
10
10
 
11
11
  ## Documentation and examples
12
12
 
13
- Visit https://mobility-toolbox-js.vercel.app/
13
+ Visit https://mobility-toolbox-js.geops.io/
14
14
 
15
15
  ## Demos
16
16
 
@@ -24,7 +24,7 @@ Visit https://mobility-toolbox-js.vercel.app/
24
24
  Install the library and the peer dependencies:
25
25
 
26
26
  ```bash
27
- yarn add mobility-toolbox-js ol maplibre-gl
27
+ yarn add ol maplibre-gl mobility-toolbox-js
28
28
  ```
29
29
 
30
30
  ## Development
@@ -34,9 +34,17 @@ yarn install
34
34
  yarn dev
35
35
  ```
36
36
 
37
+ `yarn dev` starts a vite server using the `index.html` file at the root of the project.
38
+ This html file loads the `dev.js` file. Use this file to develop the library.
39
+ Each time you modifiy the library code you have to run `yarn build:tsc` to see the changes.
40
+
41
+ ## Development documentation
42
+
43
+ The documentations website is located in the `doc/` folder.
44
+ It's a nextJS website that use the mobility-toolbox-js library built from the `build/` folder.
45
+
37
46
  ## Deploy
38
47
 
39
48
  This library website is deployed automatically using [Vercel](https://vercel.com/geops).
40
49
  For Vercel we have to add the nextjs and raw-loader modules in the dev dependencies of the main package.json.
41
50
  But those 2 librairies are not needed to build the library.
42
-
package/mbt.js CHANGED
@@ -43225,13 +43225,13 @@ uniform ${i3} ${a3} u_${s3};
43225
43225
  }
43226
43226
  const map = this.getMap();
43227
43227
  if (map && map.isRendered() && this.getActive()) {
43228
- this.handlePointerAtPixel_(this.lastPixel_, map);
43228
+ this.handlePointerAtPixel_(map.getCoordinateFromPixel(this.lastPixel_));
43229
43229
  }
43230
43230
  feature2.addEventListener(EventType_default.CHANGE, this.boundHandleFeatureChange_);
43231
43231
  }
43232
43232
  /**
43233
43233
  * @param {import("../MapBrowserEvent.js").default} evt Map browser event.
43234
- * @param {Array<Array<SegmentData>>} segments The segments subject to modification.
43234
+ * @param {Array<SegmentData>} segments The segments subject to modification.
43235
43235
  * @private
43236
43236
  */
43237
43237
  willModifyFeatures_(evt, segments) {
@@ -43239,12 +43239,9 @@ uniform ${i3} ${a3} u_${s3};
43239
43239
  this.featuresBeingModified_ = new Collection_default();
43240
43240
  const features = this.featuresBeingModified_.getArray();
43241
43241
  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
- }
43242
+ const feature2 = segments[i].feature;
43243
+ if (feature2 && !features.includes(feature2)) {
43244
+ this.featuresBeingModified_.push(feature2);
43248
43245
  }
43249
43246
  }
43250
43247
  if (this.featuresBeingModified_.getLength() === 0) {
@@ -43562,10 +43559,11 @@ uniform ${i3} ${a3} u_${s3};
43562
43559
  * @param {import("../coordinate.js").Coordinate} coordinates Coordinates.
43563
43560
  * @param {Array<Feature>} features The features being modified.
43564
43561
  * @param {Array<import("../geom/SimpleGeometry.js").default>} geometries The geometries being modified.
43562
+ * @param {boolean} existing The vertex represents an existing vertex.
43565
43563
  * @return {Feature} Vertex feature.
43566
43564
  * @private
43567
43565
  */
43568
- createOrUpdateVertexFeature_(coordinates2, features, geometries) {
43566
+ createOrUpdateVertexFeature_(coordinates2, features, geometries, existing) {
43569
43567
  let vertexFeature = this.vertexFeature_;
43570
43568
  if (!vertexFeature) {
43571
43569
  vertexFeature = new Feature_default(new Point_default(coordinates2));
@@ -43577,6 +43575,7 @@ uniform ${i3} ${a3} u_${s3};
43577
43575
  }
43578
43576
  vertexFeature.set("features", features);
43579
43577
  vertexFeature.set("geometries", geometries);
43578
+ vertexFeature.set("existing", existing);
43580
43579
  return vertexFeature;
43581
43580
  }
43582
43581
  /**
@@ -43606,6 +43605,80 @@ uniform ${i3} ${a3} u_${s3};
43606
43605
  }
43607
43606
  return super.handleEvent(mapBrowserEvent) && !handled;
43608
43607
  }
43608
+ findInsertVerticesAndUpdateDragSegments_(pixelCoordinate) {
43609
+ this.handlePointerAtPixel_(pixelCoordinate);
43610
+ this.dragSegments_.length = 0;
43611
+ this.featuresBeingModified_ = null;
43612
+ const vertexFeature = this.vertexFeature_;
43613
+ if (!vertexFeature) {
43614
+ return;
43615
+ }
43616
+ const projection = this.getMap().getView().getProjection();
43617
+ const insertVertices = [];
43618
+ const vertex = vertexFeature.getGeometry().getCoordinates();
43619
+ const vertexExtent = boundingExtent([vertex]);
43620
+ const segmentDataMatches = this.rBush_.getInExtent(vertexExtent);
43621
+ const componentSegments = {};
43622
+ segmentDataMatches.sort(compareIndexes);
43623
+ for (let i = 0, ii = segmentDataMatches.length; i < ii; ++i) {
43624
+ const segmentDataMatch = segmentDataMatches[i];
43625
+ const segment = segmentDataMatch.segment;
43626
+ let uid = getUid(segmentDataMatch.geometry);
43627
+ const depth = segmentDataMatch.depth;
43628
+ if (depth) {
43629
+ uid += "-" + depth.join("-");
43630
+ }
43631
+ if (!componentSegments[uid]) {
43632
+ componentSegments[uid] = new Array(2);
43633
+ }
43634
+ if (segmentDataMatch.geometry.getType() === "Circle" && segmentDataMatch.index === CIRCLE_CIRCUMFERENCE_INDEX) {
43635
+ const closestVertex = closestOnSegmentData(
43636
+ pixelCoordinate,
43637
+ segmentDataMatch,
43638
+ projection
43639
+ );
43640
+ if (equals3(closestVertex, vertex) && !componentSegments[uid][0]) {
43641
+ this.dragSegments_.push([segmentDataMatch, 0]);
43642
+ componentSegments[uid][0] = segmentDataMatch;
43643
+ }
43644
+ continue;
43645
+ }
43646
+ if (equals3(segment[0], vertex) && !componentSegments[uid][0]) {
43647
+ this.dragSegments_.push([segmentDataMatch, 0]);
43648
+ componentSegments[uid][0] = segmentDataMatch;
43649
+ continue;
43650
+ }
43651
+ if (equals3(segment[1], vertex) && !componentSegments[uid][1]) {
43652
+ if (componentSegments[uid][0] && componentSegments[uid][0].index === 0) {
43653
+ let coordinates2 = segmentDataMatch.geometry.getCoordinates();
43654
+ switch (segmentDataMatch.geometry.getType()) {
43655
+ // prevent dragging closed linestrings by the connecting node
43656
+ case "LineString":
43657
+ case "MultiLineString":
43658
+ continue;
43659
+ // if dragging the first vertex of a polygon, ensure the other segment
43660
+ // belongs to the closing vertex of the linear ring
43661
+ case "MultiPolygon":
43662
+ coordinates2 = coordinates2[depth[1]];
43663
+ /* falls through */
43664
+ case "Polygon":
43665
+ if (segmentDataMatch.index !== coordinates2[depth[0]].length - 2) {
43666
+ continue;
43667
+ }
43668
+ break;
43669
+ default:
43670
+ }
43671
+ }
43672
+ this.dragSegments_.push([segmentDataMatch, 1]);
43673
+ componentSegments[uid][1] = segmentDataMatch;
43674
+ continue;
43675
+ }
43676
+ if (getUid(segment) in this.vertexSegments_ && !componentSegments[uid][0] && !componentSegments[uid][1]) {
43677
+ insertVertices.push(segmentDataMatch);
43678
+ }
43679
+ }
43680
+ return insertVertices;
43681
+ }
43609
43682
  /**
43610
43683
  * Handle pointer drag events.
43611
43684
  * @param {import("../MapBrowserEvent.js").default} evt Event.
@@ -43613,7 +43686,10 @@ uniform ${i3} ${a3} u_${s3};
43613
43686
  */
43614
43687
  handleDragEvent(evt) {
43615
43688
  this.ignoreNextSingleClick_ = false;
43616
- this.willModifyFeatures_(evt, this.dragSegments_);
43689
+ this.willModifyFeatures_(
43690
+ evt,
43691
+ this.dragSegments_.map(([segment]) => segment)
43692
+ );
43617
43693
  const vertex = [
43618
43694
  evt.coordinate[0] + this.delta_[0],
43619
43695
  evt.coordinate[1] + this.delta_[1]
@@ -43671,26 +43747,30 @@ uniform ${i3} ${a3} u_${s3};
43671
43747
  segment[index] = vertex;
43672
43748
  break;
43673
43749
  case "Circle":
43750
+ const circle = (
43751
+ /** @type {import("../geom/Circle.js").default} */
43752
+ geometry
43753
+ );
43674
43754
  segment[0] = vertex;
43675
43755
  segment[1] = vertex;
43676
43756
  if (segmentData.index === CIRCLE_CENTER_INDEX) {
43677
43757
  this.changingFeature_ = true;
43678
- geometry.setCenter(vertex);
43758
+ circle.setCenter(vertex);
43679
43759
  this.changingFeature_ = false;
43680
43760
  } else {
43681
43761
  this.changingFeature_ = true;
43682
43762
  const projection = evt.map.getView().getProjection();
43683
43763
  let radius = distance(
43684
- fromUserCoordinate(geometry.getCenter(), projection),
43764
+ fromUserCoordinate(circle.getCenter(), projection),
43685
43765
  fromUserCoordinate(vertex, projection)
43686
43766
  );
43687
43767
  const userProjection2 = getUserProjection();
43688
43768
  if (userProjection2) {
43689
- const circleGeometry = geometry.clone().transform(userProjection2, projection);
43769
+ const circleGeometry = circle.clone().transform(userProjection2, projection);
43690
43770
  circleGeometry.setRadius(radius);
43691
43771
  radius = circleGeometry.transform(projection, userProjection2).getRadius();
43692
43772
  }
43693
- geometry.setRadius(radius);
43773
+ circle.setRadius(radius);
43694
43774
  this.changingFeature_ = false;
43695
43775
  }
43696
43776
  break;
@@ -43700,7 +43780,7 @@ uniform ${i3} ${a3} u_${s3};
43700
43780
  this.setGeometryCoordinates_(geometry, coordinates2);
43701
43781
  }
43702
43782
  }
43703
- this.createOrUpdateVertexFeature_(vertex, features, geometries);
43783
+ this.createOrUpdateVertexFeature_(vertex, features, geometries, true);
43704
43784
  }
43705
43785
  /**
43706
43786
  * Handle pointer down events.
@@ -43713,80 +43793,15 @@ uniform ${i3} ${a3} u_${s3};
43713
43793
  return false;
43714
43794
  }
43715
43795
  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;
43780
- }
43781
- if (getUid(segment) in this.vertexSegments_ && !componentSegments[uid][0] && !componentSegments[uid][1] && this.insertVertexCondition_(evt)) {
43782
- insertVertices.push(segmentDataMatch);
43796
+ const insertVertices = this.findInsertVerticesAndUpdateDragSegments_(pixelCoordinate);
43797
+ if (insertVertices?.length && this.insertVertexCondition_(evt)) {
43798
+ this.willModifyFeatures_(evt, insertVertices);
43799
+ if (this.vertexFeature_) {
43800
+ const vertex = this.vertexFeature_.getGeometry().getCoordinates();
43801
+ for (let j = insertVertices.length - 1; j >= 0; --j) {
43802
+ this.insertVertex_(insertVertices[j], vertex);
43783
43803
  }
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);
43804
+ this.ignoreNextSingleClick_ = true;
43790
43805
  }
43791
43806
  }
43792
43807
  return !!this.vertexFeature_;
@@ -43802,7 +43817,11 @@ uniform ${i3} ${a3} u_${s3};
43802
43817
  const segmentData = this.dragSegments_[i][0];
43803
43818
  const geometry = segmentData.geometry;
43804
43819
  if (geometry.getType() === "Circle") {
43805
- const coordinates2 = geometry.getCenter();
43820
+ const circle = (
43821
+ /** @type {import("../geom/Circle.js").default} */
43822
+ geometry
43823
+ );
43824
+ const coordinates2 = circle.getCenter();
43806
43825
  const centerSegmentData = segmentData.featureSegments[0];
43807
43826
  const circumferenceSegmentData = segmentData.featureSegments[1];
43808
43827
  centerSegmentData.segment[0] = coordinates2;
@@ -43810,7 +43829,7 @@ uniform ${i3} ${a3} u_${s3};
43810
43829
  circumferenceSegmentData.segment[0] = coordinates2;
43811
43830
  circumferenceSegmentData.segment[1] = coordinates2;
43812
43831
  this.rBush_.update(createOrUpdateFromCoordinate(coordinates2), centerSegmentData);
43813
- let circleGeometry = geometry;
43832
+ let circleGeometry = circle;
43814
43833
  const userProjection2 = getUserProjection();
43815
43834
  if (userProjection2) {
43816
43835
  const projection = evt.map.getView().getProjection();
@@ -43846,16 +43865,15 @@ uniform ${i3} ${a3} u_${s3};
43846
43865
  */
43847
43866
  handlePointerMove_(evt) {
43848
43867
  this.lastPixel_ = evt.pixel;
43849
- this.handlePointerAtPixel_(evt.pixel, evt.map, evt.coordinate);
43868
+ this.handlePointerAtPixel_(evt.coordinate);
43850
43869
  }
43851
43870
  /**
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.
43871
+ * @param {import("../coordinate.js").Coordinate} pixelCoordinate The pixel Coordinate.
43855
43872
  * @private
43856
43873
  */
43857
- handlePointerAtPixel_(pixel, map, coordinate) {
43858
- const pixelCoordinate = coordinate || map.getCoordinateFromPixel(pixel);
43874
+ handlePointerAtPixel_(pixelCoordinate) {
43875
+ const map = this.getMap();
43876
+ const pixel = map.getPixelFromCoordinate(pixelCoordinate);
43859
43877
  const projection = map.getView().getProjection();
43860
43878
  const sortByDistance = function(a, b) {
43861
43879
  return projectedDistanceToSegmentDataSquared(pixelCoordinate, a, projection) - projectedDistanceToSegmentDataSquared(pixelCoordinate, b, projection);
@@ -43873,10 +43891,10 @@ uniform ${i3} ${a3} u_${s3};
43873
43891
  );
43874
43892
  }
43875
43893
  const geom = geometry || feature2.getGeometry();
43876
- if (feature2 instanceof Feature_default && this.features_.getArray().includes(feature2)) {
43894
+ if (geom && geom.getType() === "Point" && feature2 instanceof Feature_default && this.features_.getArray().includes(feature2)) {
43877
43895
  hitPointGeometry = /** @type {Point} */
43878
43896
  geom;
43879
- const coordinate2 = (
43897
+ const coordinate = (
43880
43898
  /** @type {Point} */
43881
43899
  feature2.getGeometry().getFlatCoordinates().slice(0, 2)
43882
43900
  );
@@ -43884,7 +43902,7 @@ uniform ${i3} ${a3} u_${s3};
43884
43902
  {
43885
43903
  feature: feature2,
43886
43904
  geometry: hitPointGeometry,
43887
- segment: [coordinate2, coordinate2]
43905
+ segment: [coordinate, coordinate]
43888
43906
  }
43889
43907
  ];
43890
43908
  }
@@ -43923,7 +43941,8 @@ uniform ${i3} ${a3} u_${s3};
43923
43941
  this.createOrUpdateVertexFeature_(
43924
43942
  vertex,
43925
43943
  [node.feature],
43926
- [node.geometry]
43944
+ [node.geometry],
43945
+ this.snappedToVertex_
43927
43946
  );
43928
43947
  } else {
43929
43948
  const pixel1 = map.getPixelFromCoordinate(closestSegment[0]);
@@ -43938,7 +43957,8 @@ uniform ${i3} ${a3} u_${s3};
43938
43957
  this.createOrUpdateVertexFeature_(
43939
43958
  vertex,
43940
43959
  [node.feature],
43941
- [node.geometry]
43960
+ [node.geometry],
43961
+ this.snappedToVertex_
43942
43962
  );
43943
43963
  const geometries = {};
43944
43964
  geometries[getUid(node.geometry)] = true;
@@ -43967,6 +43987,7 @@ uniform ${i3} ${a3} u_${s3};
43967
43987
  /**
43968
43988
  * @param {SegmentData} segmentData Segment data.
43969
43989
  * @param {import("../coordinate.js").Coordinate} vertex Vertex.
43990
+ * @return {boolean} A vertex was inserted.
43970
43991
  * @private
43971
43992
  */
43972
43993
  insertVertex_(segmentData, vertex) {
@@ -43997,7 +44018,7 @@ uniform ${i3} ${a3} u_${s3};
43997
44018
  coordinates2.splice(index + 1, 0, vertex);
43998
44019
  break;
43999
44020
  default:
44000
- return;
44021
+ return false;
44001
44022
  }
44002
44023
  this.setGeometryCoordinates_(geometry, coordinates2);
44003
44024
  const rTree = this.rBush_;
@@ -44021,17 +44042,70 @@ uniform ${i3} ${a3} u_${s3};
44021
44042
  };
44022
44043
  rTree.insert(boundingExtent(newSegmentData2.segment), newSegmentData2);
44023
44044
  this.dragSegments_.push([newSegmentData2, 0]);
44024
- this.ignoreNextSingleClick_ = true;
44045
+ return true;
44046
+ }
44047
+ updatePointer_(coordinate) {
44048
+ if (coordinate) {
44049
+ this.findInsertVerticesAndUpdateDragSegments_(coordinate);
44050
+ }
44051
+ return this.vertexFeature_?.getGeometry().getCoordinates();
44052
+ }
44053
+ /**
44054
+ * Get the current pointer position.
44055
+ * @return {import("../coordinate.js").Coordinate | null} The current pointer coordinate.
44056
+ */
44057
+ getPoint() {
44058
+ const coordinate = this.vertexFeature_?.getGeometry().getCoordinates();
44059
+ if (!coordinate) {
44060
+ return null;
44061
+ }
44062
+ return toUserCoordinate(
44063
+ coordinate,
44064
+ this.getMap().getView().getProjection()
44065
+ );
44066
+ }
44067
+ /**
44068
+ * Check if a point can be removed from the current linestring or polygon at the current
44069
+ * pointer position.
44070
+ * @return {boolean} A point can be deleted at the current pointer position.
44071
+ * @api
44072
+ */
44073
+ canRemovePoint() {
44074
+ if (!this.vertexFeature_) {
44075
+ return false;
44076
+ }
44077
+ if (this.vertexFeature_.get("geometries").every(
44078
+ (geometry) => geometry.getType() === "Circle" || geometry.getType().endsWith("Point")
44079
+ )) {
44080
+ return false;
44081
+ }
44082
+ const coordinate = this.vertexFeature_.getGeometry().getCoordinates();
44083
+ const segments = this.rBush_.getInExtent(boundingExtent([coordinate]));
44084
+ return segments.some(
44085
+ ({ segment }) => equals3(segment[0], coordinate) || equals3(segment[1], coordinate)
44086
+ );
44025
44087
  }
44026
44088
  /**
44027
- * Removes the vertex currently being pointed.
44089
+ * Removes the vertex currently being pointed from the current linestring or polygon.
44090
+ * @param {import('../coordinate.js').Coordinate} [coordinate] If provided, the pointer
44091
+ * will be set to the provided coordinate. If not, the current pointer coordinate will be used.
44028
44092
  * @return {boolean} True when a vertex was removed.
44029
44093
  * @api
44030
44094
  */
44031
- removePoint() {
44032
- if (this.lastPointerEvent_ && this.lastPointerEvent_.type != MapBrowserEventType_default.POINTERDRAG) {
44095
+ removePoint(coordinate) {
44096
+ if (coordinate) {
44097
+ coordinate = fromUserCoordinate(
44098
+ coordinate,
44099
+ this.getMap().getView().getProjection()
44100
+ );
44101
+ this.updatePointer_(coordinate);
44102
+ }
44103
+ if (!this.lastPointerEvent_ || this.lastPointerEvent_ && this.lastPointerEvent_.type != MapBrowserEventType_default.POINTERDRAG) {
44033
44104
  const evt = this.lastPointerEvent_;
44034
- this.willModifyFeatures_(evt, this.dragSegments_);
44105
+ this.willModifyFeatures_(
44106
+ evt,
44107
+ this.dragSegments_.map(([segment]) => segment)
44108
+ );
44035
44109
  const removed = this.removeVertex_();
44036
44110
  if (this.featuresBeingModified_) {
44037
44111
  this.dispatchEvent(
@@ -44160,6 +44234,45 @@ uniform ${i3} ${a3} u_${s3};
44160
44234
  }
44161
44235
  return deleted;
44162
44236
  }
44237
+ /**
44238
+ * Check if a point can be inserted to the current linestring or polygon at the current
44239
+ * pointer position.
44240
+ * @return {boolean} A point can be inserted at the current pointer position.
44241
+ * @api
44242
+ */
44243
+ canInsertPoint() {
44244
+ if (!this.vertexFeature_) {
44245
+ return false;
44246
+ }
44247
+ if (this.vertexFeature_.get("geometries").every(
44248
+ (geometry) => geometry.getType() === "Circle" || geometry.getType().endsWith("Point")
44249
+ )) {
44250
+ return false;
44251
+ }
44252
+ const coordinate = this.vertexFeature_.getGeometry().getCoordinates();
44253
+ const segments = this.rBush_.getInExtent(boundingExtent([coordinate]));
44254
+ return segments.some(
44255
+ ({ segment }) => !(equals3(segment[0], coordinate) || equals3(segment[1], coordinate))
44256
+ );
44257
+ }
44258
+ /**
44259
+ * Inserts the vertex currently being pointed to the current linestring or polygon.
44260
+ * @param {import('../coordinate.js').Coordinate} [coordinate] If provided, the pointer
44261
+ * will be set to the provided coordinate. If not, the current pointer coordinate will be used.
44262
+ * @return {boolean} A vertex was inserted.
44263
+ * @api
44264
+ */
44265
+ insertPoint(coordinate) {
44266
+ const pixelCoordinate = coordinate ? fromUserCoordinate(coordinate, this.getMap().getView().getProjection()) : this.vertexFeature_?.getGeometry().getCoordinates();
44267
+ if (!pixelCoordinate) {
44268
+ return false;
44269
+ }
44270
+ const insertVertices = this.findInsertVerticesAndUpdateDragSegments_(pixelCoordinate);
44271
+ return insertVertices.reduce(
44272
+ (prev, segmentData) => prev || this.insertVertex_(segmentData, pixelCoordinate),
44273
+ false
44274
+ );
44275
+ }
44163
44276
  /**
44164
44277
  * @param {import("../geom/SimpleGeometry.js").default} geometry Geometry.
44165
44278
  * @param {Array} coordinates Coordinates.
@@ -44435,7 +44548,7 @@ uniform ${i3} ${a3} u_${s3};
44435
44548
  */
44436
44549
  createModifyInteraction() {
44437
44550
  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
44551
+ // hitDetection: this.routingLayer, // TODO: wait for ol, fixed in https://github.com/openlayers/openlayers/pull/16393
44439
44552
  deleteCondition: (e) => {
44440
44553
  const feats = e.target?.getFeaturesAtPixel(e.pixel, {
44441
44554
  hitTolerance: 5
@@ -44475,7 +44588,7 @@ uniform ${i3} ${a3} u_${s3};
44475
44588
  */
44476
44589
  drawRoute() {
44477
44590
  this.abortRequests();
44478
- this.routingLayer?.getSource()?.clear(true);
44591
+ this.routingLayer?.getSource()?.clear();
44479
44592
  if (!this.viaPoints.length) {
44480
44593
  return null;
44481
44594
  }
@@ -45355,7 +45468,7 @@ uniform ${i3} ${a3} u_${s3};
45355
45468
  this.set("hitTolerance", newValue);
45356
45469
  }
45357
45470
  get key() {
45358
- return this.get("key") || this.get("name") || getUid(this);
45471
+ return this.get("key") || this.get("name");
45359
45472
  }
45360
45473
  get map() {
45361
45474
  return this.getMapInternal();
@@ -45471,6 +45584,7 @@ uniform ${i3} ${a3} u_${s3};
45471
45584
  );
45472
45585
  }
45473
45586
  super(newOptions);
45587
+ this.set("options", options);
45474
45588
  }
45475
45589
  /**
45476
45590
  * Initialize the layer and listen to feature clicks.
@@ -45519,6 +45633,9 @@ uniform ${i3} ${a3} u_${s3};
45519
45633
  if (this.url.includes("style.json")) {
45520
45634
  return this.url;
45521
45635
  }
45636
+ if (this.get("options")?.mapLibreOptions?.style) {
45637
+ return this.get("options").mapLibreOptions.style;
45638
+ }
45522
45639
  return buildStyleUrl(this.url, this.style, this.apiKey, this.apiKeyName);
45523
45640
  }
45524
45641
  updateMaplibreMap() {
@@ -46868,11 +46985,18 @@ uniform ${i3} ${a3} u_${s3};
46868
46985
  if (minResolution && maxResolution && !inRange) {
46869
46986
  return [];
46870
46987
  }
46988
+ const zIndex = feature2?.getGeometry()?.getType() === "Point" ? 100 : 0;
46989
+ let styles = [blackBorder, redLine];
46871
46990
  const mot = feature2.get("mot");
46872
- if (mot !== "foot") {
46873
- return [blackBorder, redLine];
46991
+ if (mot === "foot") {
46992
+ styles = [dashedRedLine];
46874
46993
  }
46875
- return [dashedRedLine];
46994
+ styles = styles.map((style) => {
46995
+ const tmp = style.clone();
46996
+ tmp.setZIndex(zIndex);
46997
+ return tmp;
46998
+ });
46999
+ return styles;
46876
47000
  };
46877
47001
  var routingStyle_default = routingStyle;
46878
47002