polylines 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- polylines (0.0.1)
4
+ polylines (0.1.0)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2011 Josh Clayton
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,31 @@
1
+ # Polylines
2
+
3
+ ## Easily handle Google polylines
4
+
5
+ ## Install
6
+
7
+ Install with Rubygems:
8
+
9
+ gem install polylines
10
+
11
+ ## Usage
12
+
13
+ To encode an array of latitude/longitude pairs:
14
+
15
+ >> Polylines::Encoder.encode_points([[38.5, -120.2], [40.7, -120.95], [43.252, -126.453]])
16
+ => "_p~iF~ps|U_ulLnnqC_mqNvxq`@"
17
+
18
+ To decode a polyline into an array of latitude/longitude pairs:
19
+
20
+ >> Polylines::Decoder.decode_polyline("_p~iF~ps|U_ulLnnqC_mqNvxq`@")
21
+ => [[38.5, -120.2], [40.7, -120.95], [43.252, -126.453]]
22
+
23
+ I wrote this to follow the steps outlined in http://code.google.com/apis/maps/documentation/utilities/polylinealgorithm.html.
24
+
25
+ ## License
26
+
27
+ Please see LICENSE
28
+
29
+ ## Author
30
+
31
+ Written by Josh Clayton
@@ -37,6 +37,8 @@ module Polylines
37
37
  numbers.unshift(current_value & 0x1f)
38
38
  @current_value >>= 5
39
39
  end
40
+
41
+ numbers << 0 if numbers.empty?
40
42
  end
41
43
  end
42
44
 
@@ -1,3 +1,3 @@
1
1
  module Polylines
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -14,3 +14,9 @@ describe Polylines::Decoder, ".decode_polyline" do
14
14
  Polylines::Decoder.decode_polyline(polyline).should == points
15
15
  end
16
16
  end
17
+
18
+ describe Polylines::Decoder, ".decode_polyline with points that were close together" do
19
+ it "decodes a polyline correctly" do
20
+ Polylines::Decoder.decode_polyline("krk{FdxdlO?e@").should == [[41.35222, -86.04563],[41.35222, -86.04544]]
21
+ end
22
+ end
@@ -14,3 +14,9 @@ describe Polylines::Encoder, ".encode_points" do
14
14
  Polylines::Encoder.encode_points(points).should == polyline
15
15
  end
16
16
  end
17
+
18
+ describe Polylines::Encoder, ".encode_points that are very close together" do
19
+ it "encodes points correctly" do
20
+ Polylines::Encoder.encode_points([[41.3522171071184, -86.0456299662023],[41.3522171071183, -86.0454368471533]]).should == "krk{FdxdlO?e@"
21
+ end
22
+ end
metadata CHANGED
@@ -1,50 +1,44 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: polylines
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 0
8
- - 1
9
- version: 0.0.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Josh Clayton
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2011-02-19 00:00:00 -05:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-06-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: rspec
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - "="
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 2
30
- - 4
31
- - 0
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
32
21
  version: 2.4.0
33
22
  type: :development
34
- version_requirements: *id001
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - '='
28
+ - !ruby/object:Gem::Version
29
+ version: 2.4.0
35
30
  description:
36
- email:
31
+ email:
37
32
  - joshua.clayton@gmail.com
38
33
  executables: []
39
-
40
34
  extensions: []
41
-
42
35
  extra_rdoc_files: []
43
-
44
- files:
36
+ files:
45
37
  - .gitignore
46
38
  - Gemfile
47
39
  - Gemfile.lock
40
+ - LICENSE
41
+ - README.markdown
48
42
  - Rakefile
49
43
  - lib/polylines.rb
50
44
  - lib/polylines/base.rb
@@ -55,39 +49,32 @@ files:
55
49
  - spec/polylines/decoder_spec.rb
56
50
  - spec/polylines/encoder_spec.rb
57
51
  - spec/spec_helper.rb
58
- has_rdoc: true
59
- homepage: ""
52
+ homepage: ''
60
53
  licenses: []
61
-
62
54
  post_install_message:
63
55
  rdoc_options: []
64
-
65
- require_paths:
56
+ require_paths:
66
57
  - lib
67
- required_ruby_version: !ruby/object:Gem::Requirement
58
+ required_ruby_version: !ruby/object:Gem::Requirement
68
59
  none: false
69
- requirements:
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- segments:
73
- - 0
74
- version: "0"
75
- required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
65
  none: false
77
- requirements:
78
- - - ">="
79
- - !ruby/object:Gem::Version
80
- segments:
81
- - 0
82
- version: "0"
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
83
70
  requirements: []
84
-
85
71
  rubyforge_project:
86
- rubygems_version: 1.3.7
72
+ rubygems_version: 1.8.23
87
73
  signing_key:
88
74
  specification_version: 3
89
75
  summary: Easily handle Google polylines
90
- test_files:
76
+ test_files:
91
77
  - spec/polylines/decoder_spec.rb
92
78
  - spec/polylines/encoder_spec.rb
93
79
  - spec/spec_helper.rb
80
+ has_rdoc: