@wemap/routers 12.0.0-alpha.10 → 12.0.0-alpha.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.
package/dist/index.js CHANGED
@@ -831,13 +831,34 @@ class Itinerary {
831
831
  }
832
832
  }
833
833
  toGeoJson() {
834
- return {
834
+ const transformToPoint = (point, name) => ({
835
835
  type: "Feature",
836
- properties: {},
836
+ properties: { name, level: point.level },
837
837
  geometry: {
838
- type: "MultiLineString",
839
- coordinates: this.legs.map((leg) => leg.coords.map(({ lat, lng }) => [lng, lat]))
838
+ type: "Point",
839
+ coordinates: [point.lng, point.lat]
840
840
  }
841
+ });
842
+ const transformToMultiLineStrings = (segments, level) => {
843
+ return {
844
+ type: "Feature",
845
+ properties: { level, name: level == null ? void 0 : level.toString() },
846
+ geometry: {
847
+ type: "MultiLineString",
848
+ coordinates: segments.map((s) => s.map(({ lat, lng }) => [lng, lat]))
849
+ }
850
+ };
851
+ };
852
+ const levelsOfItinerary = [...new Set(this.coords.map((c) => geo.Level.toString(c.level)))].map(geo.Level.fromString);
853
+ const segmentsSplitted = levelsOfItinerary.map((loi) => [loi, geo.Utils.createSegmentsAtLevel(this.coords, loi, true)]);
854
+ const multiLineStrings = segmentsSplitted.map(([loi, segments]) => transformToMultiLineStrings(segments, loi));
855
+ return {
856
+ type: "FeatureCollection",
857
+ features: [
858
+ transformToPoint(this.origin, "origin"),
859
+ transformToPoint(this.destination, "destination"),
860
+ ...multiLineStrings
861
+ ]
841
862
  };
842
863
  }
843
864
  /**
@@ -2493,8 +2514,8 @@ class WemapMultiRouter {
2493
2514
  }
2494
2515
  const newRouterRequest = {
2495
2516
  ...routerRequest,
2496
- origin: ioMapRoute.end,
2497
- destination,
2517
+ origin,
2518
+ destination: ioMapRoute.start,
2498
2519
  waypoints: []
2499
2520
  };
2500
2521
  try {