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.
- checksums.yaml +4 -4
- data/README.md +6 -1
- data/lib/mapricot/api.rb +14 -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: 60ae66ee605316bfe6bf97ce5cdee87b0540c914a687d6d9fa32c94116599d91
|
|
4
|
+
data.tar.gz: a3614aa73d7395d146158da05b9a3dccb955fd656c646411ce1427c4026f294a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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.
|
|
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
|
-
|
|
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)
|
|
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
|