belongs_to :changeset
has_many :old_ways, -> { order(:version) }
has_many :way_nodes, -> { order(:sequence_id) }
belongs_to :changeset
has_many :old_ways, -> { order(:version) }
has_many :way_nodes, -> { order(:sequence_id) }
- has_many :containing_relations, :class_name => "Relation", :through => :containing_relation_members, :source => :relation, :extend => ObjectFinder
+ has_many :containing_relations, :class_name => "Relation", :through => :containing_relation_members, :source => :relation
validates_presence_of :id, :on => :update
validates_presence_of :changeset_id,:version, :timestamp
validates_presence_of :id, :on => :update
validates_presence_of :changeset_id,:version, :timestamp
validates_associated :changeset
scope :visible, -> { where(:visible => true) }
validates_associated :changeset
scope :visible, -> { where(:visible => true) }
# Read in xml as text and return it's Way object representation
def self.from_xml(xml, create=false)
# Read in xml as text and return it's Way object representation
def self.from_xml(xml, create=false)
# We want to make sure that there is no id with zero anyway
raise OSM::APIBadUserInput.new("ID of way cannot be zero when updating.") if way.id == 0
end
# We don't care about the timestamp nor the visibility as these are either
# We want to make sure that there is no id with zero anyway
raise OSM::APIBadUserInput.new("ID of way cannot be zero when updating.") if way.id == 0
end
# We don't care about the timestamp nor the visibility as these are either
# You can't pull in all the tags too unless we put a sequence_id on the way_tags table and have a multipart key
def self.find_eager(id)
way = Way.find(id, :include => {:way_nodes => :node})
# You can't pull in all the tags too unless we put a sequence_id on the way_tags table and have a multipart key
def self.find_eager(id)
way = Way.find(id, :include => {:way_nodes => :node})
unless new_way.preconditions_ok?(self.nds)
raise OSM::APIPreconditionFailedError.new("Cannot update way #{self.id}: data is invalid.")
end
unless new_way.preconditions_ok?(self.nds)
raise OSM::APIPreconditionFailedError.new("Cannot update way #{self.id}: data is invalid.")
end
# provide repeatable reads for the used-by checks. this means it
# shouldn't be possible to get race conditions.
Way.transaction do
# provide repeatable reads for the used-by checks. this means it
# shouldn't be possible to get race conditions.
Way.transaction do
def fix_placeholders!(id_map, placeholder_id = nil)
self.nds.map! do |node_id|
if node_id < 0
def fix_placeholders!(id_map, placeholder_id = nil)
self.nds.map! do |node_id|
if node_id < 0
- # update the bounding box, note that this has to be done both before
- # and after the save, so that nodes from both versions are included in the
+ # update the bounding box, note that this has to be done both before
+ # and after the save, so that nodes from both versions are included in the