Class: Rosemary::BoundingBox

Inherits:
Element
  • Object
show all
Defined in:
lib/rosemary/bounding_box.rb

Overview

OpenStreetMap Boundary Box.

Instance Attribute Summary collapse

Attributes inherited from Element

#changeset, #id, #tags, #timestamp, #uid, #user, #version

Instance Method Summary collapse

Methods inherited from Element

#<=>, #[], #[]=, #add_tags, #attributes, from_api, from_xml, #get_history_from_api, #get_relations_from_api, #initialize_copy, #is_tagged?, #method_missing, #shape, #update_attributes

Constructor Details

#initialize(attrs = {}) ⇒ BoundingBox

Create new Node object.

If id is nil a new unique negative ID will be allocated.



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rosemary/bounding_box.rb', line 13

def initialize(attrs = {})
  attrs = attrs.dup.stringify_keys!
  @minlat = attrs['minlat'].to_f
  @minlon = attrs['minlon'].to_f
  @maxlat = attrs['maxlat'].to_f
  @maxlon = attrs['maxlon'].to_f

  @nodes = []
  @ways = []
  @relations = []
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Rosemary::Element

Instance Attribute Details

#maxlatObject

Returns the value of attribute maxlat.



8
9
10
# File 'lib/rosemary/bounding_box.rb', line 8

def maxlat
  @maxlat
end

#maxlonObject

Returns the value of attribute maxlon.



8
9
10
# File 'lib/rosemary/bounding_box.rb', line 8

def maxlon
  @maxlon
end

#minlatObject

Returns the value of attribute minlat.



8
9
10
# File 'lib/rosemary/bounding_box.rb', line 8

def minlat
  @minlat
end

#minlonObject

Returns the value of attribute minlon.



8
9
10
# File 'lib/rosemary/bounding_box.rb', line 8

def minlon
  @minlon
end

#nodesObject

Returns the value of attribute nodes.



8
9
10
# File 'lib/rosemary/bounding_box.rb', line 8

def nodes
  @nodes
end

#relationsObject

Returns the value of attribute relations.



8
9
10
# File 'lib/rosemary/bounding_box.rb', line 8

def relations
  @relations
end

#waysObject

Returns the value of attribute ways.



8
9
10
# File 'lib/rosemary/bounding_box.rb', line 8

def ways
  @ways
end

Instance Method Details

#attribute_listObject

List of attributes for a bounds element



31
32
33
# File 'lib/rosemary/bounding_box.rb', line 31

def attribute_list
  [:minlat, :minlon, :maxlat, :maxlon]
end

#to_xml(options = {}) ⇒ Object



35
36
37
38
39
40
41
42
43
44
# File 'lib/rosemary/bounding_box.rb', line 35

def to_xml(options = {})
  xml = options[:builder] ||= Builder::XmlMarkup.new
  xml.instruct! unless options[:skip_instruct]
  xml.osm(:generator => "rosemary v#{Rosemary::VERSION}", :version => Rosemary::Api::API_VERSION) do
    xml.bounds(attributes)
    [ nodes, ways, relations].each do |elements|
      elements.each { |e| e.to_xml(:builder => xml, :skip_instruct => true) }
    end
  end
end

#typeObject



26
27
28
# File 'lib/rosemary/bounding_box.rb', line 26

def type
  'BoundingBoxBox'
end