@wemap/routers 12.11.1 → 12.11.2

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.mjs CHANGED
@@ -5180,6 +5180,85 @@ const _InstructionManager = class _InstructionManager {
5180
5180
  };
5181
5181
  __publicField(_InstructionManager, "useProposals", false);
5182
5182
  let InstructionManager = _InstructionManager;
5183
+ class InstructionManagerV1 {
5184
+ // eslint-disable-next-line max-statements, complexity
5185
+ static getInstructionFromStep(step) {
5186
+ var _a;
5187
+ const modifier = OsrmRemoteRouter$1.getModifierFromAngle(step.angle);
5188
+ let direction, directionExtra;
5189
+ if (modifier.includes("left")) {
5190
+ direction = "left";
5191
+ } else if (modifier.includes("right")) {
5192
+ direction = "right";
5193
+ }
5194
+ if (modifier.includes("slight")) {
5195
+ directionExtra = "slight";
5196
+ }
5197
+ const isTurn = modifier !== "straight";
5198
+ if (step.lastStep) {
5199
+ if (isTurn && direction === "left") {
5200
+ return "Your destination is on your left";
5201
+ } else if (isTurn && direction === "right") {
5202
+ return "Your destination is on your right";
5203
+ }
5204
+ }
5205
+ const suffix = step.name ? ` on ${step.name}` : "";
5206
+ if (step.levelChange) {
5207
+ if (step.levelChange.direction === "up") {
5208
+ if (step.levelChange.type === "escalator") {
5209
+ return "Go up the escalator";
5210
+ }
5211
+ if (step.levelChange.type === "stairs") {
5212
+ return "Go up the stairs";
5213
+ }
5214
+ return "Go up" + suffix;
5215
+ }
5216
+ if (step.levelChange.direction === "down") {
5217
+ if (step.levelChange.type === "escalator") {
5218
+ return "Go down the escalator";
5219
+ }
5220
+ if (step.levelChange.type === "stairs") {
5221
+ return "Go down the stairs";
5222
+ }
5223
+ return "Go down" + suffix;
5224
+ }
5225
+ if ((_a = step.extras) == null ? void 0 : _a.subwayEntrance) {
5226
+ return `Take exit ${step.extras.subwayEntranceRef}`;
5227
+ }
5228
+ }
5229
+ if (isTurn) {
5230
+ if (direction === "left") {
5231
+ if (directionExtra === "slight") {
5232
+ return "Turn slightly left" + suffix;
5233
+ }
5234
+ return "Turn left" + suffix;
5235
+ }
5236
+ if (direction === "right") {
5237
+ if (directionExtra === "slight") {
5238
+ return "Turn slightly right" + suffix;
5239
+ }
5240
+ return "Turn right" + suffix;
5241
+ }
5242
+ }
5243
+ return "";
5244
+ }
5245
+ static getInstructionFromPosition(itineraryInfoManager, position) {
5246
+ const itineraryInfo = itineraryInfoManager.getInfo(position);
5247
+ if (!itineraryInfo) {
5248
+ return null;
5249
+ }
5250
+ const { nextStep } = itineraryInfo;
5251
+ if (!nextStep) {
5252
+ return null;
5253
+ }
5254
+ const distNextStep = position.distanceTo(nextStep.coords);
5255
+ const nextStep2 = itineraryInfoManager._steps.find((step) => step.number > nextStep.number);
5256
+ if (distNextStep < 3 && nextStep2) {
5257
+ return InstructionManagerV1.getInstructionFromStep(nextStep2);
5258
+ }
5259
+ return InstructionManagerV1.getInstructionFromStep(nextStep);
5260
+ }
5261
+ }
5183
5262
  export {
5184
5263
  CitywayRemoteRouter$1 as CitywayRemoteRouter,
5185
5264
  CustomGraphMap,
@@ -5194,6 +5273,7 @@ export {
5194
5273
  GraphRouterOptionsBuilder,
5195
5274
  IdfmRemoteRouter$1 as IdfmRemoteRouter,
5196
5275
  InstructionManager,
5276
+ InstructionManagerV1,
5197
5277
  Itinerary,
5198
5278
  ItineraryInfoManager,
5199
5279
  Leg,