end
def test_upload_large_changeset
- auth_header = basic_authorization_header create(:user).email, "test"
+ user = create(:user)
+ auth_header = basic_authorization_header user.email, "test"
+
+ # create an old changeset to ensure we have the maximum rate limit
+ create(:changeset, :user => user, :created_at => Time.now.utc - 28.days)
# create a changeset
put changeset_create_path, :params => "<osm><changeset/></osm>", :headers => auth_header
diff = <<~CHANGESET
<osmChange>
<modify>
- <node id='#{node.id}' lon='0' lat='0' changeset='#{changeset.id}' version='1'/>
- <node id='#{node.id}' lon='1' lat='0' changeset='#{changeset.id}' version='2'/>
- <node id='#{node.id}' lon='1' lat='1' changeset='#{changeset.id}' version='3'/>
- <node id='#{node.id}' lon='1' lat='2' changeset='#{changeset.id}' version='4'/>
- <node id='#{node.id}' lon='2' lat='2' changeset='#{changeset.id}' version='5'/>
- <node id='#{node.id}' lon='3' lat='2' changeset='#{changeset.id}' version='6'/>
- <node id='#{node.id}' lon='3' lat='3' changeset='#{changeset.id}' version='7'/>
- <node id='#{node.id}' lon='9' lat='9' changeset='#{changeset.id}' version='8'/>
+ <node id='#{node.id}' lon='0.0' lat='0.0' changeset='#{changeset.id}' version='1'/>
+ <node id='#{node.id}' lon='0.1' lat='0.0' changeset='#{changeset.id}' version='2'/>
+ <node id='#{node.id}' lon='0.1' lat='0.1' changeset='#{changeset.id}' version='3'/>
+ <node id='#{node.id}' lon='0.1' lat='0.2' changeset='#{changeset.id}' version='4'/>
+ <node id='#{node.id}' lon='0.2' lat='0.2' changeset='#{changeset.id}' version='5'/>
+ <node id='#{node.id}' lon='0.3' lat='0.2' changeset='#{changeset.id}' version='6'/>
+ <node id='#{node.id}' lon='0.3' lat='0.3' changeset='#{changeset.id}' version='7'/>
+ <node id='#{node.id}' lon='0.9' lat='0.9' changeset='#{changeset.id}' version='8'/>
</modify>
</osmChange>
CHANGESET
diff = <<~CHANGESET
<osmChange>
<create>
- <node id="-1" lon="0" lat="0" changeset="#{changeset.id}" version="1"/>
- <node id="-2" lon="1" lat="1" changeset="#{changeset.id}" version="1"/>
- <node id="-3" lon="2" lat="2" changeset="#{changeset.id}" version="1"/>
+ <node id="-1" lon="0.0" lat="0.0" changeset="#{changeset.id}" version="1"/>
+ <node id="-2" lon="0.1" lat="0.1" changeset="#{changeset.id}" version="1"/>
+ <node id="-3" lon="0.2" lat="0.2" changeset="#{changeset.id}" version="1"/>
<way id="-1" changeset="#{changeset.id}" version="1">
<nd ref="-1"/>
<nd ref="-2"/>
diff = <<~CHANGESET
<osmChange>
<create>
- <node id="-1" lon="0" lat="0" changeset="#{changeset.id}" version="1"/>
- <node id="-2" lon="1" lat="1" changeset="#{changeset.id}" version="1"/>
- <node id="-3" lon="2" lat="2" changeset="#{changeset.id}" version="1"/>
+ <node id="-1" lon="0.0" lat="0.0" changeset="#{changeset.id}" version="1"/>
+ <node id="-2" lon="0.1" lat="0.1" changeset="#{changeset.id}" version="1"/>
+ <node id="-3" lon="0.2" lat="0.2" changeset="#{changeset.id}" version="1"/>
<way id="#{way.id}" changeset="#{changeset.id}" version="1">
<nd ref="-1"/>
<nd ref="-2"/>
diff = <<~CHANGESET
<osmChange>
<create>
- <node id="-1" lon="0" lat="0" changeset="#{changeset.id}" version="1"/>
- <node id="-2" lon="1" lat="1" changeset="#{changeset.id}" version="1"/>
- <node id="-3" lon="2" lat="2" changeset="#{changeset.id}" version="1"/>
+ <node id="-1" lon="0.0" lat="0.0" changeset="#{changeset.id}" version="1"/>
+ <node id="-2" lon="0.1" lat="0.1" changeset="#{changeset.id}" version="1"/>
+ <node id="-3" lon="0.2" lat="0.2" changeset="#{changeset.id}" version="1"/>
<relation id="-1" changeset="#{changeset.id}" version="1">
<member type="node" role="foo" ref="-1"/>
<member type="node" role="foo" ref="-2"/>
diff = <<~CHANGESET
<osmChange>
<create>
- <node id="-1" lon="0" lat="0" changeset="#{changeset.id}" version="1"/>
- <node id="-2" lon="1" lat="1" changeset="#{changeset.id}" version="1"/>
- <node id="-3" lon="2" lat="2" changeset="#{changeset.id}" version="1"/>
+ <node id="-1" lon="0.0" lat="0.0" changeset="#{changeset.id}" version="1"/>
+ <node id="-2" lon="0.1" lat="0.1" changeset="#{changeset.id}" version="1"/>
+ <node id="-3" lon="0.2" lat="0.2" changeset="#{changeset.id}" version="1"/>
<relation id="#{relation.id}" changeset="#{changeset.id}" version="1">
<member type="node" role="foo" ref="-1"/>
<member type="node" role="foo" ref="-2"/>
changeset_id = @response.body.to_i
old_way = create(:way)
- create(:way_node, :way => old_way, :node => create(:node, :lat => 1, :lon => 1))
+ create(:way_node, :way => old_way, :node => create(:node, :lat => 0.1, :lon => 0.1))
diff = XML::Document.new
diff.root = XML::Node.new "osmChange"
modify = XML::Node.new "modify"
xml_old_way = xml_node_for_way(old_way)
nd_ref = XML::Node.new "nd"
- nd_ref["ref"] = create(:node, :lat => 3, :lon => 3).id.to_s
+ nd_ref["ref"] = create(:node, :lat => 0.3, :lon => 0.3).id.to_s
xml_old_way << nd_ref
xml_old_way["changeset"] = changeset_id.to_s
modify << xml_old_way
# check the bbox
changeset = Changeset.find(changeset_id)
- assert_equal 1 * GeoRecord::SCALE, changeset.min_lon, "min_lon should be 1 degree"
- assert_equal 3 * GeoRecord::SCALE, changeset.max_lon, "max_lon should be 3 degrees"
- assert_equal 1 * GeoRecord::SCALE, changeset.min_lat, "min_lat should be 1 degree"
- assert_equal 3 * GeoRecord::SCALE, changeset.max_lat, "max_lat should be 3 degrees"
+ assert_equal 0.1 * GeoRecord::SCALE, changeset.min_lon, "min_lon should be 0.1 degree"
+ assert_equal 0.3 * GeoRecord::SCALE, changeset.max_lon, "max_lon should be 0.3 degrees"
+ assert_equal 0.1 * GeoRecord::SCALE, changeset.min_lat, "min_lat should be 0.1 degree"
+ assert_equal 0.3 * GeoRecord::SCALE, changeset.max_lat, "max_lat should be 0.3 degrees"
end
##
diff = <<~CHANGESET
<osmChange>
<modify>
- <node id='#{node.id}' lon='0' lat='0' changeset='#{changeset_id}' version='1'/>
- <node id='#{node.id}' lon='1' lat='0' changeset='#{changeset_id}' version='2'/>
- <node id='#{node.id}' lon='1' lat='1' changeset='#{changeset_id}' version='3'/>
- <node id='#{node.id}' lon='1' lat='2' changeset='#{changeset_id}' version='4'/>
- <node id='#{node.id}' lon='2' lat='2' changeset='#{changeset_id}' version='5'/>
- <node id='#{node.id}' lon='3' lat='2' changeset='#{changeset_id}' version='6'/>
- <node id='#{node.id}' lon='3' lat='3' changeset='#{changeset_id}' version='7'/>
- <node id='#{node.id}' lon='9' lat='9' changeset='#{changeset_id}' version='8'/>
+ <node id='#{node.id}' lon='0.0' lat='0.0' changeset='#{changeset_id}' version='1'/>
+ <node id='#{node.id}' lon='0.1' lat='0.0' changeset='#{changeset_id}' version='2'/>
+ <node id='#{node.id}' lon='0.1' lat='0.1' changeset='#{changeset_id}' version='3'/>
+ <node id='#{node.id}' lon='0.1' lat='0.2' changeset='#{changeset_id}' version='4'/>
+ <node id='#{node.id}' lon='0.2' lat='0.2' changeset='#{changeset_id}' version='5'/>
+ <node id='#{node.id}' lon='0.3' lat='0.2' changeset='#{changeset_id}' version='6'/>
+ <node id='#{node.id}' lon='0.3' lat='0.3' changeset='#{changeset_id}' version='7'/>
+ <node id='#{node.id}' lon='0.9' lat='0.9' changeset='#{changeset_id}' version='8'/>
</modify>
</osmChange>
CHANGESET
diff = <<~CHANGESET
<osmChange>
<delete>
- <node id='#{node.id}' lon='0' lat='0' changeset='#{changeset_id}' version='1'/>
+ <node id='#{node.id}' lon='0.0' lat='0.0' changeset='#{changeset_id}' version='1'/>
</delete>
<create>
- <node id='-1' lon='9' lat='9' changeset='#{changeset_id}' version='0'/>
- <node id='-2' lon='8' lat='9' changeset='#{changeset_id}' version='0'/>
- <node id='-3' lon='7' lat='9' changeset='#{changeset_id}' version='0'/>
+ <node id='-1' lon='0.9' lat='0.9' changeset='#{changeset_id}' version='0'/>
+ <node id='-2' lon='0.8' lat='0.9' changeset='#{changeset_id}' version='0'/>
+ <node id='-3' lon='0.7' lat='0.9' changeset='#{changeset_id}' version='0'/>
</create>
<modify>
- <node id='#{node2.id}' lon='20' lat='15' changeset='#{changeset_id}' version='1'/>
+ <node id='#{node2.id}' lon='2.0' lat='1.5' changeset='#{changeset_id}' version='1'/>
<way id='#{way.id}' changeset='#{changeset_id}' version='1'>
<nd ref='#{node2.id}'/>
<nd ref='-1'/>
# FIXME: This should really be moded to a integration test due to the with_controller
def test_changeset_bbox
way = create(:way)
- create(:way_node, :way => way, :node => create(:node, :lat => 3, :lon => 3))
+ create(:way_node, :way => way, :node => create(:node, :lat => 0.3, :lon => 0.3))
auth_header = basic_authorization_header create(:user).email, "test"
# add a single node to it
with_controller(NodesController.new) do
- xml = "<osm><node lon='1' lat='2' changeset='#{changeset_id}'/></osm>"
+ xml = "<osm><node lon='0.1' lat='0.2' changeset='#{changeset_id}'/></osm>"
put node_create_path, :params => xml, :headers => auth_header
assert_response :success, "Couldn't create node."
end
# get the bounding box back from the changeset
get changeset_show_path(:id => changeset_id)
assert_response :success, "Couldn't read back changeset."
- assert_select "osm>changeset[min_lon='1.0000000']", 1
- assert_select "osm>changeset[max_lon='1.0000000']", 1
- assert_select "osm>changeset[min_lat='2.0000000']", 1
- assert_select "osm>changeset[max_lat='2.0000000']", 1
+ assert_select "osm>changeset[min_lon='0.1000000']", 1
+ assert_select "osm>changeset[max_lon='0.1000000']", 1
+ assert_select "osm>changeset[min_lat='0.2000000']", 1
+ assert_select "osm>changeset[max_lat='0.2000000']", 1
# add another node to it
with_controller(NodesController.new) do
- xml = "<osm><node lon='2' lat='1' changeset='#{changeset_id}'/></osm>"
+ xml = "<osm><node lon='0.2' lat='0.1' changeset='#{changeset_id}'/></osm>"
put node_create_path, :params => xml, :headers => auth_header
assert_response :success, "Couldn't create second node."
end
# get the bounding box back from the changeset
get changeset_show_path(:id => changeset_id)
assert_response :success, "Couldn't read back changeset for the second time."
- assert_select "osm>changeset[min_lon='1.0000000']", 1
- assert_select "osm>changeset[max_lon='2.0000000']", 1
- assert_select "osm>changeset[min_lat='1.0000000']", 1
- assert_select "osm>changeset[max_lat='2.0000000']", 1
+ assert_select "osm>changeset[min_lon='0.1000000']", 1
+ assert_select "osm>changeset[max_lon='0.2000000']", 1
+ assert_select "osm>changeset[min_lat='0.1000000']", 1
+ assert_select "osm>changeset[max_lat='0.2000000']", 1
# add (delete) a way to it, which contains a point at (3,3)
with_controller(WaysController.new) do
# get the bounding box back from the changeset
get changeset_show_path(:id => changeset_id)
assert_response :success, "Couldn't read back changeset for the third time."
- assert_select "osm>changeset[min_lon='1.0000000']", 1
- assert_select "osm>changeset[max_lon='3.0000000']", 1
- assert_select "osm>changeset[min_lat='1.0000000']", 1
- assert_select "osm>changeset[max_lat='3.0000000']", 1
+ assert_select "osm>changeset[min_lon='0.1000000']", 1
+ assert_select "osm>changeset[max_lon='0.3000000']", 1
+ assert_select "osm>changeset[min_lat='0.1000000']", 1
+ assert_select "osm>changeset[max_lat='0.3000000']", 1
end
##
# FIXME: Move this test to being an integration test since it spans multiple controllers
def test_version
private_user = create(:user, :data_public => false)
- private_node = create(:node, :with_history, :version => 4, :changeset => create(:changeset, :user => private_user))
+ private_node = create(:node, :with_history, :version => 4, :lat => 0, :lon => 0, :changeset => create(:changeset, :user => private_user))
user = create(:user)
- node = create(:node, :with_history, :version => 4, :changeset => create(:changeset, :user => user))
+ node = create(:node, :with_history, :version => 4, :lat => 0, :lon => 0, :changeset => create(:changeset, :user => user))
create_list(:node_tag, 2, :node => node)
# Ensure that the current tags are propagated to the history too
propagate_tags(node, node.old_nodes.last)
# randomly move the node about
3.times do
# move the node somewhere else
- xml_node["lat"] = precision((rand * 180) - 90).to_s
- xml_node["lon"] = precision((rand * 360) - 180).to_s
+ xml_node["lat"] = precision(rand - 0.5).to_s
+ xml_node["lon"] = precision(rand - 0.5).to_s
with_controller(NodesController.new) do
put api_node_path(nodeid), :params => xml_doc.to_s, :headers => auth_header
assert_response :forbidden, "Should have rejected node update"
# randomly move the node about
3.times do
# move the node somewhere else
- xml_node["lat"] = precision((rand * 180) - 90).to_s
- xml_node["lon"] = precision((rand * 360) - 180).to_s
+ xml_node["lat"] = precision(rand - 0.5).to_s
+ xml_node["lon"] = precision(rand - 0.5).to_s
with_controller(NodesController.new) do
put api_node_path(nodeid), :params => xml_doc.to_s, :headers => auth_header
assert_response :success
# box of all its members into the changeset.
def test_tag_modify_bounding_box
relation = create(:relation)
- node1 = create(:node, :lat => 3, :lon => 3)
- node2 = create(:node, :lat => 5, :lon => 5)
+ node1 = create(:node, :lat => 0.3, :lon => 0.3)
+ node2 = create(:node, :lat => 0.5, :lon => 0.5)
way = create(:way)
create(:way_node, :way => way, :node => node1)
create(:relation_member, :relation => relation, :member => way)
create(:relation_member, :relation => relation, :member => node2)
# the relation contains nodes1 and node2 (node1
- # indirectly via the way), so the bbox should be [3,3,5,5].
- check_changeset_modify(BoundingBox.new(3, 3, 5, 5)) do |changeset_id, auth_header|
+ # indirectly via the way), so the bbox should be [0.3,0.3,0.5,0.5].
+ check_changeset_modify(BoundingBox.new(0.3, 0.3, 0.5, 0.5)) do |changeset_id, auth_header|
# add a tag to an existing relation
relation_xml = xml_for_relation(relation)
relation_element = relation_xml.find("//osm/relation").first
# still technically valid.
def test_remove_all_members
relation = create(:relation)
- node1 = create(:node, :lat => 3, :lon => 3)
- node2 = create(:node, :lat => 5, :lon => 5)
+ node1 = create(:node, :lat => 0.3, :lon => 0.3)
+ node2 = create(:node, :lat => 0.5, :lon => 0.5)
way = create(:way)
create(:way_node, :way => way, :node => node1)
create(:relation_member, :relation => relation, :member => way)
create(:relation_member, :relation => relation, :member => node2)
- check_changeset_modify(BoundingBox.new(3, 3, 5, 5)) do |changeset_id, auth_header|
+ check_changeset_modify(BoundingBox.new(0.3, 0.3, 0.5, 0.5)) do |changeset_id, auth_header|
relation_xml = xml_for_relation(relation)
relation_xml
.find("//osm/relation/member")