+ @tags ||= Hash[way_tags.collect { |t| [t.k, t.v] }]
+ end
+
+ attr_writer :nds
+
+ attr_writer :tags
+
+ def add_nd_num(n)
+ @nds = [] unless @nds
+ @nds << n.to_i
+ end
+
+ def add_tag_keyval(k, v)
+ @tags = {} unless @tags
+
+ # duplicate tags are now forbidden, so we can't allow values
+ # in the hash to be overwritten.
+ fail OSM::APIDuplicateTagsError.new("way", id, k) if @tags.include? k
+
+ @tags[k] = v
+ end
+
+ ##
+ # the integer coords (i.e: unscaled) bounding box of the way, assuming
+ # straight line segments.
+ def bbox
+ lons = nodes.collect(&:longitude)
+ lats = nodes.collect(&:latitude)
+ BoundingBox.new(lons.min, lats.min, lons.max, lats.max)
+ end
+
+ def update_from(new_way, user)
+ Way.transaction do
+ lock!
+ check_consistency(self, new_way, user)
+ unless new_way.preconditions_ok?(nds)
+ fail OSM::APIPreconditionFailedError.new("Cannot update way #{id}: data is invalid.")
+ end
+
+ self.changeset_id = new_way.changeset_id
+ self.changeset = new_way.changeset
+ self.tags = new_way.tags
+ self.nds = new_way.nds
+ self.visible = true
+ save_with_history!