mapricot 0.10.0 → 0.11.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 CHANGED
@@ -35,6 +35,7 @@ Methods are grouped by product, the same way as the API's paths. Each returns th
35
35
  | `client.places.nearby(lat, lon, { category, radius, limit, lang })` | [`GET /places/v1/nearby`](https://mapricot.com/docs/places/#list-places-around-a-point) |
36
36
  | `client.places.get(id, { lang })` | [`GET /places/v1/{id}`](https://mapricot.com/docs/places/#look-up-a-saved-place) |
37
37
  | `client.routing.route(waypoints, { mode, geometries, steps, lang })` | [`POST /routing/v1/route`](https://mapricot.com/docs/routing/#get-a-route) |
38
+ | `client.routing.optimize(waypoints, { mode, geometries, steps, lang })` | [`POST /routing/v1/optimize`](https://mapricot.com/docs/routing/#optimize-the-order-of-stops) |
38
39
  | `client.routing.isochrone(location, minutes, { mode })` | [`POST /routing/v1/isochrone`](https://mapricot.com/docs/routing/#get-an-isochrone) |
39
40
  | `client.ipGeolocation.lookup(ip)` | [`GET /ip-geolocation/v1/{ip}`](https://mapricot.com/docs/ip-geolocation/#look-up-an-address) |
40
41
  | `client.account()` | `GET /account`, which checks a key and is never billed |
@@ -57,6 +58,8 @@ controller.abort();
57
58
 
58
59
  A route's path comes as an encoded `polyline` with five decimal places, which polyline decoders assume. Pass `geometries: "geojson"` to get it as a GeoJSON `LineString` in `geometry` instead, which maps draw without decoding, or `geometries: "polyline6"` for six decimal places.
59
60
 
61
+ `routing.optimize` takes the same options as `routing.route` and returns the route that visits the waypoints in a fast order, keeping the first and last in place. It adds `waypointOrder`: the indexes of your waypoints in visiting order, which `legs` follow. Every pair of waypoints must be within 400 km of each other for `drive`, or 200 km for `walk` and `bicycle`.
62
+
60
63
  An isochrone is a GeoJSON `FeatureCollection` with one polygon per time, largest first, so a map that draws them in order shows the smaller ones on top:
61
64
 
62
65
  ```js
package/dist/index.d.ts CHANGED
@@ -55,6 +55,8 @@ export interface Step {
55
55
  lon: number;
56
56
  }
57
57
  export interface Route {
58
+ /** From `routing.optimize` only: the indexes of the waypoints you sent, in the order the route visits them. */
59
+ waypointOrder?: number[];
58
60
  distanceMeters: number;
59
61
  durationSeconds: number;
60
62
  /** Encoded polyline, with five decimal places unless `geometries` was `polyline6`. Absent for `geojson`. */
@@ -178,6 +180,13 @@ export declare class Mapricot {
178
180
  steps?: boolean;
179
181
  lang?: string;
180
182
  }) => Promise<Routes>;
183
+ /** Find a fast route through 2 to 20 waypoints, keeping the first and last in place and reordering the rest. */
184
+ optimize: (waypoints: Point[], { signal, ...options }?: RequestOptions & {
185
+ mode?: "drive" | "walk" | "bicycle";
186
+ geometries?: "polyline" | "polyline6" | "geojson";
187
+ steps?: boolean;
188
+ lang?: string;
189
+ }) => Promise<Routes>;
181
190
  /** The areas reachable from a location within 1 to 4 times, each 1 to 60 minutes. */
182
191
  isochrone: (location: Point, minutes: number[], { signal, ...options }?: RequestOptions & {
183
192
  mode?: "drive" | "walk" | "bicycle";
package/dist/index.js CHANGED
@@ -44,6 +44,8 @@ export class Mapricot {
44
44
  this.routing = {
45
45
  /** Find a route through 2 to 20 waypoints. */
46
46
  route: (waypoints, { signal, ...options } = {}) => __classPrivateFieldGet(this, _Mapricot_instances, "m", _Mapricot_request).call(this, "POST", "/routing/v1/route", {}, signal, { waypoints, ...options }),
47
+ /** Find a fast route through 2 to 20 waypoints, keeping the first and last in place and reordering the rest. */
48
+ optimize: (waypoints, { signal, ...options } = {}) => __classPrivateFieldGet(this, _Mapricot_instances, "m", _Mapricot_request).call(this, "POST", "/routing/v1/optimize", {}, signal, { waypoints, ...options }),
47
49
  /** The areas reachable from a location within 1 to 4 times, each 1 to 60 minutes. */
48
50
  isochrone: (location, minutes, { signal, ...options } = {}) => __classPrivateFieldGet(this, _Mapricot_instances, "m", _Mapricot_request).call(this, "POST", "/routing/v1/isochrone", {}, signal, { location, minutes, ...options }),
49
51
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mapricot",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "description": "Official client for the Mapricot API: geocoding, places, routing, and IP geolocation.",
5
5
  "keywords": [
6
6
  "geocoding",