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

- (Position) initialize

Returns a new instance of Position



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

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

Instance Attribute Details

- (Object) lat

緯度



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

def lat
  @lat
end

- (Object) lon

経度



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

def lon
  @lon
end

- (Object) options

その他の情報



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

def options
  @options
end

Class Method Details

+ (Object) acts_as_mappable



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

def self.acts_as_mappable; end

+ (Object) distance_column_name



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

def self.distance_column_name; end

+ (Object) dms2deg(d, m, s)

度分秒を度に変換する。



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

+ (Object) lat_column_name



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

def self.lat_column_name; :lat; end

+ (Object) lng_column_name



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

def self.lng_column_name; :lng; end

Instance Method Details

- (Object) ==(x)

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



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

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

- (Object) ll

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



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

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

- (Object) lng

経度



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

def lng
  lon
end

- (Object) lng=(l)

経度を設定



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

def lng=(l)
  lon = l
end

- (Object) to_s

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



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

- (Object) tokyo2wgs84!

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



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

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