geokit-pretty_heading 0.5.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.
- data/.gitignore +3 -0
- data/Gemfile +4 -0
- data/Rakefile +2 -0
- data/geokit-pretty_heading.gemspec +23 -0
- data/lib/geokit-pretty_heading/version.rb +5 -0
- data/lib/geokit-pretty_heading.rb +51 -0
- metadata +86 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "geokit-pretty_heading/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "geokit-pretty_heading"
|
7
|
+
s.version = Geokit::Prettyheading::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Jade Rubick"]
|
10
|
+
s.email = ["jade@rubick.com"]
|
11
|
+
s.homepage = "http://rubygems.org/gems/geokit-pretty_heading"
|
12
|
+
s.summary = %q{When given two lat/long pairs, displays a pretty heading, like North Northeast.}
|
13
|
+
s.description = %q{Displays a nicely formatted heading in English. See http://en.wikipedia.org/wiki/Boxing_the_compass for the algorithm used}
|
14
|
+
|
15
|
+
s.rubyforge_project = "geokit-pretty_heading"
|
16
|
+
|
17
|
+
s.add_dependency('geokit')
|
18
|
+
|
19
|
+
s.files = `git ls-files`.split("\n")
|
20
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
22
|
+
s.require_paths = ["lib"]
|
23
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Geokit
|
2
|
+
module Prettyheading
|
3
|
+
|
4
|
+
def self.heading(from_latlng, to_latlng)
|
5
|
+
heading = Geokit::LatLng.heading_between(from_latlng, to_latlng)
|
6
|
+
|
7
|
+
# see http://en.wikipedia.org/wiki/Boxing_the_compass
|
8
|
+
sixteen_points_centered = (heading / (360/16) + 1)
|
9
|
+
if sixteen_points_centered >= 17
|
10
|
+
sixteen_points_centered = sixteen_points_centered - 17
|
11
|
+
end
|
12
|
+
case sixteen_points_centered.to_i
|
13
|
+
when 1 then
|
14
|
+
"North"
|
15
|
+
when 2 then
|
16
|
+
"North-northeast"
|
17
|
+
when 3 then
|
18
|
+
"Northeast"
|
19
|
+
when 4 then
|
20
|
+
"East-Northeast"
|
21
|
+
when 5 then
|
22
|
+
"East"
|
23
|
+
when 6 then
|
24
|
+
"East-southeast"
|
25
|
+
when 7 then
|
26
|
+
"Southeast"
|
27
|
+
when 8 then
|
28
|
+
"South-southeast"
|
29
|
+
when 9 then
|
30
|
+
"South"
|
31
|
+
when 10 then
|
32
|
+
"South-Southwest"
|
33
|
+
when 11 then
|
34
|
+
"Southwest"
|
35
|
+
when 12 then
|
36
|
+
"West-southwest"
|
37
|
+
when 13 then
|
38
|
+
"West"
|
39
|
+
when 14 then
|
40
|
+
"West-northwest"
|
41
|
+
when 15 then
|
42
|
+
"Northwest"
|
43
|
+
when 16 then
|
44
|
+
"North-northwest"
|
45
|
+
else
|
46
|
+
"Invalid"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: geokit-pretty_heading
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 11
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 5
|
9
|
+
- 0
|
10
|
+
version: 0.5.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Jade Rubick
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-12-27 00:00:00 -05:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: geokit
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
description: Displays a nicely formatted heading in English. See http://en.wikipedia.org/wiki/Boxing_the_compass for the algorithm used
|
36
|
+
email:
|
37
|
+
- jade@rubick.com
|
38
|
+
executables: []
|
39
|
+
|
40
|
+
extensions: []
|
41
|
+
|
42
|
+
extra_rdoc_files: []
|
43
|
+
|
44
|
+
files:
|
45
|
+
- .gitignore
|
46
|
+
- Gemfile
|
47
|
+
- Rakefile
|
48
|
+
- geokit-pretty_heading.gemspec
|
49
|
+
- lib/geokit-pretty_heading.rb
|
50
|
+
- lib/geokit-pretty_heading/version.rb
|
51
|
+
has_rdoc: true
|
52
|
+
homepage: http://rubygems.org/gems/geokit-pretty_heading
|
53
|
+
licenses: []
|
54
|
+
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
hash: 3
|
66
|
+
segments:
|
67
|
+
- 0
|
68
|
+
version: "0"
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
hash: 3
|
75
|
+
segments:
|
76
|
+
- 0
|
77
|
+
version: "0"
|
78
|
+
requirements: []
|
79
|
+
|
80
|
+
rubyforge_project: geokit-pretty_heading
|
81
|
+
rubygems_version: 1.3.7
|
82
|
+
signing_key:
|
83
|
+
specification_version: 3
|
84
|
+
summary: When given two lat/long pairs, displays a pretty heading, like North Northeast.
|
85
|
+
test_files: []
|
86
|
+
|