class ComtecDR::GpsLog

Public Class Methods

new(lat, lat_s, lon, lon_s, speed, jst, msec, x_a, y_a, z_a, filename) click to toggle source
# File lib/comtec-dr/gps_log.rb, line 3
def initialize lat, lat_s, lon, lon_s, speed, jst, msec, x_a, y_a, z_a, filename
  @lat      = lat
  @lat_sign = lat_s
  @lon      = lon
  @lon_sign = lon_s
  @speed = speed
  @jst   = jst
  @msec  = msec
  @x_acceleration = x_a
  @y_acceleration = y_a
  @z_acceleration = z_a
  @filename = filename
end

Public Instance Methods

csv_line() click to toggle source
# File lib/comtec-dr/gps_log.rb, line 49
def csv_line
  [lat, lon, speed, jst, msec, x_acceleration, y_acceleration, z_acceleration, @filename]
end
jst() click to toggle source
# File lib/comtec-dr/gps_log.rb, line 29
def jst
  Time.parse "20#{@jst}}+0900"
end
lat() click to toggle source
# File lib/comtec-dr/gps_log.rb, line 17
def lat
  (dmm_to_dms(@lat) * (@lat_sign == 'N' ? 1 : -1)).to_f
end
lon() click to toggle source
# File lib/comtec-dr/gps_log.rb, line 21
def lon
  (dmm_to_dms(@lon) * (@lon_sign == 'E' ? 1 : -1)).to_f
end
msec() click to toggle source
# File lib/comtec-dr/gps_log.rb, line 33
def msec
  @msec.to_i
end
speed() click to toggle source
# File lib/comtec-dr/gps_log.rb, line 25
def speed
  @speed.to_i
end
x_acceleration() click to toggle source
# File lib/comtec-dr/gps_log.rb, line 37
def x_acceleration
  @x_acceleration.to_f/1000
end
y_acceleration() click to toggle source
# File lib/comtec-dr/gps_log.rb, line 41
def y_acceleration
  @y_acceleration.to_f/1000
end
z_acceleration() click to toggle source
# File lib/comtec-dr/gps_log.rb, line 45
def z_acceleration
  @z_acceleration.to_f/1000
end

Private Instance Methods

dmm_to_dms(str) click to toggle source

DMM形式から変換

# File lib/comtec-dr/gps_log.rb, line 55
def dmm_to_dms str
  number, fractional = str.split('.')
  number[0...-2].to_r + "#{number[-2..-1]}.#{fractional}".to_r / 60
end