]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/way.rb
Update annotations to correctly show bigint types
[rails.git] / app / models / way.rb
index 2d149863e359b12cad01bf22315a5e658ef216b9..6fcaf39cc7c021801adc22e054820834430b7353 100644 (file)
@@ -2,11 +2,11 @@
 #
 # Table name: current_ways
 #
-#  id           :integer          not null, primary key
-#  changeset_id :integer          not null
+#  id           :bigint(8)        not null, primary key
+#  changeset_id :bigint(8)        not null
 #  timestamp    :datetime         not null
 #  visible      :boolean          not null
-#  version      :integer          not null
+#  version      :bigint(8)        not null
 #
 # Indexes
 #
@@ -60,8 +60,8 @@ class Way < ActiveRecord::Base
       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 => ex
-    raise OSM::APIBadXMLError.new("way", xml, ex.message)
+  rescue LibXML::XML::Error, ArgumentError => e
+    raise OSM::APIBadXMLError.new("way", xml, e.message)
   end
 
   def self.from_xml_node(pt, create = false)
@@ -206,7 +206,7 @@ class Way < ActiveRecord::Base
 
   def preconditions_ok?(old_nodes = [])
     return false if nds.empty?
-    raise OSM::APITooManyWayNodesError.new(id, nds.length, MAX_NUMBER_OF_WAY_NODES) if nds.length > MAX_NUMBER_OF_WAY_NODES
+    raise OSM::APITooManyWayNodesError.new(id, nds.length, Settings.max_number_of_way_nodes) if nds.length > Settings.max_number_of_way_nodes
 
     # check only the new nodes, for efficiency - old nodes having been checked last time and can't
     # be deleted when they're in-use.
@@ -254,7 +254,7 @@ class Way < ActiveRecord::Base
   # to IDs +id_map+.
   def fix_placeholders!(id_map, placeholder_id = nil)
     nds.map! do |node_id|
-      if node_id < 0
+      if node_id.negative?
         new_id = id_map[:node][node_id]
         raise OSM::APIBadUserInput, "Placeholder node not found for reference #{node_id} in way #{id.nil? ? placeholder_id : id}" if new_id.nil?