pointy 0.0.1 → 0.0.2
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/lib/pointy.rb +16 -13
- data/lib/pointy/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 943e99115573fc3c8796281392156d709e5aaad7
|
4
|
+
data.tar.gz: 927301e76c0a9dd1966ab22259f3581a19a76b50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd781242022c91e6119dfee840e97e05d046f39de94bfe9ce7d5e8f5eafc4259190c7219966805261d7d581189898d55ae3e85598c6762dd6a57bc9ac7b2aab8
|
7
|
+
data.tar.gz: ad9b6fe9c3bbe458e03d490c243f84a481f67d23d2c6e7db9a47599361bb0fb9a28139f443e5bfa2d7809b81e7b6a1a758b1bff4b24d91e510cfaaf06f66fd96
|
data/lib/pointy.rb
CHANGED
@@ -16,6 +16,8 @@ module Pointy
|
|
16
16
|
# long: float
|
17
17
|
# }
|
18
18
|
def self.route(from, to, opts={})
|
19
|
+
return if default_params[:key].nil? and opts[:key].nil?
|
20
|
+
|
19
21
|
# Format points for Google API
|
20
22
|
opts.merge!({
|
21
23
|
origin: "#{from[:lat]},#{from[:long]}",
|
@@ -33,22 +35,23 @@ module Pointy
|
|
33
35
|
legs = route['legs']
|
34
36
|
return if legs.nil? or legs.empty?
|
35
37
|
|
36
|
-
|
37
|
-
legs.
|
38
|
+
# Accumulate all points
|
39
|
+
legs.inject([]) do |all_points, leg|
|
38
40
|
steps = leg['steps']
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
41
|
+
if !steps.nil? and !steps.empty?
|
42
|
+
steps.each_with_index do |step, index|
|
43
|
+
polyline = step['polyline']['points']
|
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
|
48
51
|
end
|
49
52
|
end
|
50
|
-
end
|
51
53
|
|
52
|
-
|
54
|
+
all_points
|
55
|
+
end
|
53
56
|
end
|
54
57
|
end
|
data/lib/pointy/version.rb
CHANGED