mapricot-api 0.6.0 → 0.7.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.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/lib/mapricot/api.rb +6 -4
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 85ceb14ed10d1d3499221e1e2f4378cd3e40c58b4b3274e341004452bc873518
|
|
4
|
+
data.tar.gz: 3a01af9ed6d7431e07255bb635e09d77dd01232c613b9a469da9815d601cd659
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 46a943e94e0f8c2d0d22ddb9d1f7857034b6599fa87633ddbf3d71b982172abf70f096edfbf560b139a0f7a00708d0ef8f5c9a85e2bd97671ec7268c391f8eb1
|
|
7
|
+
data.tar.gz: e5d5becbf5f3de0301f40963ef84317efde3f606ebca3a90050a2c2e98ec23ba3d631e54274f5f3c97fd0aeda837a9a69328bec76c2ff5c872152b1347f98779
|
data/README.md
CHANGED
|
@@ -33,7 +33,7 @@ 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
37
|
| `client.routing.isochrone(location, minutes, mode:)` | [`POST /routing/v1/isochrone`](https://mapricot.com/docs/routing/#get-an-isochrone) |
|
|
38
38
|
| `client.ip_geolocation.lookup(ip)` | [`GET /ip-geolocation/v1/{ip}`](https://mapricot.com/docs/ip-geolocation/#look-up-an-address) |
|
|
39
39
|
| `client.account` | `GET /account`, which checks a key and is never billed |
|
|
@@ -48,6 +48,8 @@ puts route["routes"][0]["durationSeconds"]
|
|
|
48
48
|
|
|
49
49
|
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
50
|
|
|
51
|
+
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
|
+
|
|
51
53
|
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
54
|
|
|
53
55
|
```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.
|
|
10
|
+
VERSION = "0.7.0"
|
|
11
11
|
|
|
12
12
|
# An error response from the API.
|
|
13
13
|
class Error < StandardError
|
|
@@ -148,9 +148,11 @@ 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
|
-
|
|
153
|
-
|
|
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)
|
|
154
156
|
end
|
|
155
157
|
|
|
156
158
|
# The areas reachable from a location, {lat:, lon:}, within 1 to 4 times, each 1 to 60 minutes, as a GeoJSON
|