Class: V900Waypoint
- Inherits:
-
Object
- Object
- V900Waypoint
- Defined in:
- lib/columbus3/v900track/v900waypoint.rb
Overview
a facade which presents a CSV::row as a v900 waypoint
Instance Method Summary collapse
- #heading ⇒ Object
- #height ⇒ Object
- #index ⇒ Object
-
#initialize(row) ⇒ V900Waypoint
constructor
A new instance of V900Waypoint.
- #lat ⇒ Object
-
#lat_lon ⇒ Object
return an array with lat and lon: [lat, lon].
- #lon ⇒ Object
-
#lon_lat ⇒ Object
…
- #speed ⇒ Object
- #tag ⇒ Object
- #time ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(row) ⇒ V900Waypoint
Returns a new instance of V900Waypoint.
5 6 7 |
# File 'lib/columbus3/v900track/v900waypoint.rb', line 5 def initialize row @row = row end |
Instance Method Details
#heading ⇒ Object
53 54 55 |
# File 'lib/columbus3/v900track/v900waypoint.rb', line 53 def heading @row["HEADING"].to_i end |
#height ⇒ Object
45 46 47 |
# File 'lib/columbus3/v900track/v900waypoint.rb', line 45 def height @row["HEIGHT"].to_i end |
#index ⇒ Object
9 10 11 |
# File 'lib/columbus3/v900track/v900waypoint.rb', line 9 def index @row["INDEX"].to_i end |
#lat ⇒ Object
30 31 32 33 |
# File 'lib/columbus3/v900track/v900waypoint.rb', line 30 def lat value = @row["LATITUDE N/S"] value.match(/(N|E)/) ? value[0..-2].to_f : -1 * value[0..-2].to_f end |
#lat_lon ⇒ Object
return an array with lat and lon: [lat, lon]
36 37 38 |
# File 'lib/columbus3/v900track/v900waypoint.rb', line 36 def lat_lon [lat, lon] end |
#lon ⇒ Object
25 26 27 28 |
# File 'lib/columbus3/v900track/v900waypoint.rb', line 25 def lon value = @row["LONGITUDE E/W"] value.match(/(N|E)/) ? value[0..-2].to_f : -1 * value[0..-2].to_f end |
#lon_lat ⇒ Object
… and since many prefer the other way around ..
41 42 43 |
# File 'lib/columbus3/v900track/v900waypoint.rb', line 41 def lon_lat [lon, lat] end |
#speed ⇒ Object
49 50 51 |
# File 'lib/columbus3/v900track/v900waypoint.rb', line 49 def speed @row["SPEED"].to_i end |
#tag ⇒ Object
13 14 15 |
# File 'lib/columbus3/v900track/v900waypoint.rb', line 13 def tag @row["TAG"] end |
#time ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/columbus3/v900track/v900waypoint.rb', line 17 def time date = @row["DATE"] time = @row["TIME"] # make sure it is understood as ZULU time (UTC) and pad time to six numbers 75858 -> 075858 # http://stackoverflow.com/questions/1543171/how-can-i-output-leading-zeros-in-ruby Time.parse("#{date}T" + time.to_s.rjust(6, "0") + "Z") end |
#to_s ⇒ Object
57 58 59 |
# File 'lib/columbus3/v900track/v900waypoint.rb', line 57 def to_s "#{@row["INDEX"]},T,#{@row["DATE"]},#{@row["TIME"]},#{@row["LATITUDE N/S"]},#{@row["LONGITUDE E/W"]},#{@row["HEIGHT"]},#{@row["SPEED"]},#{@row["HEADING"]},0" end |