pointy 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/lib/pointy.rb +28 -11
- data/lib/pointy/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8495e00f8c5acd73c26a0f48564cfa025dd5310
|
4
|
+
data.tar.gz: bab007222a6d876296b344ce8787a98c25b9b8ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb4f29abe94c2d5f448332de34312c4ac67b3d7ef59986d97c530351ce7de632c9db2ea9179811d8a101688ea5f66b87f43ff044c1c5afc03d1324f8999f45e7
|
7
|
+
data.tar.gz: 604366875487225ab3b407446057a959bce30e64ba31f5aa1ba3efdfd20d5d51731820b482090dbc89fa36135ed2eb90bd5cbe56393628ef9dfd987b94a50967
|
data/README.md
CHANGED
@@ -33,7 +33,9 @@ Or install it yourself as:
|
|
33
33
|
long: -4.2590
|
34
34
|
}
|
35
35
|
|
36
|
-
The returned array of points are of the same format.
|
36
|
+
The returned array of points are of the same format. If you would rather an
|
37
|
+
array of
|
38
|
+
[polylines](https://code.google.com/apis/maps/documentation/utilities/polylinealgorithm.html) then call `Pointy.route_polylines(from, to)` instead.
|
37
39
|
|
38
40
|
You can also pass in any other query parameters accepted by Google, so you override the API key or transport mode
|
39
41
|
|
data/lib/pointy.rb
CHANGED
@@ -15,7 +15,7 @@ module Pointy
|
|
15
15
|
# lat: float
|
16
16
|
# long: float
|
17
17
|
# }
|
18
|
-
def self.
|
18
|
+
def self.route_polylines(from, to, opts={})
|
19
19
|
return if default_params[:key].nil? and opts[:key].nil?
|
20
20
|
|
21
21
|
# Format points for Google API
|
@@ -36,22 +36,39 @@ module Pointy
|
|
36
36
|
return if legs.nil? or legs.empty?
|
37
37
|
|
38
38
|
# Accumulate all points
|
39
|
-
legs.inject([]) do |
|
39
|
+
legs.inject([]) do |polylines, leg|
|
40
40
|
steps = leg['steps']
|
41
41
|
if !steps.nil? and !steps.empty?
|
42
42
|
steps.each_with_index do |step, index|
|
43
|
-
|
44
|
-
decoded_poly = Polylines::Decoder.decode_polyline(polyline)
|
45
|
-
all_points += decoded_poly.map do |coord|
|
46
|
-
{
|
47
|
-
lat: coord.first,
|
48
|
-
long: coord.last
|
49
|
-
}
|
50
|
-
end
|
43
|
+
polylines << step['polyline']['points']
|
51
44
|
end
|
52
45
|
end
|
53
46
|
|
54
|
-
|
47
|
+
polylines
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# from and to should be of format:
|
52
|
+
# {
|
53
|
+
# lat: float
|
54
|
+
# long: float
|
55
|
+
# }
|
56
|
+
def self.route_coordinates(from, to, opts={})
|
57
|
+
polylines = Pointy.route_polylines(from, to, opts)
|
58
|
+
return if polylines.nil?
|
59
|
+
|
60
|
+
polylines.inject([]) do |all_points, polyline|
|
61
|
+
decoded_poly = Polylines::Decoder.decode_polyline(polyline)
|
62
|
+
all_points += decoded_poly.map do |coord|
|
63
|
+
{
|
64
|
+
lat: coord.first,
|
65
|
+
long: coord.last
|
66
|
+
}
|
67
|
+
end
|
55
68
|
end
|
56
69
|
end
|
70
|
+
|
71
|
+
def self.route(from, to, opts={})
|
72
|
+
Pointy.route_coordinates(from, to, opts)
|
73
|
+
end
|
57
74
|
end
|
data/lib/pointy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pointy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Sloey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|