geohex 2.0.0 → 2.0.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.
Files changed (4) hide show
  1. data/.gemtest +0 -0
  2. data/lib/geohex.rb +15 -13
  3. data/spec/geohex_spec.rb +3 -3
  4. metadata +7 -38
File without changes
@@ -7,7 +7,7 @@ require 'rubygems'
7
7
  require 'ostruct'
8
8
 
9
9
  module GeoHex
10
- VERSION = '2.0.0'
10
+ VERSION = '2.0.1'
11
11
 
12
12
  H_KEY = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
13
13
  H_BASE = 20037508.34;
@@ -43,7 +43,7 @@ module GeoHex
43
43
  def hexCoords
44
44
  h_lat = self.lat;
45
45
  h_lon = self.lon;
46
- h_xy = GeoHex.loc2xy(h_lon, h_lat);
46
+ h_xy = GeoHex::Zone.loc2xy(h_lon, h_lat);
47
47
  h_x = h_xy.x
48
48
  h_y = h_xy.y
49
49
  h_deg = Math.tan(Math::PI * (60 / 180));
@@ -201,17 +201,19 @@ module GeoHex
201
201
  end
202
202
  end
203
203
 
204
- def loc2xy(_lon,_lat)
205
- x=_lon*H_BASE/180;
206
- y= Math.log(Math.tan((90+_lat)*Math::PI/360)) / (Math::PI / 180 );
207
- y= y * H_BASE / 180;
208
- return OpenStruct.new("x"=>x, "y"=>y);
209
- end
210
-
211
- def xy2loc(_x,_y)
212
- lon=(_x/H_BASE)*180;
213
- lat=(_y/H_BASE)*180;
204
+ class << Zone
205
+ def loc2xy(_lon,_lat)
206
+ x=_lon*H_BASE/180;
207
+ y= Math.log(Math.tan((90+_lat)*Math::PI/360)) / (Math::PI / 180 );
208
+ y= y * H_BASE / 180;
209
+ return OpenStruct.new("x"=>x, "y"=>y);
210
+ end
211
+
212
+ def xy2loc(_x,_y)
213
+ lon=(_x/H_BASE)*180;
214
+ lat=(_y/H_BASE)*180;
214
215
  lat=180.0/Math::PI*(2.0*Math.atan(Math.exp(lat*Math::PI/180))-Math::PI/2);
215
- return OpenStruct.new("lon" => lon,"lat" => lat);
216
+ return OpenStruct.new("lon" => lon,"lat" => lat);
217
+ end
216
218
  end
217
219
  end
@@ -1,4 +1,4 @@
1
- require "#{File.dirname(__FILE__)}/../lib/geohex.rb"
1
+ require "#{File.expand_path(File.dirname(__FILE__))}/../lib/geohex.rb"
2
2
  require "pp"
3
3
  include GeoHex
4
4
 
@@ -6,13 +6,13 @@ describe GeoHex do
6
6
  before(:all) do
7
7
  @test_ll2hex = []
8
8
  @test_hex2ll = []
9
- File.open("#{File.dirname(__FILE__)}/testdata_ll2hex.txt").read.each_line do |l|
9
+ File.open("#{File.expand_path(File.dirname(__FILE__))}/testdata_ll2hex.txt").read.each_line do |l|
10
10
  if l.slice(0,1) != "#"
11
11
  d = l.strip.split(',')
12
12
  @test_ll2hex << [d[0].to_f, d[1].to_f, d[2].to_i, d[3]]
13
13
  end
14
14
  end
15
- File.open("#{File.dirname(__FILE__)}/testdata_hex2ll.txt").read.each_line do |l|
15
+ File.open("#{File.expand_path(File.dirname(__FILE__))}/testdata_hex2ll.txt").read.each_line do |l|
16
16
  if l.slice(0,1) != "#"
17
17
  d = l.strip.split(',')
18
18
  @test_hex2ll << [d[0],d[1].to_f, d[2].to_f,d[3].to_i]
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geohex
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
5
- prerelease: false
6
- segments:
7
- - 2
8
- - 0
9
- - 0
10
- version: 2.0.0
4
+ prerelease:
5
+ version: 2.0.1
11
6
  platform: ruby
12
7
  authors:
13
8
  - hal_sk
@@ -15,41 +10,20 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2010-10-08 00:00:00 +09:00
13
+ date: 2011-02-06 00:00:00 +09:00
19
14
  default_executable:
20
15
  dependencies:
21
16
  - !ruby/object:Gem::Dependency
22
- name: rubyforge
17
+ name: hoe
23
18
  prerelease: false
24
19
  requirement: &id001 !ruby/object:Gem::Requirement
25
20
  none: false
26
21
  requirements:
27
22
  - - ">="
28
23
  - !ruby/object:Gem::Version
29
- hash: 7
30
- segments:
31
- - 2
32
- - 0
33
- - 4
34
- version: 2.0.4
24
+ version: 2.9.0
35
25
  type: :development
36
26
  version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: hoe
39
- prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 19
46
- segments:
47
- - 2
48
- - 6
49
- - 2
50
- version: 2.6.2
51
- type: :development
52
- version_requirements: *id002
53
27
  description: |-
54
28
  This GeoHex Ruby gem can convert latitude/longitude to GeoHex code each others.
55
29
  * Encode from latitude/longitude to GeoHex code to an arbitrary level of precision
@@ -71,6 +45,7 @@ files:
71
45
  - Rakefile
72
46
  - lib/geohex.rb
73
47
  - spec/geohex_spec.rb
48
+ - .gemtest
74
49
  has_rdoc: true
75
50
  homepage: http://geohex.rubyforge.org/
76
51
  licenses: []
@@ -86,23 +61,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
86
61
  requirements:
87
62
  - - ">="
88
63
  - !ruby/object:Gem::Version
89
- hash: 3
90
- segments:
91
- - 0
92
64
  version: "0"
93
65
  required_rubygems_version: !ruby/object:Gem::Requirement
94
66
  none: false
95
67
  requirements:
96
68
  - - ">="
97
69
  - !ruby/object:Gem::Version
98
- hash: 3
99
- segments:
100
- - 0
101
70
  version: "0"
102
71
  requirements: []
103
72
 
104
73
  rubyforge_project: geohex
105
- rubygems_version: 1.3.7
74
+ rubygems_version: 1.5.0
106
75
  signing_key:
107
76
  specification_version: 3
108
77
  summary: This GeoHex Ruby gem can convert latitude/longitude to GeoHex code each others