mapbox-sdk 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.circleci/config.yml +40 -0
- data/.gitignore +9 -0
- data/CHANGELOG.md +15 -0
- data/Gemfile +1 -1
- data/README.md +14 -4
- data/lib/mapbox.rb +1 -0
- data/lib/mapbox/directions.rb +5 -8
- data/lib/mapbox/geocoder.rb +18 -4
- data/lib/mapbox/tilequery.rb +15 -0
- data/mapbox-sdk.gemspec +2 -3
- data/test/directions_test.rb +1 -1
- data/test/geocoding_test.rb +7 -0
- data/test/tilequery_test.rb +15 -0
- metadata +11 -20
- data/Gemfile.lock +0 -64
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4292d0f1ca115de9e53c9289a9fb375904e2b49faf028b6a90a523ea35d5c0fb
|
4
|
+
data.tar.gz: 9dabda32d362ed87adc887589f73cd5fc8025c2cd69bc3f46647423e684623f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 994336458245a81e414248411bded1b62c03a80cf268bbc1f428d3fefef31b49e60355944dc2c397317cae809cbfde8e39f7dce9aa275c941e49ce92232f9f65
|
7
|
+
data.tar.gz: 040654e4765ff2fc308eef710669fffa48ad0b7b1d15c908150a0a5c29879be9fad18b340c6fc600bfc1b6806cf1eee0f3bf6292d0a378f4ce3637530020e37f
|
@@ -0,0 +1,40 @@
|
|
1
|
+
version: 2
|
2
|
+
jobs:
|
3
|
+
build:
|
4
|
+
working_directory: ~/mapbox/mapbox-sdk-rb
|
5
|
+
parallelism: 1
|
6
|
+
shell: /bin/bash --login
|
7
|
+
environment:
|
8
|
+
CIRCLE_ARTIFACTS: /tmp/circleci-artifacts
|
9
|
+
CIRCLE_TEST_REPORTS: /tmp/circleci-test-results
|
10
|
+
docker:
|
11
|
+
- image: circleci/build-image:ubuntu-14.04-XXL-upstart-1189-5614f37
|
12
|
+
command: /sbin/init
|
13
|
+
steps:
|
14
|
+
- checkout
|
15
|
+
- run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS
|
16
|
+
- restore_cache:
|
17
|
+
keys:
|
18
|
+
- v1-dep-{{ .Branch }}-
|
19
|
+
- v1-dep-master-
|
20
|
+
- v1-dep-
|
21
|
+
- run: echo -e "export RAILS_ENV=test\nexport RACK_ENV=test" >> $BASH_ENV
|
22
|
+
- run: 'bundle check --path=vendor/bundle || bundle install --path=vendor/bundle
|
23
|
+
--jobs=4 --retry=3 '
|
24
|
+
- save_cache:
|
25
|
+
key: v1-dep-{{ .Branch }}-{{ epoch }}
|
26
|
+
paths:
|
27
|
+
- vendor/bundle
|
28
|
+
- ~/virtualenvs
|
29
|
+
- ~/.bundle
|
30
|
+
- run:
|
31
|
+
command: bundle exec rake test
|
32
|
+
environment:
|
33
|
+
RAILS_ENV: test
|
34
|
+
RACK_ENV: test
|
35
|
+
- store_test_results:
|
36
|
+
path: /tmp/circleci-test-results
|
37
|
+
- store_artifacts:
|
38
|
+
path: /tmp/circleci-artifacts
|
39
|
+
- store_artifacts:
|
40
|
+
path: /tmp/circleci-test-results
|
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
5
|
+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## [2.1.0] - 2018-06-07
|
8
|
+
### Added
|
9
|
+
- Added CHANGELOG.md
|
10
|
+
- Added Tilequery endpoint
|
11
|
+
|
12
|
+
### Changed
|
13
|
+
- Updated documentation links in README
|
14
|
+
|
15
|
+
### Removed
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -10,11 +10,12 @@ gem install mapbox-sdk
|
|
10
10
|
|
11
11
|
## Services
|
12
12
|
|
13
|
-
* [Geocoding](https://www.mapbox.com/
|
13
|
+
* [Geocoding](https://www.mapbox.com/api-documentation/#geocoding)
|
14
14
|
* Forward (place names ⇢ longitude, latitude)
|
15
15
|
* Reverse (longitude, latitude ⇢ place names)
|
16
|
-
* [Directions](https://www.mapbox.com/
|
16
|
+
* [Directions](https://www.mapbox.com/api-documentation/#directions)
|
17
17
|
* Profiles for driving, walking, and cycling
|
18
|
+
* [Tilequery](https://www.mapbox.com/api-documentation/#tilequery)
|
18
19
|
|
19
20
|
## Example
|
20
21
|
|
@@ -31,14 +32,23 @@ placenames = Mapbox::Geocoder.geocode_reverse({
|
|
31
32
|
# Forward geocoding with optional proximity parameter
|
32
33
|
places = Mapbox::Geocoder.geocode_forward("Chester, NJ", {:proximity => {:longitude => -74.6968, :latitude => 40.7843}})
|
33
34
|
|
34
|
-
#
|
35
|
+
# Driving directions with required profile parameter
|
35
36
|
drivingDirections = Mapbox::Directions.directions([{
|
36
37
|
"longitude" => -100,
|
37
38
|
"latitude" => 38
|
38
39
|
}, {
|
39
40
|
"longitude" => -90,
|
40
41
|
"latitude" => 38
|
41
|
-
}])
|
42
|
+
}], "driving")
|
43
|
+
|
44
|
+
# In the above example, you can substitute `driving` for `driving-traffic`, `cycling` or `walking`. For more, [check out the documentation](https://www.mapbox.com/api-documentation/#directions).
|
45
|
+
|
46
|
+
# Tilequery
|
47
|
+
tilequery = Mapbox::Tilequery.tilequery(mapid, {location}, radius, limit)
|
48
|
+
|
49
|
+
# Example: tilequery = Mapbox::Tilequery.tilequery("mapbox.mapbox-streets-v7", {"longitude" => -100, "latitude" => 38}, 0, 1)
|
50
|
+
# `Radius` refers to the approximate distance in meters to query for features. Defaults to 0 if left blank. Has no upper bound. Required for queries against point and line data.
|
51
|
+
# `Limit` refers to the number of features between 1 - 50 to return. Defaults to 5 if left blank.
|
42
52
|
```
|
43
53
|
|
44
54
|
Heavily influenced by Stripe's Ruby client, and includes its MIT license.
|
data/lib/mapbox.rb
CHANGED
data/lib/mapbox/directions.rb
CHANGED
@@ -1,16 +1,13 @@
|
|
1
|
-
require 'rest-client'
|
2
|
-
require 'json'
|
3
|
-
|
4
1
|
module Mapbox
|
5
2
|
class Directions
|
6
3
|
include Mapbox::APIOperations::Request
|
7
4
|
extend Mapbox::HashUtils
|
8
|
-
def self.directions(waypoints, profile
|
5
|
+
def self.directions(waypoints, profile)
|
9
6
|
formatted_waypoints = waypoints.map {|p| xy_from_hash(p).join ','}.join ';'
|
10
7
|
return request(
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
:get,
|
9
|
+
"/directions/v5/mapbox/#{profile}/#{formatted_waypoints}.json",
|
10
|
+
nil)
|
14
11
|
end
|
15
12
|
end
|
16
|
-
end
|
13
|
+
end
|
data/lib/mapbox/geocoder.rb
CHANGED
@@ -7,11 +7,12 @@ module Mapbox
|
|
7
7
|
include Mapbox::APIOperations::Request
|
8
8
|
extend Mapbox::HashUtils
|
9
9
|
|
10
|
-
def self.
|
10
|
+
def self.assemble_params(options={})
|
11
11
|
proximity = options[:proximity]
|
12
12
|
bbox = options[:bbox]
|
13
|
+
types = options[:types]
|
13
14
|
params = ''
|
14
|
-
opts = options.select { |key, value| key != :proximity && key != :bbox}
|
15
|
+
opts = options.select { |key, value| key != :proximity && key != :bbox && key != :types}
|
15
16
|
if opts.length > 0
|
16
17
|
params += "#{params.length > 0 ? '&' : '?'}#{URI.encode_www_form(opts)}"
|
17
18
|
end
|
@@ -25,19 +26,32 @@ module Mapbox
|
|
25
26
|
if bbox then
|
26
27
|
params += "#{params.length > 0 ? '&' : '?'}bbox=#{bbox.join('%2C')}"
|
27
28
|
end
|
29
|
+
|
30
|
+
if types then
|
31
|
+
params += "#{params.length > 0 ? '&' : '?'}types=#{types.join('%2C')}"
|
32
|
+
end
|
33
|
+
|
34
|
+
return params
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.geocode_forward(query, options={}, dataset='mapbox.places')
|
38
|
+
params = self.assemble_params(options)
|
39
|
+
|
28
40
|
return request(
|
29
41
|
:get,
|
30
42
|
"/geocoding/v5/#{dataset}/#{URI.escape(query)}.json#{params}",
|
31
43
|
nil)
|
32
44
|
end
|
33
45
|
|
34
|
-
def self.geocode_reverse(location, dataset='mapbox.places')
|
46
|
+
def self.geocode_reverse(location, options={}, dataset='mapbox.places')
|
35
47
|
location[:longitude] = location[:longitude].round(5)
|
36
48
|
location[:latitude] = location[:latitude].round(5)
|
37
49
|
|
50
|
+
params = self.assemble_params(options)
|
51
|
+
|
38
52
|
return request(
|
39
53
|
:get,
|
40
|
-
"/geocoding/v5/#{dataset}/#{xy_from_hash(location).join(',')}.json",
|
54
|
+
"/geocoding/v5/#{dataset}/#{xy_from_hash(location).join(',')}.json#{params}",
|
41
55
|
nil)
|
42
56
|
end
|
43
57
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Mapbox
|
2
|
+
class Tilequery
|
3
|
+
include Mapbox::APIOperations::Request
|
4
|
+
extend Mapbox::HashUtils
|
5
|
+
|
6
|
+
def self.tilequery(mapid, location, radius, limit)
|
7
|
+
lon = location['longitude'].round(5)
|
8
|
+
lat = location['latitude'].round(5)
|
9
|
+
return request(
|
10
|
+
:get,
|
11
|
+
"/v4/#{mapid}/tilequery/#{lon},#{lat}.json?radius=#{radius}&limit=#{limit}",
|
12
|
+
nil)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/mapbox-sdk.gemspec
CHANGED
@@ -2,7 +2,7 @@ $:.unshift(File.join(File.dirname(__FILE__), 'lib'))
|
|
2
2
|
|
3
3
|
spec = Gem::Specification.new do |s|
|
4
4
|
s.name = 'mapbox-sdk'
|
5
|
-
s.version = '2.
|
5
|
+
s.version = '2.1.0'
|
6
6
|
s.summary = 'Ruby bindings for the Mapbox API'
|
7
7
|
s.description = ''
|
8
8
|
s.authors = ['Tom MacWright']
|
@@ -10,8 +10,7 @@ spec = Gem::Specification.new do |s|
|
|
10
10
|
s.homepage = 'https://mapbox.com/developers'
|
11
11
|
s.license = 'MIT'
|
12
12
|
|
13
|
-
s.add_dependency('rest-client', '~> 1
|
14
|
-
s.add_dependency('json', '~> 1.8.1')
|
13
|
+
s.add_dependency('rest-client', '~> 2.0.1')
|
15
14
|
|
16
15
|
s.add_development_dependency('mocha', '~> 0.13.2')
|
17
16
|
s.add_development_dependency('shoulda', '~> 3.4.0')
|
data/test/directions_test.rb
CHANGED
data/test/geocoding_test.rb
CHANGED
@@ -39,6 +39,13 @@ module Mapbox
|
|
39
39
|
assert Mapbox.request_opts[:url].include? '?country=ca';
|
40
40
|
end
|
41
41
|
|
42
|
+
should "#geocode_forward (include types param)" do
|
43
|
+
Mapbox.access_token = ENV["MapboxAccessToken"]
|
44
|
+
result = Mapbox::Geocoder.geocode_forward("Washington", {:types => ['poi.landmark', 'address'], :foo_key => "foo_val", :bar_key => "bar_val"})
|
45
|
+
assert result
|
46
|
+
assert Mapbox.request_opts[:url].include? '?foo_key=foo_val&bar_key=bar_val&types=poi.landmark%2Caddress';
|
47
|
+
end
|
48
|
+
|
42
49
|
should "#geocode_reverse" do
|
43
50
|
Mapbox.access_token = ENV["MapboxAccessToken"]
|
44
51
|
result = Mapbox::Geocoder.geocode_reverse({
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'mapbox'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'mocha/setup'
|
4
|
+
require 'shoulda'
|
5
|
+
|
6
|
+
module Mapbox
|
7
|
+
class TilequeryTest < Test::Unit::TestCase
|
8
|
+
should "#tilequery" do
|
9
|
+
Mapbox.access_token = ENV["MapboxAccessToken"]
|
10
|
+
result = Mapbox::Tilequery.tilequery(
|
11
|
+
"mapbox.mapbox-streets-v7", {"longitude" => -122.42901, "latitude" => 37.80633}, 5, 10)
|
12
|
+
assert result
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mapbox-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom MacWright
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -16,28 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.0.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: json
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 1.8.1
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 1.8.1
|
26
|
+
version: 2.0.1
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: mocha
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -101,8 +87,10 @@ executables: []
|
|
101
87
|
extensions: []
|
102
88
|
extra_rdoc_files: []
|
103
89
|
files:
|
90
|
+
- ".circleci/config.yml"
|
91
|
+
- ".gitignore"
|
92
|
+
- CHANGELOG.md
|
104
93
|
- Gemfile
|
105
|
-
- Gemfile.lock
|
106
94
|
- LICENSE
|
107
95
|
- README.md
|
108
96
|
- Rakefile
|
@@ -112,10 +100,12 @@ files:
|
|
112
100
|
- lib/mapbox/authentication_error.rb
|
113
101
|
- lib/mapbox/directions.rb
|
114
102
|
- lib/mapbox/geocoder.rb
|
103
|
+
- lib/mapbox/tilequery.rb
|
115
104
|
- mapbox-sdk.gemspec
|
116
105
|
- test/directions_test.rb
|
117
106
|
- test/geocoding_test.rb
|
118
107
|
- test/mapbox_test.rb
|
108
|
+
- test/tilequery_test.rb
|
119
109
|
homepage: https://mapbox.com/developers
|
120
110
|
licenses:
|
121
111
|
- MIT
|
@@ -136,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
126
|
version: '0'
|
137
127
|
requirements: []
|
138
128
|
rubyforge_project:
|
139
|
-
rubygems_version: 2.
|
129
|
+
rubygems_version: 2.7.7
|
140
130
|
signing_key:
|
141
131
|
specification_version: 4
|
142
132
|
summary: Ruby bindings for the Mapbox API
|
@@ -144,3 +134,4 @@ test_files:
|
|
144
134
|
- test/directions_test.rb
|
145
135
|
- test/geocoding_test.rb
|
146
136
|
- test/mapbox_test.rb
|
137
|
+
- test/tilequery_test.rb
|
data/Gemfile.lock
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
mapbox (1.0.0)
|
5
|
-
json (~> 1.8.1)
|
6
|
-
rest-client (~> 1.4)
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: https://rubygems.org/
|
10
|
-
specs:
|
11
|
-
activesupport (4.2.3)
|
12
|
-
i18n (~> 0.7)
|
13
|
-
json (~> 1.7, >= 1.7.7)
|
14
|
-
minitest (~> 5.1)
|
15
|
-
thread_safe (~> 0.3, >= 0.3.4)
|
16
|
-
tzinfo (~> 1.1)
|
17
|
-
bourne (1.5.0)
|
18
|
-
mocha (>= 0.13.2, < 0.15)
|
19
|
-
domain_name (0.5.24)
|
20
|
-
unf (>= 0.0.5, < 1.0.0)
|
21
|
-
http-cookie (1.0.2)
|
22
|
-
domain_name (~> 0.5)
|
23
|
-
i18n (0.7.0)
|
24
|
-
json (1.8.3)
|
25
|
-
metaclass (0.0.4)
|
26
|
-
mime-types (2.6.1)
|
27
|
-
minitest (5.7.0)
|
28
|
-
mocha (0.13.3)
|
29
|
-
metaclass (~> 0.0.1)
|
30
|
-
netrc (0.10.3)
|
31
|
-
power_assert (0.2.4)
|
32
|
-
rake (10.4.2)
|
33
|
-
rest-client (1.8.0)
|
34
|
-
http-cookie (>= 1.0.2, < 2.0)
|
35
|
-
mime-types (>= 1.16, < 3.0)
|
36
|
-
netrc (~> 0.7)
|
37
|
-
shoulda (3.4.0)
|
38
|
-
shoulda-context (~> 1.0, >= 1.0.1)
|
39
|
-
shoulda-matchers (~> 1.0, >= 1.4.1)
|
40
|
-
shoulda-context (1.2.1)
|
41
|
-
shoulda-matchers (1.5.6)
|
42
|
-
activesupport (>= 3.0.0)
|
43
|
-
bourne (~> 1.3)
|
44
|
-
test-unit (3.1.2)
|
45
|
-
power_assert
|
46
|
-
thread_safe (0.3.5)
|
47
|
-
tzinfo (1.2.2)
|
48
|
-
thread_safe (~> 0.1)
|
49
|
-
unf (0.1.4)
|
50
|
-
unf_ext
|
51
|
-
unf_ext (0.0.7.1)
|
52
|
-
|
53
|
-
PLATFORMS
|
54
|
-
ruby
|
55
|
-
|
56
|
-
DEPENDENCIES
|
57
|
-
mapbox!
|
58
|
-
mocha (~> 0.13.2)
|
59
|
-
rake
|
60
|
-
shoulda (~> 3.4.0)
|
61
|
-
test-unit
|
62
|
-
|
63
|
-
BUNDLED WITH
|
64
|
-
1.10.6
|