+ has_many :containing_relation_members, :class_name => "RelationMember", :as => :member
+ has_many :containing_relations, :class_name => "Relation", :through => :containing_relation_members, :source => :relation
+
+ validates :id, :uniqueness => true, :presence => { :on => :update },
+ :numericality => { :on => :update, :only_integer => true }
+ validates :version, :presence => true,
+ :numericality => { :only_integer => true }
+ validates :changeset_id, :presence => true,
+ :numericality => { :only_integer => true }
+ validates :timestamp, :presence => true
+ validates :changeset, :associated => true
+ validates :visible, :inclusion => [true, false]
+
+ scope :visible, -> { where(:visible => true) }
+ scope :invisible, -> { where(:visible => false) }
+
+ # Read in xml as text and return it's Way object representation
+ def self.from_xml(xml, create = false)
+ p = XML::Parser.string(xml, :options => XML::Parser::Options::NOERROR)
+ doc = p.parse
+
+ doc.find("//osm/way").each do |pt|
+ return Way.from_xml_node(pt, create)
+ end
+ raise OSM::APIBadXMLError.new("node", xml, "XML doesn't contain an osm/way element.")
+ rescue LibXML::XML::Error, ArgumentError => e
+ raise OSM::APIBadXMLError.new("way", xml, e.message)
+ end