fast-polylines 0.1.0 → 0.1.1

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: cf28bc2bb47a05f419d1366ecb38d2b33e22af0e
4
- data.tar.gz: b0fb22fcb016fd2397a4dcc4b7346772a8dcabae
3
+ metadata.gz: 188b873d21a061c22675b35f10d0364dd81407c2
4
+ data.tar.gz: d0a78755d81d3eecc329023a5956af078c1930b1
5
5
  SHA512:
6
- metadata.gz: e74e05e39f67996941bf7409d8e7daa526d1578be1e2e3f1f3bbe7dcb564bd22908fd3eaeeb6f17ac3f47e017b7ff54e0554fd3b5a1c91f0a981f08b42c678fe
7
- data.tar.gz: 5041a5e03079af6a48f50c8f0796382deed04e422cc1721c12edfabcdb19b9bcc5c2ca6bd2505716fffe9dc4d7f43ae61d3a262c5055a888bc0f121e668730ed
6
+ metadata.gz: 206c7ddc05a9cd4585f3090ff3a75eec0a888a59c2413ffcfa3dfb6a60152f3295e0298eff098528bee4f1e9289a8f44ab71a5658aa2ca48aa9605ca6ff182cb
7
+ data.tar.gz: 6ece894847da8d830754b09a096c250232e9f7cc4dd80758ea093a463130a24724b6c114b98f4db190684394720951bf4000a0afa5615b9e3b9300f46092036b
data/README.md CHANGED
@@ -1,11 +1,14 @@
1
1
  # Fast Polylines
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/fast-polylines.svg)](https://badge.fury.io/rb/fast-polylines)
4
+ [![CircleCI](https://circleci.com/gh/klaxit/fast-polylines.svg?style=shield&circle-token=:circle-token)](https://circleci.com/gh/klaxit/fast-polylines)
5
+
3
6
  Implementation of the Google polyline algorithm :
4
7
  http://code.google.com/apis/maps/documentation/utilities/polylinealgorithm.html
5
8
 
6
- Inspired by Joshua Clayton gem : https://github.com/joshuaclayton/polylines
9
+ Greatly inspired by Joshua Clayton gem : https://github.com/joshuaclayton/polylines
7
10
 
8
- But **at least a 5x faster implementation**.
11
+ But an **at least 5x faster** implementation.
9
12
 
10
13
  ## Install
11
14
 
@@ -20,13 +20,13 @@ module FastPolylines
20
20
  end
21
21
  lat = lng = 0
22
22
  coords.each_slice(2).map do |coords_pair|
23
- lat += decode_number(coords_pair[0], precision)
24
- lng += decode_number(coords_pair[1], precision)
25
- [lat, lng]
23
+ lat += decode_number(coords_pair[0])
24
+ lng += decode_number(coords_pair[1])
25
+ [lat / precision, lng / precision]
26
26
  end
27
27
  end
28
28
 
29
- def self.decode_number(string, precision = 1e5)
29
+ def self.decode_number(string)
30
30
  result = 1
31
31
  shift = 0
32
32
  string.each_byte do |b|
@@ -34,8 +34,7 @@ module FastPolylines
34
34
  result += b << shift
35
35
  shift += 5
36
36
  end
37
- result = (result & 1).nonzero? ? (~result >> 1) : (result >> 1)
38
- result / precision
37
+ (result & 1).nonzero? ? (~result >> 1) : (result >> 1)
39
38
  end
40
39
  private_class_method :decode_number
41
40
  end
@@ -1,3 +1,3 @@
1
1
  module FastPolylines
2
- VERSION = "0.1.0".freeze
2
+ VERSION = "0.1.1".freeze
3
3
  end
@@ -28,5 +28,12 @@ describe FastPolylines::Decoder do
28
28
  expect(described_class.decode("krk{FdxdlO?e@")).to eq points
29
29
  end
30
30
  end
31
+ context "with points that cause float overflow" do
32
+ let(:polyline) { "ahdiHsmeMHPDN|A`FVt@" }
33
+ let(:points) { [[48.85137, 2.32682], [48.85132, 2.32673], [48.85129, 2.32665], [48.85082, 2.32552], [48.8507, 2.32525]] }
34
+ it "should respect precision" do
35
+ expect(described_class.decode(polyline)).to eq points
36
+ end
37
+ end
31
38
  end
32
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fast-polylines
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyrille Courtière
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-19 00:00:00.000000000 Z
11
+ date: 2018-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0.3'
55
55
  description:
56
56
  email:
57
- - cyrille@wayzup.com
57
+ - cyrille@klaxit.com
58
58
  executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
@@ -67,7 +67,7 @@ files:
67
67
  - spec/fast-polylines/decoder_spec.rb
68
68
  - spec/fast-polylines/encoder_spec.rb
69
69
  - spec/spec_helper.rb
70
- homepage: http://github.com/wayzup/fast-polylines
70
+ homepage: http://github.com/klaxit/fast-polylines
71
71
  licenses:
72
72
  - MIT
73
73
  metadata: {}
@@ -87,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  version: '0'
88
88
  requirements: []
89
89
  rubyforge_project:
90
- rubygems_version: 2.6.8
90
+ rubygems_version: 2.5.2
91
91
  signing_key:
92
92
  specification_version: 4
93
93
  summary: Fast & easy Google polylines