Class: TF1Converter::Gpx::Waypoint

Inherits:
Object
  • Object
show all
Defined in:
lib/tf1_converter/gpx/waypoint.rb

Instance Method Summary collapse

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

#elevationObject



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_meaningObject



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_nameObject



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

#latObject



38
39
40
# File 'lib/tf1_converter/gpx/waypoint.rb', line 38

def lat
  @node.attribute('lat').value
end

#longObject



42
43
44
# File 'lib/tf1_converter/gpx/waypoint.rb', line 42

def long
  @node.attribute('lon').value
end

#nameObject



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

#timestampObject



34
35
36
# File 'lib/tf1_converter/gpx/waypoint.rb', line 34

def timestamp
  @node.children.select{ |child| child.name == 'cmt' }.first.text
end

#usngObject



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

#utmObject



55
56
57
# File 'lib/tf1_converter/gpx/waypoint.rb', line 55

def utm
  utm_object.to_s
end