X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/2b1bac1279e268c8e5fcca34c950f30d2c06ec1c..e6d7da3a629c952a5d27f4d356dd4d5c4293848a:/app/models/way.rb diff --git a/app/models/way.rb b/app/models/way.rb index 3284c47f3..ca6829df4 100644 --- a/app/models/way.rb +++ b/app/models/way.rb @@ -17,7 +17,7 @@ # current_ways_changeset_id_fkey (changeset_id => changesets.id) # -class Way < ActiveRecord::Base +class Way < ApplicationRecord require "xml/libxml" include ConsistencyValidations @@ -55,11 +55,13 @@ class Way < ActiveRecord::Base def self.from_xml(xml, create = false) p = XML::Parser.string(xml, :options => XML::Parser::Options::NOERROR) doc = p.parse + pt = doc.find_first("//osm/way") - doc.find("//osm/way").each do |pt| - return Way.from_xml_node(pt, create) + if pt + Way.from_xml_node(pt, create) + else + raise OSM::APIBadXMLError.new("node", xml, "XML doesn't contain an osm/way element.") 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 @@ -114,9 +116,7 @@ class Way < ActiveRecord::Base @tags ||= Hash[way_tags.collect { |t| [t.k, t.v] }] end - attr_writer :nds - - attr_writer :tags + attr_writer :nds, :tags def add_nd_num(n) @nds ||= []