Class: KML::Point

Inherits:
Object
  • Object
show all
Defined in:
lib/gpx_kml/kml/point.rb

Overview

Docu

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(coord, father, node) ⇒ Point

Returns a new instance of Point.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# 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

Instance Attribute Details

#authorObject (readonly)

Returns the value of attribute author.



31
32
33
# File 'lib/gpx_kml/kml/point.rb', line 31

def author
  @author
end

#elevationObject (readonly)

Returns the value of attribute elevation.



31
32
33
# File 'lib/gpx_kml/kml/point.rb', line 31

def elevation
  @elevation
end

#fatherObject (readonly)

Returns the value of attribute father.



31
32
33
# File 'lib/gpx_kml/kml/point.rb', line 31

def father
  @father
end

#latitudeObject (readonly)

Returns the value of attribute latitude.



31
32
33
# File 'lib/gpx_kml/kml/point.rb', line 31

def latitude
  @latitude
end

Returns the value of attribute link.



31
32
33
# File 'lib/gpx_kml/kml/point.rb', line 31

def link
  @link
end

#longitudeObject (readonly)

Returns the value of attribute longitude.



31
32
33
# File 'lib/gpx_kml/kml/point.rb', line 31

def longitude
  @longitude
end

#nameObject (readonly)

Returns the value of attribute name.



31
32
33
# File 'lib/gpx_kml/kml/point.rb', line 31

def name
  @name
end