polylines 0.3.0 → 0.4.0
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 +5 -5
- data/Gemfile.lock +19 -11
- data/lib/polylines/decoder.rb +1 -1
- data/lib/polylines/version.rb +1 -1
- data/polylines.gemspec +1 -1
- data/spec/polylines/decoder_spec.rb +23 -9
- data/spec/polylines/encoder_spec.rb +19 -11
- data/spec/spec_helper.rb +0 -4
- metadata +5 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: da58528bb3a57978f8dc73763bcebd2dd09d64cac7f6c64f6dffc33cdcc9a1c1
|
4
|
+
data.tar.gz: a0869fe420b3721e367374e163c2b396655efbb47b1a6c50b8864943a162a191
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8745bf6f073c0894590884508f587448fdda56a9e24e8c2a09649f7477cd2eab1602e85c2754eb43242e43bc7748d8eb703aa948d68c9959ac546f7363dbe42
|
7
|
+
data.tar.gz: 9dc0c56d23b52261c03443a6f0b9a1a6e96fcb2c7f5b20ff1246853e69370c0fea4d1a35614a95deaccdb6f5a125fc8f4bb165f459da55f4c41a2074b950ae70
|
data/Gemfile.lock
CHANGED
@@ -1,21 +1,26 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
polylines (0.
|
4
|
+
polylines (0.4.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: http://rubygems.org/
|
8
8
|
specs:
|
9
|
-
diff-lcs (1.
|
9
|
+
diff-lcs (1.4.4)
|
10
10
|
rake (10.0.2)
|
11
|
-
rspec (
|
12
|
-
rspec-core (~>
|
13
|
-
rspec-expectations (~>
|
14
|
-
rspec-mocks (~>
|
15
|
-
rspec-core (
|
16
|
-
|
17
|
-
|
18
|
-
|
11
|
+
rspec (3.10.0)
|
12
|
+
rspec-core (~> 3.10.0)
|
13
|
+
rspec-expectations (~> 3.10.0)
|
14
|
+
rspec-mocks (~> 3.10.0)
|
15
|
+
rspec-core (3.10.0)
|
16
|
+
rspec-support (~> 3.10.0)
|
17
|
+
rspec-expectations (3.10.0)
|
18
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
+
rspec-support (~> 3.10.0)
|
20
|
+
rspec-mocks (3.10.0)
|
21
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
+
rspec-support (~> 3.10.0)
|
23
|
+
rspec-support (3.10.0)
|
19
24
|
|
20
25
|
PLATFORMS
|
21
26
|
ruby
|
@@ -23,4 +28,7 @@ PLATFORMS
|
|
23
28
|
DEPENDENCIES
|
24
29
|
polylines!
|
25
30
|
rake
|
26
|
-
rspec (=
|
31
|
+
rspec (= 3.10.0)
|
32
|
+
|
33
|
+
BUNDLED WITH
|
34
|
+
2.1.4
|
data/lib/polylines/decoder.rb
CHANGED
@@ -7,7 +7,7 @@ module Polylines
|
|
7
7
|
[].tap do |points|
|
8
8
|
points << [points_with_deltas.shift, points_with_deltas.shift]
|
9
9
|
|
10
|
-
while points_with_deltas.
|
10
|
+
while points_with_deltas.size > 1
|
11
11
|
points << [
|
12
12
|
points.last[0] + points_with_deltas.shift,
|
13
13
|
points.last[1] + points_with_deltas.shift
|
data/lib/polylines/version.rb
CHANGED
data/polylines.gemspec
CHANGED
@@ -16,6 +16,6 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
17
|
s.require_paths = ["lib"]
|
18
18
|
|
19
|
-
s.add_development_dependency("rspec", "
|
19
|
+
s.add_development_dependency("rspec", "3.10.0")
|
20
20
|
s.add_development_dependency("rake")
|
21
21
|
end
|
@@ -2,38 +2,52 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe Polylines::Decoder, ".decode" do
|
4
4
|
it "decodes a single point" do
|
5
|
-
Polylines::Decoder.decode("`~oia@").
|
5
|
+
expect(Polylines::Decoder.decode("`~oia@")).to be_within(0.00001).of(-179.9832104)
|
6
6
|
end
|
7
7
|
|
8
8
|
it "decodes a single point with 1e6 precision" do
|
9
|
-
Polylines::Decoder.decode("ruhhvI", 1e6).
|
9
|
+
expect(Polylines::Decoder.decode("ruhhvI", 1e6)).to be_within(0.000001).of(-179.9832104)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
describe Polylines::Decoder, ".decode_polyline" do
|
14
|
-
let(:points)
|
14
|
+
let(:points) { [[38.5, -120.2], [40.7, -120.95], [43.252, -126.453]] }
|
15
15
|
|
16
16
|
context "with default precision" do
|
17
|
-
let(:polyline) { "_p~iF~ps|U_ulLnnqC_mqNvxq`@" }
|
18
17
|
it "decodes a polyline correctly" do
|
19
|
-
|
18
|
+
polyline = "_p~iF~ps|U_ulLnnqC_mqNvxq`@"
|
19
|
+
|
20
|
+
expect(Polylines::Decoder.decode_polyline(polyline)).to eq points
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
23
24
|
context "with 1e6 precision" do
|
24
|
-
let(:polyline) { "_izlhA~rlgdF_{geC~ywl@_kwzCn`{nI" }
|
25
25
|
it "decodes a polyline correctly" do
|
26
|
-
|
26
|
+
polyline = "_izlhA~rlgdF_{geC~ywl@_kwzCn`{nI"
|
27
|
+
|
28
|
+
expect(Polylines::Decoder.decode_polyline(polyline, 1e6)).to eq points
|
27
29
|
end
|
28
30
|
end
|
29
31
|
end
|
30
32
|
|
31
33
|
describe Polylines::Decoder, ".decode_polyline with points that were close together" do
|
32
34
|
it "decodes a polyline correctly" do
|
33
|
-
|
35
|
+
points = [[41.35222, -86.04563], [41.35222, -86.04544]]
|
36
|
+
|
37
|
+
expect(Polylines::Decoder.decode_polyline("krk{FdxdlO?e@")).to eq points
|
34
38
|
end
|
35
39
|
|
36
40
|
it "decodes a polyline correctly with 1e6 precision" do
|
37
|
-
|
41
|
+
points = [[41.352217, -86.045630], [41.352217, -86.045437]]
|
42
|
+
|
43
|
+
expect(Polylines::Decoder.decode_polyline("q`}zmAzzxbcD?aK", 1e6)).to eq points
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe Polylines::Decoder, ".decode_polyline with a value that previously broke" do
|
48
|
+
it "decodes a polyline correctly" do
|
49
|
+
value = "kbdoH{ioqCoF_j@Lwc@lC{BhNoMzCuJbEm]?wKkBaQmD}EqM_GwFiBfCge@zE_K~SaTdT`L|Da\\\\xJsX|EyJtQgPpXuRjKAtJqBfM[pn@g^nF}G??"
|
50
|
+
|
51
|
+
expect(Polylines::Decoder.decode_polyline(value).length).to eq 27
|
38
52
|
end
|
39
53
|
end
|
@@ -2,44 +2,52 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe Polylines::Encoder, ".encode" do
|
4
4
|
it "encodes a single point" do
|
5
|
-
Polylines::Encoder.encode(-179.9832104).
|
5
|
+
expect(Polylines::Encoder.encode(-179.9832104)).to eq "`~oia@"
|
6
6
|
end
|
7
7
|
|
8
8
|
it "encodes a single point with 1e6 precision" do
|
9
|
-
Polylines::Encoder.encode(-179.9832104, 1e6).
|
9
|
+
expect(Polylines::Encoder.encode(-179.9832104, 1e6)).to eq "ruhhvI"
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
describe Polylines::Encoder, ".encode_points" do
|
14
|
-
let(:points)
|
14
|
+
let(:points) { [[38.5, -120.2], [40.7, -120.95], [43.252, -126.453]] }
|
15
15
|
|
16
16
|
context "with default precision" do
|
17
|
-
let(:polyline) { "_p~iF~ps|U_ulLnnqC_mqNvxq`@" }
|
18
17
|
it "encodes points correctly" do
|
19
|
-
|
18
|
+
polyline = "_p~iF~ps|U_ulLnnqC_mqNvxq`@"
|
19
|
+
|
20
|
+
expect(Polylines::Encoder.encode_points(points)).to eq polyline
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
23
24
|
context "with 1e6 precsion" do
|
24
|
-
let(:polyline) { "_izlhA~rlgdF_{geC~ywl@_kwzCn`{nI" }
|
25
25
|
it "encodes points correctly" do
|
26
|
-
|
26
|
+
polyline = "_izlhA~rlgdF_{geC~ywl@_kwzCn`{nI"
|
27
|
+
|
28
|
+
expect(Polylines::Encoder.encode_points(points, 1e6)).to eq polyline
|
27
29
|
end
|
28
30
|
end
|
29
31
|
end
|
30
32
|
|
31
33
|
describe Polylines::Encoder, ".encode_points that are very close together" do
|
32
34
|
it "encodes points correctly" do
|
33
|
-
|
35
|
+
points = [[41.3522171071184, -86.0456299662023], [41.3522171071183, -86.0454368471533]]
|
36
|
+
|
37
|
+
expect(Polylines::Encoder.encode_points(points)).to eq "krk{FdxdlO?e@"
|
34
38
|
end
|
35
39
|
|
36
40
|
it "encodes points correctly with 1e6 precision" do
|
37
|
-
|
41
|
+
points = [[41.3522171071184, -86.0456299662023], [41.3522171071183, -86.0454368471533]]
|
42
|
+
|
43
|
+
expect(Polylines::Encoder.encode_points(points, 1e6)).to eq "q`}zmAzzxbcD?aK"
|
38
44
|
end
|
39
45
|
end
|
40
46
|
|
41
47
|
describe Polylines::Encoder, ".encode_points with same results as google's api" do
|
42
48
|
it "encodes without rounding errors" do
|
43
|
-
|
49
|
+
points = [[39.13594499,-94.4243478], [39.13558757,-94.4243471]]
|
50
|
+
|
51
|
+
expect(Polylines::Encoder.encode_points(points)).to eq "svzmFdgi_QdA?"
|
44
52
|
end
|
45
|
-
end
|
53
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polylines
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Clayton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 3.10.0
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 3.10.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,8 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
78
|
- !ruby/object:Gem::Version
|
79
79
|
version: '0'
|
80
80
|
requirements: []
|
81
|
-
|
82
|
-
rubygems_version: 2.4.5
|
81
|
+
rubygems_version: 3.1.4
|
83
82
|
signing_key:
|
84
83
|
specification_version: 4
|
85
84
|
summary: Easily handle Google polylines
|
@@ -87,4 +86,3 @@ test_files:
|
|
87
86
|
- spec/polylines/decoder_spec.rb
|
88
87
|
- spec/polylines/encoder_spec.rb
|
89
88
|
- spec/spec_helper.rb
|
90
|
-
has_rdoc:
|