class KML::Point
Docu
Attributes
elevation[R]
father[R]
latitude[R]
link[R]
longitude[R]
name[R]
Public Class Methods
new(coord, father, node)
click to toggle source
# File lib/gpx_kml/kml/point.rb, line 11 def initialize(coord, father, node) re = Regexp.new('^ ?[0-9]+\.[0-9]+,[0-9]+\.[0-9]+(,[0-9]+\.[0-9]+)? ?$') return unless valid_father?(father) && re.match?(coord) && node.is_a?(Nokogiri::XML::Element) return if node.xpath('self::*[self::xmlns:LineString or self::xmlns:Point or self::xmlns:LinearRing]').empty? @father = father coord = coord.split(',') @longitude = coord[0] @latitude = coord[1] @elevation = coord[2] if coord.length == 3 @node = node # Name is looked up in the ancestor of the node that compose this point @name = _name return if node.xpath('self::xmlns:Point').empty? @author = _author @link = _link end
Private Instance Methods
_link()
click to toggle source
# File lib/gpx_kml/kml/point.rb, line 54 def _link elem = @node.xpath('.') while elem.xpath('self::xmlns:kml').empty? elem = elem.xpath('..') return elem.xpath('./atom:link/@href').to_s unless elem.xpath('./atom:link').empty? end '' end
_name()
click to toggle source
# File lib/gpx_kml/kml/point.rb, line 35 def _name elem = @node.xpath('.') while elem.xpath('self::xmlns:kml').empty? return elem.xpath('./xmlns:name/text()').to_s unless elem.xpath('./xmlns:name').empty? elem = elem.xpath('..') end '' end
valid_father?(father)
click to toggle source
# File lib/gpx_kml/kml/point.rb, line 63 def valid_father?(father) father.is_a?(KML::Track) || father.is_a?(KML::Kml) || father.is_a?(KML::Route) end