rack-ketai 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +21 -0
- data/VERSION +1 -1
- data/lib/rack/ketai.rb +1 -0
- data/lib/rack/ketai/carrier/abstract.rb +10 -1
- data/lib/rack/ketai/carrier/au.rb +31 -0
- data/lib/rack/ketai/carrier/cidrs/au.rb +8 -2
- data/lib/rack/ketai/carrier/docomo.rb +11 -0
- data/lib/rack/ketai/carrier/softbank.rb +22 -0
- data/lib/rack/ketai/carrier/specs/au.rb +1 -1
- data/lib/rack/ketai/carrier/specs/docomo.rb +1 -1
- data/lib/rack/ketai/carrier/specs/softbank.rb +1 -1
- data/lib/rack/ketai/position.rb +64 -0
- data/rack-ketai.gemspec +10 -3
- data/spec/unit/gps_spec.rb +146 -0
- data/spec/unit/position_spec.rb +49 -0
- data/vendor/datum_conv/MIT-LICENSE +7 -0
- data/vendor/datum_conv/lib/datum_conv.rb +72 -0
- metadata +10 -7
@@ -0,0 +1,49 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'rack/ketai/position'
|
3
|
+
|
4
|
+
describe "Rack::Ketai::Position" do
|
5
|
+
|
6
|
+
describe "生成する際" do
|
7
|
+
it "lat,lngをFloatで与えることができること" do
|
8
|
+
position = Rack::Ketai::Position.new(:lat => 35.009888888889,
|
9
|
+
:lng => 135.69322222222)
|
10
|
+
format("%.10f", position.lat).should == "35.0098888889"
|
11
|
+
format("%.10f", position.lng).should == "135.6932222222"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "lat,lngを度分秒の配列で与えることができること" do
|
15
|
+
position = Rack::Ketai::Position.new(:lat => [35, 0 ,35.6],
|
16
|
+
:lng => [135, 41, 35.6])
|
17
|
+
format("%.10f", position.lat).should == "35.0098888889"
|
18
|
+
format("%.10f", position.lng).should == "135.6932222222"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "lat,lngを度分秒の文字列" do
|
22
|
+
position = Rack::Ketai::Position.new(:lat => "35.00.35.600",
|
23
|
+
:lng => "135.41.35.600")
|
24
|
+
format("%.10f", position.lat).should == "35.0098888889"
|
25
|
+
format("%.10f", position.lng).should == "135.6932222222"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "パラメータを取得する際" do
|
30
|
+
before(:each) do
|
31
|
+
@position = Rack::Ketai::Position.new(:lat => 35.009888888889,
|
32
|
+
:lng => 135.69322222222)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "#lat, #lng 引数無しの時はwgs84" do
|
36
|
+
format("%.10f", @position.lat).should == "35.0098888889"
|
37
|
+
format("%.10f", @position.lng).should == "135.6932222222"
|
38
|
+
end
|
39
|
+
|
40
|
+
it "#lat, #lng 引数で測地系を指定" do
|
41
|
+
format("%.10f", @position.lat(:wgs84)).should == "35.0098888889"
|
42
|
+
format("%.10f", @position.lng(:wgs84)).should == "135.6932222222"
|
43
|
+
|
44
|
+
format("%.10f", @position.lat(:tokyo97)).should == "35.0066762382"
|
45
|
+
format("%.10f", @position.lng(:tokyo97)).should == "135.6960795432"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright (c) 2006 Yoji Shidara
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# =測地系変換モジュール
|
3
|
+
#
|
4
|
+
# 参考文献:
|
5
|
+
# 飛田幹男, 世界測地系と座標変換--21世紀の測量士・位置情報ユーザ・プログラマーのために,
|
6
|
+
# 日本測量協会, 2002.
|
7
|
+
|
8
|
+
module DatumConv
|
9
|
+
GRS80 = [ 6378137, 298.257222101]
|
10
|
+
Bessel = [6377397.155, 299.152813]
|
11
|
+
Tokyo97toITRF94 = [-146.414, 507.337, 680.507]
|
12
|
+
ITRF94toTokyo97 = [ 146.414,-507.337,-680.507]
|
13
|
+
Deg2Rad = Math::PI/180
|
14
|
+
|
15
|
+
# 緯度(度),経度(度),高度(m)を三次元直交座標(m)に変換する。
|
16
|
+
def self.blh2xyz(b_deg,l_deg,he,datum)
|
17
|
+
a = datum[0].to_f
|
18
|
+
f = 1.0/datum[1]
|
19
|
+
b = b_deg * Deg2Rad
|
20
|
+
l = l_deg * Deg2Rad
|
21
|
+
|
22
|
+
e2 = f * (2 - f)
|
23
|
+
n = a / Math.sqrt(1 - e2 * Math.sin(b)**2 )
|
24
|
+
|
25
|
+
x = (n+he)*Math.cos(b)*Math.cos(l)
|
26
|
+
y = (n+he)*Math.cos(b)*Math.sin(l)
|
27
|
+
z = (n*(1-e2)+he)*Math.sin(b)
|
28
|
+
return x,y,z
|
29
|
+
end
|
30
|
+
|
31
|
+
# 三次元直交座標(m)を緯度(度),経度(度),高度(m)に変換する。
|
32
|
+
def self.xyz2blh(x,y,z,datum)
|
33
|
+
a = datum[0].to_f
|
34
|
+
f = 1.0/datum[1]
|
35
|
+
e2 = f * (2 - f)
|
36
|
+
l = Math.atan2(y,x)
|
37
|
+
|
38
|
+
p = Math.sqrt(x**2+y**2)
|
39
|
+
r = Math.sqrt(p**2+z**2)
|
40
|
+
u = Math.atan2(z*((1-f)+e2*a/r),p)
|
41
|
+
b = Math.atan2(z*(1-f)+e2*a*Math.sin(u)**3,(1-f)*(p-e2*a*Math.cos(u)**3))
|
42
|
+
|
43
|
+
he = p*Math.cos(b) + z*Math.sin(b) - a*Math.sqrt(1-e2*Math.sin(b)**2)
|
44
|
+
|
45
|
+
b_deg = b / Deg2Rad
|
46
|
+
l_deg = l / Deg2Rad
|
47
|
+
return b_deg,l_deg,he
|
48
|
+
end
|
49
|
+
|
50
|
+
# 三次元直交座標でシフトする。
|
51
|
+
def self.xyz2xyz(x,y,z,d)
|
52
|
+
return x+d[0],y+d[1],z+d[2]
|
53
|
+
end
|
54
|
+
|
55
|
+
# 日本測地系から世界測地系に変換する。
|
56
|
+
def self.tky2jgd(b,l,he=0)
|
57
|
+
x,y,z = blh2xyz(b,l,he,Bessel)
|
58
|
+
x,y,z = xyz2xyz(x,y,z,Tokyo97toITRF94)
|
59
|
+
b,l,he = xyz2blh(x,y,z,GRS80)
|
60
|
+
return b,l,he
|
61
|
+
end
|
62
|
+
|
63
|
+
# 世界測地系から日本測地系に変換する。
|
64
|
+
def self.jgd2tky(b,l,he=0)
|
65
|
+
x,y,z = blh2xyz(b,l,he,GRS80)
|
66
|
+
x,y,z = xyz2xyz(x,y,z,ITRF94toTokyo97)
|
67
|
+
b,l,he = xyz2blh(x,y,z,Bessel)
|
68
|
+
return b,l,he
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-ketai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 25
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
8
|
+
- 2
|
9
|
+
version: 0.1.2
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Yuichi Takeuchi
|
@@ -15,7 +14,7 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-09-
|
17
|
+
date: 2010-09-13 00:00:00 +09:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
@@ -26,7 +25,6 @@ dependencies:
|
|
26
25
|
requirements:
|
27
26
|
- - ">="
|
28
27
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 23
|
30
28
|
segments:
|
31
29
|
- 1
|
32
30
|
- 0
|
@@ -70,6 +68,7 @@ files:
|
|
70
68
|
- lib/rack/ketai/carrier/specs/softbank.rb
|
71
69
|
- lib/rack/ketai/display.rb
|
72
70
|
- lib/rack/ketai/middleware.rb
|
71
|
+
- lib/rack/ketai/position.rb
|
73
72
|
- rack-ketai.gemspec
|
74
73
|
- spec/spec_helper.rb
|
75
74
|
- spec/unit/au_filter_spec.rb
|
@@ -80,14 +79,18 @@ files:
|
|
80
79
|
- spec/unit/docomo_spec.rb
|
81
80
|
- spec/unit/emoticon_filter_spec.rb
|
82
81
|
- spec/unit/filter_spec.rb
|
82
|
+
- spec/unit/gps_spec.rb
|
83
83
|
- spec/unit/iphone_spec.rb
|
84
84
|
- spec/unit/middleware_spec.rb
|
85
|
+
- spec/unit/position_spec.rb
|
85
86
|
- spec/unit/softbank_filter_spec.rb
|
86
87
|
- spec/unit/softbank_spec.rb
|
87
88
|
- spec/unit/valid_addr_spec.rb
|
88
89
|
- test/spec_runner.rb
|
89
90
|
- tools/generate_emoji_dic.rb
|
90
91
|
- tools/update_speclist.rb
|
92
|
+
- vendor/datum_conv/MIT-LICENSE
|
93
|
+
- vendor/datum_conv/lib/datum_conv.rb
|
91
94
|
has_rdoc: true
|
92
95
|
homepage: http://github.com/take-yu/rack-ketai
|
93
96
|
licenses: []
|
@@ -102,7 +105,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
105
|
requirements:
|
103
106
|
- - ">="
|
104
107
|
- !ruby/object:Gem::Version
|
105
|
-
hash: 3
|
106
108
|
segments:
|
107
109
|
- 0
|
108
110
|
version: "0"
|
@@ -111,7 +113,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
113
|
requirements:
|
112
114
|
- - ">="
|
113
115
|
- !ruby/object:Gem::Version
|
114
|
-
hash: 3
|
115
116
|
segments:
|
116
117
|
- 0
|
117
118
|
version: "0"
|
@@ -127,7 +128,9 @@ test_files:
|
|
127
128
|
- spec/unit/middleware_spec.rb
|
128
129
|
- spec/unit/filter_spec.rb
|
129
130
|
- spec/unit/au_filter_spec.rb
|
131
|
+
- spec/unit/gps_spec.rb
|
130
132
|
- spec/unit/softbank_filter_spec.rb
|
133
|
+
- spec/unit/position_spec.rb
|
131
134
|
- spec/unit/valid_addr_spec.rb
|
132
135
|
- spec/unit/docomo_spec.rb
|
133
136
|
- spec/unit/display_spec.rb
|