polylines 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- polylines (0.1.0)
4
+ polylines (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -93,12 +93,14 @@ module Polylines
93
93
  if self == Polylines::Encoder
94
94
  delta_latitude, delta_longitude = 0, 0
95
95
 
96
- return value.inject([]) do |polyline, (latitude, longitude)|
96
+ e5_values = value.map{|tuple| tuple.map{|val| (val * 1e5).round } }
97
+ deltas = e5_values.inject([]) do |polyline, (latitude, longitude)|
97
98
  polyline << latitude - delta_latitude
98
99
  polyline << longitude - delta_longitude
99
100
  delta_latitude, delta_longitude = latitude, longitude
100
101
  polyline
101
102
  end
103
+ return deltas.map{|val| val.to_f/1e5 }
102
104
  end
103
105
 
104
106
  if self == Polylines::Decoder
@@ -1,3 +1,3 @@
1
1
  module Polylines
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -20,3 +20,9 @@ describe Polylines::Encoder, ".encode_points that are very close together" do
20
20
  Polylines::Encoder.encode_points([[41.3522171071184, -86.0456299662023],[41.3522171071183, -86.0454368471533]]).should == "krk{FdxdlO?e@"
21
21
  end
22
22
  end
23
+
24
+ describe Polylines::Encoder, ".encode_points with same results as google's api" do
25
+ it "encodes without rounding errors" do
26
+ Polylines::Encoder.encode_points([[39.13594499,-94.4243478],[39.13558757,-94.4243471]]).should == "svzmFdgi_QdA?"
27
+ end
28
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polylines
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-18 00:00:00.000000000 Z
12
+ date: 2012-11-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec