mapricot-api 0.11.0 → 0.13.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 +14 -8
  3. data/lib/mapricot/api.rb +12 -8
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3aa156c2854ba75ee6f5277d91f46bc586e5c1807b47057a253fa7b0b117a930
4
- data.tar.gz: f321e6ebdbcceb3f94ae5b51e8af98da8aa1abc4fac9d05914f7377df6feb63c
3
+ metadata.gz: 3e555ba729e27b2a4b8f31959f110398f56aa56c4194a49c96526d4542bcfa9b
4
+ data.tar.gz: 9c870fcd6884cf91cfc5d0bf3eb4bebf33fc06a03cb0782f5249a7503c3155e6
5
5
  SHA512:
6
- metadata.gz: 25afe81cbda109fc6272517af7b6bf1b3d3b29ec2a6d81eda812830834da030a3c7bbb23e7ef644f63875771b1ff907a97870c56d930a448965ab34195ef3866
7
- data.tar.gz: 73c41d224dc22f7c5c90db74814fb7cb5202110bab0f0abc3610dced8adca8334c430887a28d4a02c279359eaf7a4c617d1baef53982ea5a61b754036dd9331c
6
+ metadata.gz: 77f1c6898440dfa8da979f9ace452144ab8b29b2e79d6e5c310537b81ee5d9abdc344be15f4de3da5ce5a0a95c8b774af64d1d644320c20661cade5b37e45657
7
+ data.tar.gz: 33f7c9d70cc13f80a9e22d2b6170dd8da78b673adea5a0c4056db9ba9385fdcfd9c834cf8e3af9e6d9b1557959454c4eca7fd9887eefd8695159b8f88e674fe1
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Mapricot for Ruby
2
2
 
3
- The official Ruby client for the [Mapricot API](https://mapricot.com/): address and place search, reverse geocoding, nearby places, routing, and IP geolocation, with 250,000 free requests every month.
3
+ The official Ruby client for the [Mapricot API](https://mapricot.com/): address and place search, reverse geocoding, nearby places, routing, and IP geolocation, with 250,000 free requests every 30 days.
4
4
 
5
5
  ```sh
6
6
  gem install mapricot-api
@@ -28,27 +28,33 @@ Methods are grouped by product, the same way as the API's paths. Each returns th
28
28
 
29
29
  | Method | Endpoint |
30
30
  | --- | --- |
31
- | `client.geocoding.search(q, focus:, country:, limit:, lang:)` | [`GET /geocoding/v1/search`](https://mapricot.com/docs/geocoding/#find-an-address) |
31
+ | `client.geocoding.search(q, address:, locality:, county:, region:, postal_code:, focus:, country:, limit:, lang:)` | [`GET /geocoding/v1/search`](https://mapricot.com/docs/geocoding/#find-an-address) |
32
32
  | `client.geocoding.search_batch(queries)` | [`POST /geocoding/v1/search/batch`](https://mapricot.com/docs/geocoding/#search-a-list-of-addresses) |
33
33
  | `client.geocoding.autocomplete(q, focus:, country:, limit:, lang:)` | [`GET /geocoding/v1/autocomplete`](https://mapricot.com/docs/geocoding/#suggest-as-people-type) |
34
- | `client.geocoding.reverse(lat, lon, limit:, lang:)` | [`GET /geocoding/v1/reverse`](https://mapricot.com/docs/geocoding/#find-the-address-at-a-point) |
35
- | `client.places.nearby(lat, lon, category:, radius:, limit:, lang:)` | [`GET /places/v1/nearby`](https://mapricot.com/docs/places/#list-places-around-a-point) |
34
+ | `client.geocoding.reverse(lat:, lon:, limit:, lang:)` | [`GET /geocoding/v1/reverse`](https://mapricot.com/docs/geocoding/#find-the-address-at-a-point) |
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:, costing:)` | [`POST /routing/v1/route`](https://mapricot.com/docs/routing/#get-a-route) |
38
38
  | `client.routing.optimize(waypoints, mode:, geometries:, steps:, lang:, costing:)` | [`POST /routing/v1/optimize`](https://mapricot.com/docs/routing/#optimize-the-order-of-stops) |
39
- | `client.routing.isochrone(location, minutes, mode:, costing:, generalize:)` | [`POST /routing/v1/isochrone`](https://mapricot.com/docs/routing/#get-an-isochrone) |
39
+ | `client.routing.isochrone(location:, minutes:, mode:, costing:, generalize:)` | [`POST /routing/v1/isochrone`](https://mapricot.com/docs/routing/#get-an-isochrone) |
40
40
  | `client.ip_geolocation.lookup(ip)` | [`GET /ip-geolocation/v1/{ip}`](https://mapricot.com/docs/ip-geolocation/#look-up-an-address) |
41
41
  | `client.account` | `GET /account`, which checks a key and is never billed |
42
42
 
43
43
  Every keyword argument is optional. `focus` and each waypoint are `{ lat:, lon: }`. `country` and `category` take an Array or a comma-separated String.
44
44
 
45
45
  ```ruby
46
- nearby = client.places.nearby(45.52, -122.68, category: ["food:coffee_shop"], radius: 1000)
46
+ nearby = client.places.nearby(lat: 45.52, lon: -122.68, category: ["food:coffee_shop"], radius: 1000)
47
47
  route = client.routing.route([{ lat: 45.5189, lon: -122.6793 }, { lat: 45.5214, lon: -122.6828 }], mode: "walk")
48
48
  puts route["routes"][0]["durationSeconds"]
49
49
  ```
50
50
 
51
- `search_batch` runs up to 100 searches in one request. Each query is a Hash of `search`'s parameters, and `"responses"` answers them in the same order, each with `"results"` and `"attribution"`, or an `"error"` with the `"code"` and `"message"` that search would get, without raising. Each completed search is billed as one request; errors aren't.
51
+ When you already have an address in parts, such as a spreadsheet's columns, pass them in place of `q`. Search ignores a blank part:
52
+
53
+ ```ruby
54
+ data = client.geocoding.search(address: "10 Downing Street", locality: "London", postal_code: "SW1A 2AA", country: "GB")
55
+ ```
56
+
57
+ `search_batch` runs up to 100 searches in one request. Each query is a Hash of `search`'s parameters, with `q` or the address parts named as in the API, such as `postalCode`, and `"responses"` answers them in the same order, each with `"results"` and `"attribution"`, or an `"error"` with the `"code"` and `"message"` that search would get, without raising. Each completed search is billed as one request; errors aren't.
52
58
 
53
59
  ```ruby
54
60
  batch = client.geocoding.search_batch([{ q: "128 SW 3rd Ave, Portland", limit: 1 }, { q: "10 Downing Street, London", limit: 1 }])
@@ -66,7 +72,7 @@ Pass `steps: true` and each leg's `steps` has its turn-by-turn directions: an `i
66
72
  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:
67
73
 
68
74
  ```ruby
69
- area = client.routing.isochrone({ lat: 45.5189, lon: -122.6793 }, [5, 10], mode: "walk")
75
+ area = client.routing.isochrone(location: { lat: 45.5189, lon: -122.6793 }, minutes: [5, 10], mode: "walk")
70
76
  puts area["features"].map { |feature| feature["properties"]["minutes"] }.inspect
71
77
  ```
72
78
 
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.11.0"
10
+ VERSION = "0.13.0"
11
11
 
12
12
  # An error response from the API.
13
13
  class Error < StandardError
@@ -110,12 +110,16 @@ module Mapricot
110
110
  @query_value = query_value
111
111
  end
112
112
 
113
- # Find addresses and places matching free text. focus is {lat:, lon:}; country is an Array or a String.
114
- def search(q, focus: nil, country: nil, limit: nil, lang: nil)
115
- @get.call("/geocoding/v1/search", q: q, focus: focus, country: country, limit: limit, lang: lang)
113
+ # Find addresses and places matching free text in q, or an address given in parts in place of q, as in
114
+ # search(address: "10 Downing Street", locality: "London"). focus is {lat:, lon:}; country is an Array or a String.
115
+ def search(q = nil, address: nil, locality: nil, county: nil, region: nil, postal_code: nil, focus: nil, country: nil,
116
+ limit: nil, lang: nil)
117
+ @get.call("/geocoding/v1/search", q: q, address: address, locality: locality, county: county, region: region,
118
+ postalCode: postal_code, focus: focus, country: country, limit: limit, lang: lang)
116
119
  end
117
120
 
118
- # Run up to 100 searches in one request, each a Hash of search's parameters, as in { q: "…", limit: 1 }. Each
121
+ # Run up to 100 searches in one request, each a Hash of search's parameters, as in { q: "…", limit: 1 } or
122
+ # { address: "…", postalCode: "…" }, with the API's names. Each
119
123
  # completed search is billed as one request. "responses" answers them in order, each with "results" and
120
124
  # "attribution", or an "error" with the code and message the search would get on its own, which isn't raised.
121
125
  def search_batch(queries)
@@ -129,7 +133,7 @@ module Mapricot
129
133
  end
130
134
 
131
135
  # Find the address nearest a coordinate, or the area around it.
132
- def reverse(lat, lon, limit: nil, lang: nil)
136
+ def reverse(lat:, lon:, limit: nil, lang: nil)
133
137
  @get.call("/geocoding/v1/reverse", lat: lat, lon: lon, limit: limit, lang: lang)
134
138
  end
135
139
  end
@@ -141,7 +145,7 @@ module Mapricot
141
145
  end
142
146
 
143
147
  # List places around a coordinate, optionally by category, an Array or a String.
144
- def nearby(lat, lon, category: nil, radius: nil, limit: nil, lang: nil)
148
+ def nearby(lat:, lon:, category: nil, radius: nil, limit: nil, lang: nil)
145
149
  @get.call("/places/v1/nearby", lat: lat, lon: lon, category: category, radius: radius, limit: limit, lang: lang)
146
150
  end
147
151
 
@@ -177,7 +181,7 @@ module Mapricot
177
181
  # The areas reachable from a location, {lat:, lon:}, within 1 to 4 times, each 1 to 60 minutes, as a GeoJSON
178
182
  # FeatureCollection with one polygon per time, largest first. mode and costing are as for route. generalize smooths
179
183
  # each outline to within that many meters, from 10 to 5000; left out, the API picks it from the travel time.
180
- def isochrone(location, minutes, mode: nil, costing: nil, generalize: nil)
184
+ def isochrone(location:, minutes:, mode: nil, costing: nil, generalize: nil)
181
185
  @post.call("/routing/v1/isochrone", { location: location, minutes: minutes, mode: mode, costing: costing, generalize: generalize })
182
186
  end
183
187
  end
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.11.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mapricot