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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 943e99115573fc3c8796281392156d709e5aaad7
4
- data.tar.gz: 927301e76c0a9dd1966ab22259f3581a19a76b50
3
+ metadata.gz: b8495e00f8c5acd73c26a0f48564cfa025dd5310
4
+ data.tar.gz: bab007222a6d876296b344ce8787a98c25b9b8ae
5
5
  SHA512:
6
- metadata.gz: bd781242022c91e6119dfee840e97e05d046f39de94bfe9ce7d5e8f5eafc4259190c7219966805261d7d581189898d55ae3e85598c6762dd6a57bc9ac7b2aab8
7
- data.tar.gz: ad9b6fe9c3bbe458e03d490c243f84a481f67d23d2c6e7db9a47599361bb0fb9a28139f443e5bfa2d7809b81e7b6a1a758b1bff4b24d91e510cfaaf06f66fd96
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
 
@@ -15,7 +15,7 @@ module Pointy
15
15
  # lat: float
16
16
  # long: float
17
17
  # }
18
- def self.route(from, to, opts={})
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 |all_points, leg|
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
- 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
43
+ polylines << step['polyline']['points']
51
44
  end
52
45
  end
53
46
 
54
- all_points
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
@@ -1,3 +1,3 @@
1
1
  module Pointy
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
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.2
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-16 00:00:00.000000000 Z
11
+ date: 2014-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler