Class: Rozi::WaypointWriter
- Inherits:
-
Object
- Object
- Rozi::WaypointWriter
- Includes:
- OziFunctions
- Defined in:
- lib/rozi/waypoint_writer.rb
Overview
This class writes a list of waypoints to a “.wpt” file that can be opened by Ozi Explorer.
Instance Method Summary collapse
Methods included from OziFunctions
#datum_valid?, #escape_text, #interpret_color
Instance Method Details
#waypoint_to_text(waypoint) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/rozi/waypoint_writer.rb', line 28 def waypoint_to_text(waypoint) wpt = waypoint.to_a() wpt.map! { |item| item.is_a?(String) ? escape_text(item) : item } wpt.map! { |item| item.nil? ? "" : item } wpt.map! { |item| item.is_a?(Float) ? item.round(6) : item } "%d,%s,%f,%f,%s,%d,1,%d,%d,%d,%s,%d,,,%d,%d,%d,%d" % wpt end |
#write(waypoints, file) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rozi/waypoint_writer.rb', line 14 def write(waypoints, file) file.write <<-TEXT.gsub(/^[ ]{8}/, "") OziExplorer Waypoint File Version 1.1 WGS 84 Reserved 2 TEXT waypoints.each { |wpt| file.write(waypoint_to_text(wpt)) file.write("\n") } end |