mapricot-api 0.7.0 → 0.8.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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -0
  3. data/lib/mapricot/api.rb +9 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 85ceb14ed10d1d3499221e1e2f4378cd3e40c58b4b3274e341004452bc873518
4
- data.tar.gz: 3a01af9ed6d7431e07255bb635e09d77dd01232c613b9a469da9815d601cd659
3
+ metadata.gz: 60ae66ee605316bfe6bf97ce5cdee87b0540c914a687d6d9fa32c94116599d91
4
+ data.tar.gz: a3614aa73d7395d146158da05b9a3dccb955fd656c646411ce1427c4026f294a
5
5
  SHA512:
6
- metadata.gz: 46a943e94e0f8c2d0d22ddb9d1f7857034b6599fa87633ddbf3d71b982172abf70f096edfbf560b139a0f7a00708d0ef8f5c9a85e2bd97671ec7268c391f8eb1
7
- data.tar.gz: e5d5becbf5f3de0301f40963ef84317efde3f606ebca3a90050a2c2e98ec23ba3d631e54274f5f3c97fd0aeda837a9a69328bec76c2ff5c872152b1347f98779
6
+ metadata.gz: 156e3cfd96b2ed32b0fa917d973852cf7df03421ad49b96d89fd4c5ff66dd6bbe3a601a9cfdd6ba95af616e48360ae0ef63127f4402ca1a94cfe22b21558e295
7
+ data.tar.gz: 0df9af5005e818d9ef4553fb6b11ada8d1e04d8de040682c2ede03f3ef3990983112e0161affee1d0a8cf4aa8f0d3e84bcd4bf0551bd8ec07d1a333f21c7ee8d
data/README.md CHANGED
@@ -34,6 +34,7 @@ Methods are grouped by product, the same way as the API's paths. Each returns th
34
34
  | `client.places.nearby(lat, lon, category:, radius:, limit:, lang:)` | [`GET /places/v1/nearby`](https://mapricot.com/docs/places/#list-places-around-a-point) |
35
35
  | `client.places.get(id, lang:)` | [`GET /places/v1/{id}`](https://mapricot.com/docs/places/#look-up-a-saved-place) |
36
36
  | `client.routing.route(waypoints, mode:, geometries:, steps:, lang:)` | [`POST /routing/v1/route`](https://mapricot.com/docs/routing/#get-a-route) |
37
+ | `client.routing.optimize(waypoints, mode:, geometries:, steps:, lang:)` | [`POST /routing/v1/optimize`](https://mapricot.com/docs/routing/#optimize-the-order-of-stops) |
37
38
  | `client.routing.isochrone(location, minutes, mode:)` | [`POST /routing/v1/isochrone`](https://mapricot.com/docs/routing/#get-an-isochrone) |
38
39
  | `client.ip_geolocation.lookup(ip)` | [`GET /ip-geolocation/v1/{ip}`](https://mapricot.com/docs/ip-geolocation/#look-up-an-address) |
39
40
  | `client.account` | `GET /account`, which checks a key and is never billed |
@@ -50,6 +51,8 @@ A route's path comes as an encoded `polyline` with five decimal places, which po
50
51
 
51
52
  Pass `steps: true` and each leg's `steps` has its turn-by-turn directions: an `instruction`, its distance and time, and its `lat` and `lon`. They're in English unless you pass `lang`, such as `lang: "fr"`.
52
53
 
54
+ `routing.optimize` takes the same arguments 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`.
55
+
53
56
  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:
54
57
 
55
58
  ```ruby
data/lib/mapricot/api.rb CHANGED
@@ -7,7 +7,7 @@ require "net/http"
7
7
  # The official client for the Mapricot API: address and place search, reverse geocoding, nearby places, routing,
8
8
  # and IP geolocation. See https://mapricot.com/docs/ruby/.
9
9
  module Mapricot
10
- VERSION = "0.7.0"
10
+ VERSION = "0.8.0"
11
11
 
12
12
  # An error response from the API.
13
13
  class Error < StandardError
@@ -155,6 +155,14 @@ module Mapricot
155
155
  @post.call("/routing/v1/route", body)
156
156
  end
157
157
 
158
+ # Find a fast route through 2 to 20 waypoints, keeping the first and last in place and reordering the rest. It
159
+ # takes the same arguments as route, and the route adds "waypointOrder": the indexes of the waypoints sent, in
160
+ # visiting order.
161
+ def optimize(waypoints, mode: nil, geometries: nil, steps: nil, lang: nil)
162
+ body = { waypoints: waypoints, mode: mode, geometries: geometries, steps: steps, lang: lang }
163
+ @post.call("/routing/v1/optimize", body)
164
+ end
165
+
158
166
  # The areas reachable from a location, {lat:, lon:}, within 1 to 4 times, each 1 to 60 minutes, as a GeoJSON
159
167
  # FeatureCollection with one polygon per time, largest first. mode is as for route.
160
168
  def isochrone(location, minutes, mode: nil)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mapricot-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mapricot