Class: TF1Converter::Gpx::Waypoint
- Inherits:
-
Object
- Object
- TF1Converter::Gpx::Waypoint
- Defined in:
- lib/tf1_converter/gpx/waypoint.rb
Instance Method Summary collapse
- #elevation ⇒ Object
- #icon_meaning ⇒ Object
- #icon_name ⇒ Object
-
#initialize(xml_node, icon_map = TF1Converter::Config.icons) ⇒ Waypoint
constructor
A new instance of Waypoint.
- #lat ⇒ Object
- #long ⇒ Object
- #name ⇒ Object
- #timestamp ⇒ Object
- #usng ⇒ Object
- #utm ⇒ Object
Constructor Details
#initialize(xml_node, icon_map = TF1Converter::Config.icons) ⇒ Waypoint
Returns a new instance of Waypoint.
4 5 6 7 |
# File 'lib/tf1_converter/gpx/waypoint.rb', line 4 def initialize(xml_node, icon_map = TF1Converter::Config.icons) @node = xml_node @icon_map = icon_map end |
Instance Method Details
#elevation ⇒ Object
46 47 48 |
# File 'lib/tf1_converter/gpx/waypoint.rb', line 46 def elevation @node.children.select{ |child| child.name == 'ele' }.first.text end |
#icon_meaning ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/tf1_converter/gpx/waypoint.rb', line 26 def icon_meaning if symbol_name map_entry = @icon_map[symbol_name] return map_entry['meaning'] if map_entry end 'Default' end |
#icon_name ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/tf1_converter/gpx/waypoint.rb', line 14 def icon_name if symbol_name map_entry = @icon_map[symbol_name] return map_entry['icon'] if map_entry elsif name @icon_map.values.each do |icon_data| return icon_data['icon'] if icon_data['name'] == name end end 'default.png' end |
#lat ⇒ Object
38 39 40 |
# File 'lib/tf1_converter/gpx/waypoint.rb', line 38 def lat @node.attribute('lat').value end |
#long ⇒ Object
42 43 44 |
# File 'lib/tf1_converter/gpx/waypoint.rb', line 42 def long @node.attribute('lon').value end |
#name ⇒ Object
9 10 11 12 |
# File 'lib/tf1_converter/gpx/waypoint.rb', line 9 def name name_node = @node.xpath('name').first name_node.nil? ? '' : name_node.text end |
#timestamp ⇒ Object
34 35 36 |
# File 'lib/tf1_converter/gpx/waypoint.rb', line 34 def @node.children.select{ |child| child.name == 'cmt' }.first.text end |
#usng ⇒ Object
50 51 52 53 |
# File 'lib/tf1_converter/gpx/waypoint.rb', line 50 def usng u = utm_object GeoSwap.utm_to_usng(u.easting, u.northing, u.zone.number, u.zone.letter) end |
#utm ⇒ Object
55 56 57 |
# File 'lib/tf1_converter/gpx/waypoint.rb', line 55 def utm utm_object.to_s end |