@wemap/routing 14.0.0-0
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 +47 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10780 -0
- package/dist/src/Router.d.ts +77 -0
- package/dist/src/Router.d.ts.map +1 -0
- package/dist/src/types.d.ts +10 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/vitest.config.d.ts +3 -0
- package/dist/vitest.config.d.ts.map +1 -0
- package/package.json +27 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { LatLngLike } from '../../core/src';
|
|
2
|
+
import { TravelMode, Itinerary } from '@wemap/routers-legacy';
|
|
3
|
+
import { RouteOptions } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Router for calculating routes and directions
|
|
6
|
+
*
|
|
7
|
+
* Provides route calculation capabilities using the Wemap routing API.
|
|
8
|
+
* Supports multiple travel modes and returns multiple itinerary options.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { Router } from '@wemap/routing';
|
|
13
|
+
* import { core } from '@wemap/core';
|
|
14
|
+
*
|
|
15
|
+
* // Initialize core SDK first
|
|
16
|
+
* await core.init({ emmid: '...', token: '...' });
|
|
17
|
+
*
|
|
18
|
+
* // Create router and calculate route
|
|
19
|
+
* const router = new Router();
|
|
20
|
+
* const itineraries = await router.directions(
|
|
21
|
+
* { lat: 48.8566, lon: 2.3522 },
|
|
22
|
+
* { lat: 48.8606, lon: 2.3376 },
|
|
23
|
+
* 'WALK',
|
|
24
|
+
* { isWheelchair: true }
|
|
25
|
+
* );
|
|
26
|
+
*
|
|
27
|
+
* console.log(`Found ${itineraries.length} route options`);
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare class Router {
|
|
31
|
+
private httpClient;
|
|
32
|
+
/**
|
|
33
|
+
* Create a new Router instance
|
|
34
|
+
*
|
|
35
|
+
* The router uses the multi-routers API endpoint. Make sure the Core SDK
|
|
36
|
+
* is initialized before calculating routes.
|
|
37
|
+
*/
|
|
38
|
+
constructor();
|
|
39
|
+
/**
|
|
40
|
+
* Calculate route directions between two points
|
|
41
|
+
*
|
|
42
|
+
* Calculates one or more route options between the origin and destination
|
|
43
|
+
* using the specified travel mode. Returns multiple itinerary options
|
|
44
|
+
* sorted by preference (usually fastest first).
|
|
45
|
+
*
|
|
46
|
+
* @param origin - Starting coordinates
|
|
47
|
+
* @param destination - Destination coordinates
|
|
48
|
+
* @param mode - Travel mode (e.g., 'WALK', 'BIKE', 'CAR', 'TRANSIT')
|
|
49
|
+
* @param options - Route calculation options
|
|
50
|
+
* @param options.isWheelchair - Whether to avoid stairs and escalators
|
|
51
|
+
* @param options.departureDate - Departure date/time (for transit routes)
|
|
52
|
+
* @returns Promise resolving to an array of itinerary options
|
|
53
|
+
* @throws {Error} If Core SDK is not initialized
|
|
54
|
+
* @throws {HttpError} If the route calculation fails
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* const itineraries = await router.directions(
|
|
59
|
+
* { lat: 48.8566, lon: 2.3522, alt: 0 },
|
|
60
|
+
* { lat: 48.8606, lon: 2.3376, alt: 0 },
|
|
61
|
+
* 'WALK',
|
|
62
|
+
* {
|
|
63
|
+
* isWheelchair: true,
|
|
64
|
+
* departureDate: new Date()
|
|
65
|
+
* }
|
|
66
|
+
* );
|
|
67
|
+
*
|
|
68
|
+
* // Use the first (usually best) itinerary
|
|
69
|
+
* const bestRoute = itineraries[0];
|
|
70
|
+
* console.log(`Route distance: ${bestRoute.distance}m`);
|
|
71
|
+
* console.log(`Route duration: ${bestRoute.duration}s`);
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
directions(origin: LatLngLike, destination: LatLngLike, mode?: TravelMode, options?: RouteOptions): Promise<Array<Itinerary>>;
|
|
75
|
+
private coordinatesToWaypoint;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=Router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Router.d.ts","sourceRoot":"","sources":["../../src/Router.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,KAAK,UAAU,EAA2B,MAAM,aAAa,CAAC;AAE/F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAa5C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,UAAU,CAAa;IAE/B;;;;;OAKG;;IAOH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACG,UAAU,CACd,MAAM,EAAE,UAAU,EAClB,WAAW,EAAE,UAAU,EACvB,IAAI,GAAE,UAAmB,EACzB,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAuB5B,OAAO,CAAC,qBAAqB;CAQ9B"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for route calculation
|
|
3
|
+
*/
|
|
4
|
+
export interface RouteOptions {
|
|
5
|
+
/** Whether to avoid stairs and escalators (PMR - Person with Reduced Mobility) */
|
|
6
|
+
isWheelchair?: boolean;
|
|
7
|
+
/** Departure date/time for the route (useful for transit routes) */
|
|
8
|
+
departureDate?: Date | null;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,kFAAkF;IAClF,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,oEAAoE;IACpE,aAAa,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CAC7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vitest.config.d.ts","sourceRoot":"","sources":["../vitest.config.ts"],"names":[],"mappings":";AAMA,wBAcG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wemap/routing",
|
|
3
|
+
"version": "14.0.0-0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"private": false,
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@wemap/core": "14.0.0-0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@wemap/routers-legacy": "^13.3.0",
|
|
25
|
+
"@wemap/geo-legacy": "^13.3.0"
|
|
26
|
+
}
|
|
27
|
+
}
|