polylines 0.1.0 → 0.1.1
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.
- data/Gemfile.lock +1 -1
- data/lib/polylines/base.rb +3 -1
- data/lib/polylines/version.rb +1 -1
- data/spec/polylines/encoder_spec.rb +6 -0
- metadata +2 -2
data/Gemfile.lock
CHANGED
data/lib/polylines/base.rb
CHANGED
@@ -93,12 +93,14 @@ module Polylines
|
|
93
93
|
if self == Polylines::Encoder
|
94
94
|
delta_latitude, delta_longitude = 0, 0
|
95
95
|
|
96
|
-
|
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
|
data/lib/polylines/version.rb
CHANGED
@@ -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.
|
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-
|
12
|
+
date: 2012-11-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|