Sha256: f570b513d53f385c142d1c9bec17e31330cac482f717affcd20bb44194a94ce9
Contents?: true
Size: 1.22 KB
Versions: 3
Compression:
Stored size: 1.22 KB
Contents
require 'time' # a facade which presents a CSV::row as a v900 waypoint class V900Waypoint def initialize row @row = row end def index @row["INDEX"].to_i end def tag @row["TAG"] end 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 def lon value = @row["LONGITUDE E/W"] value.match(/(N|E)/) ? value[0..-2].to_f : -1 * value[0..-2].to_f end def lat value = @row["LATITUDE N/S"] value.match(/(N|E)/) ? value[0..-2].to_f : -1 * value[0..-2].to_f end # return an array with lat and lon: [lat, lon] def lat_lon [lat, lon] end # ... and since many prefer the other way around .. def lon_lat [lon, lat] end def height @row["HEIGHT"].to_i end def speed @row["SPEED"].to_i end def heading @row["HEADING"].to_i end 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 end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
columbus3-0.5.1 | lib/columbus3/v900track/v900waypoint.rb |
columbus3-0.6.0 | lib/columbus3/v900track/v900waypoint.rb |
columbus3-0.5.0 | lib/columbus3/v900track/v900waypoint.rb |