mapbox-sdk 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -1
- data/README.md +11 -5
- data/docs/directions.md +4 -4
- data/docs/mapmatching.md +43 -0
- data/docs/matrix.md +38 -0
- data/docs/optimization.md +52 -0
- data/lib/mapbox.rb +4 -1
- data/lib/mapbox/map_matching.rb +57 -0
- data/lib/mapbox/matrix.rb +32 -0
- data/lib/mapbox/optimization.rb +47 -0
- data/mapbox-sdk.gemspec +1 -1
- data/test/map_matching_test.rb +46 -0
- data/test/matrix_test.rb +40 -0
- data/test/optimization_test.rb +56 -0
- metadata +15 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e37005101fa7cc0a72f5711254531e13574ddd14d470a8e115b278e62c4297f3
|
4
|
+
data.tar.gz: ff3a2679ed83dc2df5f1fba7474d59cf0489adaa6b303f0f45072a579f2714d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e0d69f2d9f8920ef0ab08505156e1498dd579df3cedfc706444065d9d1ead993dab7abf9ab5451c5c22e0c0078e1a701f2f3eb5cb3a7dd29ee01ffb264f25d6
|
7
|
+
data.tar.gz: 1b7b0370797210b16210060bbc92c52a9fa14add842fc2d4b7adb57e66aa0f951143012508084cde4ecc6d6c5e6fa91d53b2f8735c0a24b9a05849de9eb179e8
|
data/CHANGELOG.md
CHANGED
@@ -4,7 +4,17 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
-
## [2.
|
7
|
+
## [2.3.0] - 2019-01-16
|
8
|
+
### Added
|
9
|
+
- Matrix endpoint, docs, and tests
|
10
|
+
- Map Matching endpoint, docs, and tests
|
11
|
+
- Optimization endpoint, docs, and tests
|
12
|
+
|
13
|
+
### Changed
|
14
|
+
|
15
|
+
### Removed
|
16
|
+
|
17
|
+
## [2.2.0] - 2018-12-14
|
8
18
|
### Added
|
9
19
|
- Selection of directions profiles
|
10
20
|
- Isochrone endpoint
|
data/README.md
CHANGED
@@ -12,14 +12,20 @@ gem install mapbox-sdk
|
|
12
12
|
|
13
13
|
## Services
|
14
14
|
|
15
|
-
* [Geocoding](https://
|
15
|
+
* [Geocoding](https://docs.mapbox.com/api/search/) [[docs](https://github.com/mapbox/mapbox-sdk-rb/blob/master/docs/geocoding.md)]
|
16
16
|
* Forward (place names ⇢ longitude, latitude)
|
17
17
|
* Reverse (longitude, latitude ⇢ place names)
|
18
|
-
* [Directions](https://
|
19
|
-
* Profiles for driving, walking, and cycling
|
20
|
-
* [Tilequery](https://
|
21
|
-
* [Isochrone](https://
|
18
|
+
* [Directions](https://docs.mapbox.com/api/navigation/#directions): [[docs](https://github.com/mapbox/mapbox-sdk-rb/blob/master/docs/directions.md)]
|
19
|
+
* Profiles for driving, driving-traffic, walking, and cycling
|
20
|
+
* [Tilequery](https://docs.mapbox.com/api/maps/#tilequery): [[docs](https://github.com/mapbox/mapbox-sdk-rb/blob/master/docs/tilequery.md)]
|
21
|
+
* [Isochrone](https://docs.mapbox.com/api/navigation/#isochrone): [[docs](https://github.com/mapbox/mapbox-sdk-rb/blob/master/docs/isochrone.md)]
|
22
22
|
* Profiles for driving, walking, and cycling
|
23
|
+
* [Matrix](https://docs.mapbox.com/api/navigation/#matrix): [[docs](https://github.com/mapbox/mapbox-sdk-rb/blob/master/docs/matrix.md)]
|
24
|
+
* Profiles for driving, driving-traffic, walking, and cycling
|
25
|
+
* [Map Matching](https://docs.mapbox.com/api/navigation/#map-matching): [[docs](https://github.com/mapbox/mapbox-sdk-rb/blob/master/docs/mapmatching.md)]
|
26
|
+
* Profiles for driving, driving-traffic, walking, and cycling
|
27
|
+
* [Optimization](https://docs.mapbox.com/api/navigation/#optimization): [[docs](https://github.com/mapbox/mapbox-sdk-rb/blob/master/docs/optimization.md)]
|
28
|
+
* Profiles for driving, driving-traffic, walking, and cycling
|
23
29
|
|
24
30
|
## Testing
|
25
31
|
|
data/docs/directions.md
CHANGED
@@ -13,7 +13,7 @@ drivingDirections = Mapbox::Directions.directions([{
|
|
13
13
|
"latitude" => 38
|
14
14
|
}], "driving")
|
15
15
|
|
16
|
-
# To provide query parameters to the Directions API, such as `geometries`, `language` or `steps`, add those in a Hash as third parameter (find the full list of parameters (here)[https://www.mapbox.com/api-documentation/#retrieve-directions]).
|
16
|
+
# To provide query parameters to the Directions API, such as `geometries`, `language` or `steps`, add those in a Hash as third parameter (find the full list of parameters (here)[https://www.mapbox.com/api-documentation/navigation/#retrieve-directions]).
|
17
17
|
|
18
18
|
# For instance, to use the `geometries` and `voice_instructions` parameter:
|
19
19
|
drivingDirections = Mapbox::Directions.directions([{
|
@@ -26,6 +26,6 @@ drivingDirections = Mapbox::Directions.directions([{
|
|
26
26
|
geometries: "geojson",
|
27
27
|
voice_instructions: true
|
28
28
|
})
|
29
|
-
|
30
|
-
# 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).
|
31
|
-
```
|
29
|
+
|
30
|
+
# 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/navigation/#directions).
|
31
|
+
```
|
data/docs/mapmatching.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Map Matching
|
2
|
+
|
3
|
+
```rb
|
4
|
+
require "mapbox-sdk"
|
5
|
+
Mapbox.access_token = "YOUR_ACCESS_TOKEN"
|
6
|
+
|
7
|
+
# Snap fuzzy, inaccurate GPS or phone traces to the road and path network with required profile parameter.
|
8
|
+
matching = Mapbox::MapMatching.map_matching([{
|
9
|
+
"longitude" => -117.17282,
|
10
|
+
"latitude" => 32.71204
|
11
|
+
}, {
|
12
|
+
"longitude" => -117.17288,
|
13
|
+
"latitude" => 32.71225
|
14
|
+
}, {
|
15
|
+
"longitude" => -117.17293,
|
16
|
+
"latitude" => 32.71244
|
17
|
+
},{
|
18
|
+
"longitude" => -117.17292,
|
19
|
+
"latitude" => 32.71256
|
20
|
+
}], "driving")
|
21
|
+
|
22
|
+
# To provide query parameters to the Matrix API, such as `annotations`, `approaches` or `sources`, add those in a Hash as third parameter (find the full list of parameters (here)[https://www.mapbox.com/api-documentation/navigation/#matrix]).
|
23
|
+
|
24
|
+
# For instance, to use the `geometries` and `voice_instructions` parameter:
|
25
|
+
matching = Mapbox::MapMatching.map_matching([{
|
26
|
+
"longitude" => -117.17282,
|
27
|
+
"latitude" => 32.71204
|
28
|
+
}, {
|
29
|
+
"longitude" => -117.17288,
|
30
|
+
"latitude" => 32.71225
|
31
|
+
}, {
|
32
|
+
"longitude" => -117.17293,
|
33
|
+
"latitude" => 32.71244
|
34
|
+
},{
|
35
|
+
"longitude" => -117.17292,
|
36
|
+
"latitude" => 32.71256
|
37
|
+
}], "driving", {
|
38
|
+
annotations: ["duration", "distance", "speed"],
|
39
|
+
approaches: ["curb","curb","curb","curb"]
|
40
|
+
})
|
41
|
+
|
42
|
+
# In the above example, you can substitute `driving` for `driving-traffic`, `cycling` or `walking`. For more, [check out the documentation](https://docs.mapbox.com/api/navigation/#map-matching).
|
43
|
+
```
|
data/docs/matrix.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# Matrix
|
2
|
+
|
3
|
+
```rb
|
4
|
+
require "mapbox-sdk"
|
5
|
+
Mapbox.access_token = "YOUR_ACCESS_TOKEN"
|
6
|
+
|
7
|
+
# Return travel times between many points, passing in the required profile parameter.
|
8
|
+
matrix = Mapbox::Matrix.matrix([{
|
9
|
+
"longitude" => -122.42,
|
10
|
+
"latitude" => 37.78
|
11
|
+
}, {
|
12
|
+
"longitude" => -122.45,
|
13
|
+
"latitude" => 37.91
|
14
|
+
}, {
|
15
|
+
"longitude" => -122.48,
|
16
|
+
"latitude" => 37.73
|
17
|
+
}], "walking")
|
18
|
+
|
19
|
+
# To provide query parameters to the Matrix API, such as `annotations`, `approaches` or `sources`, add those in a Hash as third parameter (find the full list of parameters (here)[https://www.mapbox.com/api-documentation/navigation/#matrix]).
|
20
|
+
|
21
|
+
# For instance, to use the `annotations`, `approaches`, and `destinations` parameters:
|
22
|
+
matrix = Mapbox::Matrix.matrix([{
|
23
|
+
"longitude" => -122.42,
|
24
|
+
"latitude" => 37.78
|
25
|
+
}, {
|
26
|
+
"longitude" => -122.45,
|
27
|
+
"latitude" => 37.91
|
28
|
+
}, {
|
29
|
+
"longitude" => -122.48,
|
30
|
+
"latitude" => 37.73
|
31
|
+
}], "cycling", {
|
32
|
+
annotations: ["duration", "distance"],
|
33
|
+
approaches: ["curb","","curb"],
|
34
|
+
destinations: [0,1]
|
35
|
+
})
|
36
|
+
|
37
|
+
# 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/navigation/#matrix).
|
38
|
+
```
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# Optimization
|
2
|
+
|
3
|
+
```rb
|
4
|
+
require "mapbox-sdk"
|
5
|
+
Mapbox.access_token = "YOUR_ACCESS_TOKEN"
|
6
|
+
|
7
|
+
# Returns a duration-optimized route between coordinates with required profile parameter.
|
8
|
+
optimization = Mapbox::Optimization.optimization([{
|
9
|
+
"longitude" => -122.42,
|
10
|
+
"latitude" => 37.78
|
11
|
+
}, {
|
12
|
+
"longitude" => -122.45,
|
13
|
+
"latitude" => 37.91
|
14
|
+
}, {
|
15
|
+
"longitude" => -122.48,
|
16
|
+
"latitude" => 37.73
|
17
|
+
}], "walking")
|
18
|
+
|
19
|
+
# To provide query parameters to the Matrix API, such as `annotations`, `approaches` or `sources`, add those in a Hash as third parameter (find the full list of parameters (here)[https://www.mapbox.com/api-documentation/navigation/#matrix]).
|
20
|
+
|
21
|
+
# For instance, to use the `annotations`, `approaches`, and `overview` parameters:
|
22
|
+
optimization = Mapbox::Optimization.optimization([{
|
23
|
+
"longitude" => -122.42,
|
24
|
+
"latitude" => 37.78
|
25
|
+
}, {
|
26
|
+
"longitude" => -122.45,
|
27
|
+
"latitude" => 37.91
|
28
|
+
}, {
|
29
|
+
"longitude" => -122.48,
|
30
|
+
"latitude" => 37.73
|
31
|
+
}], "cycling", {
|
32
|
+
annotations: ["duration", "distance"],
|
33
|
+
approaches: ["curb","curb","curb"],
|
34
|
+
overview: "false"
|
35
|
+
})
|
36
|
+
|
37
|
+
# The bearings param works a bit differently. Here's an example, leaving the second bearing blank with an additional `;` character (you must include the same number of bearings as waypoints, per the docs):
|
38
|
+
optimization = Mapbox::Optimization.optimization([{
|
39
|
+
"longitude" => -122.42,
|
40
|
+
"latitude" => 37.78
|
41
|
+
}, {
|
42
|
+
"longitude" => -122.45,
|
43
|
+
"latitude" => 37.91
|
44
|
+
}, {
|
45
|
+
"longitude" => -122.48,
|
46
|
+
"latitude" => 37.73
|
47
|
+
}], "driving", {
|
48
|
+
bearings: "45,90;;90,1"
|
49
|
+
})
|
50
|
+
|
51
|
+
# In the above example, you can substitute `driving` for `driving-traffic`, `cycling` or `walking`. For more, [check out the documentation](https://docs.mapbox.com/api/navigation/#optimization).
|
52
|
+
```
|
data/lib/mapbox.rb
CHANGED
@@ -0,0 +1,57 @@
|
|
1
|
+
module Mapbox
|
2
|
+
class MapMatching
|
3
|
+
include Mapbox::APIOperations::Request
|
4
|
+
extend Mapbox::HashUtils
|
5
|
+
|
6
|
+
def self.assemble_params(options={})
|
7
|
+
annotations = options[:annotations]
|
8
|
+
approaches = options[:approaches]
|
9
|
+
radiuses = options[:radiuses]
|
10
|
+
timestamps = options[:timestamps]
|
11
|
+
waypoint_names = options[:waypoint_names]
|
12
|
+
waypoints = options[:waypoints]
|
13
|
+
|
14
|
+
params = ''
|
15
|
+
opts = options.select { |key, value| key != :annotations && key != :approaches && key != :radiuses && key != :timestamps && key != :waypoint_names && key != :waypoints }
|
16
|
+
if opts.length > 0
|
17
|
+
params += "#{params.length > 0 ? '&' : '?'}#{URI.encode_www_form(opts)}"
|
18
|
+
end
|
19
|
+
|
20
|
+
if annotations then
|
21
|
+
params += "#{params.length > 0 ? '&' : '?'}annotations=#{annotations.join(',')}"
|
22
|
+
end
|
23
|
+
|
24
|
+
if approaches then
|
25
|
+
params += "#{params.length > 0 ? '&' : '?'}approaches=#{approaches.join(';')}"
|
26
|
+
end
|
27
|
+
|
28
|
+
if radiuses then
|
29
|
+
params += "#{params.length > 0 ? '&' : '?'}radiuses=#{radiuses.join ';'}"
|
30
|
+
end
|
31
|
+
|
32
|
+
if timestamps then
|
33
|
+
params += "#{params.length > 0 ? '&' : '?'}timestamps=#{timestamps.join ';'}"
|
34
|
+
end
|
35
|
+
|
36
|
+
if waypoint_names then
|
37
|
+
params += "#{params.length > 0 ? '&' : '?'}waypoint_names=#{waypoint_names.join ';'}"
|
38
|
+
end
|
39
|
+
|
40
|
+
if waypoints then
|
41
|
+
params += "#{params.length > 0 ? '&' : '?'}waypoints=#{waypoints.join ';'}"
|
42
|
+
end
|
43
|
+
|
44
|
+
return params
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.map_matching(waypoints, profile, options={})
|
48
|
+
formatted_waypoints = waypoints.map {|p| xy_from_hash(p).join ','}.join ';'
|
49
|
+
params = self.assemble_params(options)
|
50
|
+
|
51
|
+
return request(
|
52
|
+
:get,
|
53
|
+
"/matching/v5/mapbox/#{profile}/#{formatted_waypoints}.json#{params}",
|
54
|
+
nil)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Mapbox
|
2
|
+
class Matrix
|
3
|
+
include Mapbox::APIOperations::Request
|
4
|
+
extend Mapbox::HashUtils
|
5
|
+
|
6
|
+
def self.assemble_params(options={})
|
7
|
+
opts = options.dup
|
8
|
+
|
9
|
+
self.joinArrayParam(opts, :destinations)
|
10
|
+
self.joinArrayParam(opts, :annotations, ',')
|
11
|
+
self.joinArrayParam(opts, :approaches)
|
12
|
+
self.joinArrayParam(opts, :sources)
|
13
|
+
|
14
|
+
return "?#{URI.encode_www_form(opts)}"
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.joinArrayParam(opts, name, joinSymbol = ';')
|
18
|
+
if opts[name].kind_of?(Array)
|
19
|
+
opts[name] = opts[name].join(joinSymbol)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.matrix(waypoints, profile, options={})
|
24
|
+
formatted_waypoints = waypoints.map {|p| xy_from_hash(p).join ','}.join ';'
|
25
|
+
params = self.assemble_params(options)
|
26
|
+
return request(
|
27
|
+
:get,
|
28
|
+
"/directions-matrix/v1/mapbox/#{profile}/#{formatted_waypoints}.json#{params}",
|
29
|
+
nil)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Mapbox
|
2
|
+
class Optimization
|
3
|
+
include Mapbox::APIOperations::Request
|
4
|
+
extend Mapbox::HashUtils
|
5
|
+
|
6
|
+
def self.assemble_params(options={})
|
7
|
+
annotations = options[:annotations]
|
8
|
+
approaches = options[:approaches]
|
9
|
+
distributions = options[:distributions]
|
10
|
+
radiuses = options[:radiuses]
|
11
|
+
|
12
|
+
params = ''
|
13
|
+
opts = options.select { |key, value| key != :annotations && key != :approaches && key != :distributions && key != :radiuses }
|
14
|
+
if opts.length > 0
|
15
|
+
params += "#{params.length > 0 ? '&' : '?'}#{URI.encode_www_form(opts)}"
|
16
|
+
end
|
17
|
+
|
18
|
+
if annotations then
|
19
|
+
params += "#{params.length > 0 ? '&' : '?'}annotations=#{annotations.join(',')}"
|
20
|
+
end
|
21
|
+
|
22
|
+
if approaches then
|
23
|
+
params += "#{params.length > 0 ? '&' : '?'}approaches=#{approaches.join(';')}"
|
24
|
+
end
|
25
|
+
|
26
|
+
if distributions then
|
27
|
+
params += "#{params.length > 0 ? '&' : '?'}distributions=#{distributions.join(';')}"
|
28
|
+
end
|
29
|
+
|
30
|
+
if radiuses then
|
31
|
+
params += "#{params.length > 0 ? '&' : '?'}radiuses=#{radiuses.join(';')}"
|
32
|
+
end
|
33
|
+
|
34
|
+
return params
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.optimization(waypoints, profile, options={})
|
38
|
+
formatted_waypoints = waypoints.map {|p| xy_from_hash(p).join ','}.join ';'
|
39
|
+
params = self.assemble_params(options)
|
40
|
+
|
41
|
+
return request(
|
42
|
+
:get,
|
43
|
+
"/optimized-trips/v1/mapbox/#{profile}/#{formatted_waypoints}.json#{params}",
|
44
|
+
nil)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/mapbox-sdk.gemspec
CHANGED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'mapbox'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'mocha/setup'
|
4
|
+
require 'shoulda'
|
5
|
+
|
6
|
+
module Mapbox
|
7
|
+
class MapMatchingTest < Test::Unit::TestCase
|
8
|
+
should "#map match with just coordinates and profile" do
|
9
|
+
Mapbox.access_token = ENV["MapboxAccessToken"]
|
10
|
+
result = Mapbox::MapMatching.map_matching([{
|
11
|
+
"longitude" => -117.17282,
|
12
|
+
"latitude" => 32.71204
|
13
|
+
}, {
|
14
|
+
"longitude" => -117.17288,
|
15
|
+
"latitude" => 32.71225
|
16
|
+
}, {
|
17
|
+
"longitude" => -117.17293,
|
18
|
+
"latitude" => 32.71244
|
19
|
+
},{
|
20
|
+
"longitude" => -117.17292,
|
21
|
+
"latitude" => 32.71256
|
22
|
+
}], "driving")
|
23
|
+
assert result
|
24
|
+
end
|
25
|
+
should "#map match with optional params" do
|
26
|
+
Mapbox.access_token = ENV["MapboxAccessToken"]
|
27
|
+
result = Mapbox::MapMatching.map_matching([{
|
28
|
+
"longitude" => -117.17282,
|
29
|
+
"latitude" => 32.71204
|
30
|
+
}, {
|
31
|
+
"longitude" => -117.17288,
|
32
|
+
"latitude" => 32.71225
|
33
|
+
}, {
|
34
|
+
"longitude" => -117.17293,
|
35
|
+
"latitude" => 32.71244
|
36
|
+
}, {
|
37
|
+
"longitude" => -117.17292,
|
38
|
+
"latitude" => 32.71256
|
39
|
+
}], "driving", {
|
40
|
+
annotations: ["duration", "distance", "speed"],
|
41
|
+
approaches: ["curb","curb","curb","curb"]
|
42
|
+
})
|
43
|
+
assert result
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/test/matrix_test.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'mapbox'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'mocha/setup'
|
4
|
+
require 'shoulda'
|
5
|
+
|
6
|
+
module Mapbox
|
7
|
+
class MatrixTest < Test::Unit::TestCase
|
8
|
+
should "#matrix with just coordinates and profile" do
|
9
|
+
Mapbox.access_token = ENV["MapboxAccessToken"]
|
10
|
+
result = Mapbox::Matrix.matrix([{
|
11
|
+
"longitude" => -122.42,
|
12
|
+
"latitude" => 37.78
|
13
|
+
}, {
|
14
|
+
"longitude" => -122.45,
|
15
|
+
"latitude" => 37.91
|
16
|
+
}, {
|
17
|
+
"longitude" => -122.48,
|
18
|
+
"latitude" => 37.73
|
19
|
+
}], "driving")
|
20
|
+
assert result
|
21
|
+
end
|
22
|
+
should "#matrix with optional params" do
|
23
|
+
Mapbox.access_token = ENV["MapboxAccessToken"]
|
24
|
+
result = Mapbox::Matrix.matrix([{
|
25
|
+
"longitude" => -122.42,
|
26
|
+
"latitude" => 37.78
|
27
|
+
}, {
|
28
|
+
"longitude" => -122.45,
|
29
|
+
"latitude" => 37.91
|
30
|
+
}, {
|
31
|
+
"longitude" => -122.48,
|
32
|
+
"latitude" => 37.73
|
33
|
+
}], "cycling", {
|
34
|
+
annotations: ["duration", "distance"],
|
35
|
+
approaches: ["curb","curb","curb"]
|
36
|
+
})
|
37
|
+
assert result
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'mapbox'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'mocha/setup'
|
4
|
+
require 'shoulda'
|
5
|
+
|
6
|
+
module Mapbox
|
7
|
+
class MatrixTest < Test::Unit::TestCase
|
8
|
+
should "#optimization with just coordinates and profile" do
|
9
|
+
Mapbox.access_token = ENV["MapboxAccessToken"]
|
10
|
+
result = Mapbox::Optimization.optimization([{
|
11
|
+
"longitude" => -122.42,
|
12
|
+
"latitude" => 37.78
|
13
|
+
}, {
|
14
|
+
"longitude" => -122.45,
|
15
|
+
"latitude" => 37.91
|
16
|
+
}, {
|
17
|
+
"longitude" => -122.48,
|
18
|
+
"latitude" => 37.73
|
19
|
+
}], "walking")
|
20
|
+
assert result
|
21
|
+
end
|
22
|
+
should "#optimization with optional params" do
|
23
|
+
Mapbox.access_token = ENV["MapboxAccessToken"]
|
24
|
+
result = Mapbox::Optimization.optimization([{
|
25
|
+
"longitude" => -122.42,
|
26
|
+
"latitude" => 37.78
|
27
|
+
}, {
|
28
|
+
"longitude" => -122.45,
|
29
|
+
"latitude" => 37.91
|
30
|
+
}, {
|
31
|
+
"longitude" => -122.48,
|
32
|
+
"latitude" => 37.73
|
33
|
+
}], "cycling", {
|
34
|
+
annotations: ["duration", "distance"],
|
35
|
+
approaches: ["curb","curb","curb"]
|
36
|
+
})
|
37
|
+
assert result
|
38
|
+
end
|
39
|
+
should "#optimization with an empty bearing" do
|
40
|
+
Mapbox.access_token = ENV["MapboxAccessToken"]
|
41
|
+
result = Mapbox::Optimization.optimization([{
|
42
|
+
"longitude" => -122.42,
|
43
|
+
"latitude" => 37.78
|
44
|
+
}, {
|
45
|
+
"longitude" => -122.45,
|
46
|
+
"latitude" => 37.91
|
47
|
+
}, {
|
48
|
+
"longitude" => -122.48,
|
49
|
+
"latitude" => 37.73
|
50
|
+
}], "driving", {
|
51
|
+
bearings: "45,90;;90,1"
|
52
|
+
})
|
53
|
+
assert result
|
54
|
+
end
|
55
|
+
end
|
56
|
+
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.3.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: 2019-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -97,6 +97,9 @@ files:
|
|
97
97
|
- docs/directions.md
|
98
98
|
- docs/geocoding.md
|
99
99
|
- docs/isochrone.md
|
100
|
+
- docs/mapmatching.md
|
101
|
+
- docs/matrix.md
|
102
|
+
- docs/optimization.md
|
100
103
|
- docs/tilequery.md
|
101
104
|
- lib/mapbox-sdk.rb
|
102
105
|
- lib/mapbox.rb
|
@@ -105,13 +108,19 @@ files:
|
|
105
108
|
- lib/mapbox/directions.rb
|
106
109
|
- lib/mapbox/geocoder.rb
|
107
110
|
- lib/mapbox/isochrone.rb
|
111
|
+
- lib/mapbox/map_matching.rb
|
112
|
+
- lib/mapbox/matrix.rb
|
113
|
+
- lib/mapbox/optimization.rb
|
108
114
|
- lib/mapbox/tilequery.rb
|
109
115
|
- mapbox-sdk.gemspec
|
110
116
|
- test/all_tests.rb
|
111
117
|
- test/directions_test.rb
|
112
118
|
- test/geocoding_test.rb
|
113
119
|
- test/isochrone_test.rb
|
120
|
+
- test/map_matching_test.rb
|
114
121
|
- test/mapbox_test.rb
|
122
|
+
- test/matrix_test.rb
|
123
|
+
- test/optimization_test.rb
|
115
124
|
- test/tilequery_test.rb
|
116
125
|
homepage: https://mapbox.com/developers
|
117
126
|
licenses:
|
@@ -132,8 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
141
|
- !ruby/object:Gem::Version
|
133
142
|
version: '0'
|
134
143
|
requirements: []
|
135
|
-
|
136
|
-
rubygems_version: 2.7.8
|
144
|
+
rubygems_version: 3.0.3
|
137
145
|
signing_key:
|
138
146
|
specification_version: 4
|
139
147
|
summary: Ruby bindings for the Mapbox API
|
@@ -142,5 +150,8 @@ test_files:
|
|
142
150
|
- test/directions_test.rb
|
143
151
|
- test/geocoding_test.rb
|
144
152
|
- test/isochrone_test.rb
|
153
|
+
- test/map_matching_test.rb
|
145
154
|
- test/mapbox_test.rb
|
155
|
+
- test/matrix_test.rb
|
156
|
+
- test/optimization_test.rb
|
146
157
|
- test/tilequery_test.rb
|