Class: Jpmobile::Position

Inherits:
Object
  • Object
show all
Includes:
GeoKit::Mappable
Defined in:
lib/jpmobile/position.rb

Overview

位置情報

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePosition



22
23
24
25
26
# File 'lib/jpmobile/position.rb', line 22

def initialize
  @lat = nil
  @lon = nil
  @options = {}
end

Instance Attribute Details

#latObject

緯度



46
47
48
# File 'lib/jpmobile/position.rb', line 46

def lat
  @lat
end

#lonObject

経度



49
50
51
# File 'lib/jpmobile/position.rb', line 49

def lon
  @lon
end

#optionsObject

その他の情報



67
68
69
# File 'lib/jpmobile/position.rb', line 67

def options
  @options
end

Class Method Details

.acts_as_mappableObject



17
# File 'lib/jpmobile/position.rb', line 17

def self.acts_as_mappable; end

.distance_column_nameObject



18
# File 'lib/jpmobile/position.rb', line 18

def self.distance_column_name; end

.dms2deg(d, m, s) ⇒ Object

度分秒を度に変換する。



28
29
30
# File 'lib/jpmobile/position.rb', line 28

def self.dms2deg(d,m,s)
  return d.to_i + m.to_i.to_f/60 + s.to_f/3600
end

.lat_column_nameObject



19
# File 'lib/jpmobile/position.rb', line 19

def self.lat_column_name; :lat; end

.lng_column_nameObject



20
# File 'lib/jpmobile/position.rb', line 20

def self.lng_column_name; :lng; end

Instance Method Details

#==(x) ⇒ Object

緯度と経度が一致している場合に true



62
63
64
# File 'lib/jpmobile/position.rb', line 62

def ==(x)
  x.lat == lat && x.lon == lon
end

#llObject

緯度経度をカンマ区切りで返す



41
42
43
# File 'lib/jpmobile/position.rb', line 41

def ll
  "#{lat},#{lng}"
end

#lngObject

経度



52
53
54
# File 'lib/jpmobile/position.rb', line 52

def lng
  lon
end

#lng=(l) ⇒ Object

経度を設定



57
58
59
# File 'lib/jpmobile/position.rb', line 57

def lng=(l)
  lon = l
end

#to_sObject

文字列で緯度経度を返す。



36
37
38
# File 'lib/jpmobile/position.rb', line 36

def to_s
  sprintf("%s%f%s%f", @lat>0 ? 'N' : 'S', @lat, @lon>0 ? 'E' : 'W', @lon)
end

#tokyo2wgs84!Object

日本測地系から世界測地系に変換する。



32
33
34
# File 'lib/jpmobile/position.rb', line 32

def tokyo2wgs84!
  @lat, @lon = DatumConv.tky2jgd(@lat,@lon)
end