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



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

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

Instance Attribute Details

#latObject

緯度



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

def lat
  @lat
end

#lonObject

経度



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

def lon
  @lon
end

#optionsObject

その他の情報



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

def options
  @options
end

Class Method Details

.acts_as_mappableObject



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

def self.acts_as_mappable; end

.distance_column_nameObject



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

def self.distance_column_name; end

.dms2deg(d, m, s) ⇒ Object

度分秒を度に変換する。



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

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

.lat_column_nameObject



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

def self.lat_column_name; :lat; end

.lng_column_nameObject



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

def self.lng_column_name; :lng; end

Instance Method Details

#==(x) ⇒ Object

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



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

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

#llObject

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



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

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

#lngObject

経度



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

def lng
  lon
end

#lng=(l) ⇒ Object

経度を設定



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

def lng=(l)
  lon = l
end

#to_sObject

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



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

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

#tokyo2wgs84!Object

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



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

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