mapricot-api 0.6.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 +6 -1
  3. data/lib/mapricot/api.rb +14 -4
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ca2609b68cb960b86372cdb41ecb1ad1f0880e0eabdd7995b605e49f64cdb8e3
4
- data.tar.gz: 9037e3ac81b3e91f9389bc586f3dc1430a076cc6385347f3bb04615830745898
3
+ metadata.gz: 60ae66ee605316bfe6bf97ce5cdee87b0540c914a687d6d9fa32c94116599d91
4
+ data.tar.gz: a3614aa73d7395d146158da05b9a3dccb955fd656c646411ce1427c4026f294a
5
5
  SHA512:
6
- metadata.gz: c6845a3ae2301ab0368d2d943b891942127064b8b99565fbd4f16dfba3f2e2b5e95fc67e13312b538813107d0bf680035a66d061dc99c44066f220cc35de9b4e
7
- data.tar.gz: 9c6dc48367361ab545b4c74c684da88d9886207f9e17ec5a61e1c9115dc801cf1129389f3f9d7425d4f51a3e72f97b47ff936c57a5006ef4d47fa34ffd4ef9fe
6
+ metadata.gz: 156e3cfd96b2ed32b0fa917d973852cf7df03421ad49b96d89fd4c5ff66dd6bbe3a601a9cfdd6ba95af616e48360ae0ef63127f4402ca1a94cfe22b21558e295
7
+ data.tar.gz: 0df9af5005e818d9ef4553fb6b11ada8d1e04d8de040682c2ede03f3ef3990983112e0161affee1d0a8cf4aa8f0d3e84bcd4bf0551bd8ec07d1a333f21c7ee8d
data/README.md CHANGED
@@ -33,7 +33,8 @@ Methods are grouped by product, the same way as the API's paths. Each returns th
33
33
  | `client.geocoding.reverse(lat, lon, limit:, lang:)` | [`GET /geocoding/v1/reverse`](https://mapricot.com/docs/geocoding/#find-the-address-at-a-point) |
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
- | `client.routing.route(waypoints, mode:, geometries:)` | [`POST /routing/v1/route`](https://mapricot.com/docs/routing/#get-a-route) |
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 |
@@ -48,6 +49,10 @@ puts route["routes"][0]["durationSeconds"]
48
49
 
49
50
  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.
50
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"`.
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
+
51
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:
52
57
 
53
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.6.0"
10
+ VERSION = "0.8.0"
11
11
 
12
12
  # An error response from the API.
13
13
  class Error < StandardError
@@ -148,9 +148,19 @@ module Mapricot
148
148
  end
149
149
 
150
150
  # Find a route through 2 to 20 waypoints, each {lat:, lon:}. mode is "drive" (the default), "walk", or "bicycle".
151
- # geometries is "polyline" (the default), "polyline6", or "geojson".
152
- def route(waypoints, mode: nil, geometries: nil)
153
- @post.call("/routing/v1/route", { waypoints: waypoints, mode: mode, geometries: geometries })
151
+ # geometries is "polyline" (the default), "polyline6", or "geojson". steps: true adds each leg's turn-by-turn
152
+ # steps, in lang, an ISO 639-1 language, English by default.
153
+ def route(waypoints, mode: nil, geometries: nil, steps: nil, lang: nil)
154
+ body = { waypoints: waypoints, mode: mode, geometries: geometries, steps: steps, lang: lang }
155
+ @post.call("/routing/v1/route", body)
156
+ end
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)
154
164
  end
155
165
 
156
166
  # The areas reachable from a location, {lat:, lon:}, within 1 to 4 times, each 1 to 60 minutes, as a GeoJSON
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.6.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mapricot