3 class WaysControllerTest < ActionController::TestCase
5 # test all routes which lead to this controller
8 { :path => "/api/0.6/way/create", :method => :put },
9 { :controller => "ways", :action => "create" }
12 { :path => "/api/0.6/way/1/full", :method => :get },
13 { :controller => "ways", :action => "full", :id => "1" }
16 { :path => "/api/0.6/way/1", :method => :get },
17 { :controller => "ways", :action => "read", :id => "1" }
20 { :path => "/api/0.6/way/1", :method => :put },
21 { :controller => "ways", :action => "update", :id => "1" }
24 { :path => "/api/0.6/way/1", :method => :delete },
25 { :controller => "ways", :action => "delete", :id => "1" }
28 { :path => "/api/0.6/ways", :method => :get },
29 { :controller => "ways", :action => "ways" }
33 # -------------------------------------
35 # -------------------------------------
38 # check that a visible way is returned properly
39 get :read, :params => { :id => create(:way).id }
40 assert_response :success
42 # check that an invisible way is not returned
43 get :read, :params => { :id => create(:way, :deleted).id }
46 # check chat a non-existent way is not returned
47 get :read, :params => { :id => 0 }
48 assert_response :not_found
52 # check the "full" mode
55 get :full, :params => { :id => way.id }
57 # full call should say "gone" for non-visible ways...
63 # otherwise it should say success
64 assert_response :success
66 # Check the way is correctly returned
67 assert_select "osm way[id='#{way.id}'][version='#{way.version}'][visible='#{way.visible}']", 1
69 # check that each node in the way appears once in the output as a
70 # reference and as the node element.
72 count = (way.nodes - (way.nodes - [n])).length
73 assert_select "osm way nd[ref='#{n.id}']", count
74 assert_select "osm node[id='#{n.id}'][version='#{n.version}'][lat='#{format('%.7f', n.lat)}'][lon='#{format('%.7f', n.lon)}']", 1
80 # test fetching multiple ways
83 way2 = create(:way, :deleted)
87 # check error when no parameter provided
89 assert_response :bad_request
91 # check error when no parameter value provided
92 get :ways, :params => { :ways => "" }
93 assert_response :bad_request
96 get :ways, :params => { :ways => "#{way1.id},#{way2.id},#{way3.id},#{way4.id}" }
97 assert_response :success
98 assert_select "osm" do
99 assert_select "way", :count => 4
100 assert_select "way[id='#{way1.id}'][visible='true']", :count => 1
101 assert_select "way[id='#{way2.id}'][visible='false']", :count => 1
102 assert_select "way[id='#{way3.id}'][visible='true']", :count => 1
103 assert_select "way[id='#{way4.id}'][visible='true']", :count => 1
106 # check error when a non-existent way is included
107 get :ways, :params => { :ways => "#{way1.id},#{way2.id},#{way3.id},#{way4.id},0" }
108 assert_response :not_found
111 # -------------------------------------
112 # Test simple way creation.
113 # -------------------------------------
116 node1 = create(:node)
117 node2 = create(:node)
118 private_user = create(:user, :data_public => false)
119 private_changeset = create(:changeset, :user => private_user)
121 changeset = create(:changeset, :user => user)
123 ## First check that it fails when creating a way using a non-public user
124 basic_authorization private_user.email, "test"
126 # use the first user's open changeset
127 changeset_id = private_changeset.id
129 # create a way with pre-existing nodes
130 xml = "<osm><way changeset='#{changeset_id}'>" \
131 "<nd ref='#{node1.id}'/><nd ref='#{node2.id}'/>" \
132 "<tag k='test' v='yes' /></way></osm>"
133 put :create, :body => xml
135 assert_response :forbidden,
136 "way upload did not return forbidden status"
138 ## Now use a public user
139 basic_authorization user.email, "test"
141 # use the first user's open changeset
142 changeset_id = changeset.id
144 # create a way with pre-existing nodes
145 xml = "<osm><way changeset='#{changeset_id}'>" \
146 "<nd ref='#{node1.id}'/><nd ref='#{node2.id}'/>" \
147 "<tag k='test' v='yes' /></way></osm>"
148 put :create, :body => xml
150 assert_response :success,
151 "way upload did not return success status"
152 # read id of created way and search for it
153 wayid = @response.body
154 checkway = Way.find(wayid)
155 assert_not_nil checkway,
156 "uploaded way not found in data base after upload"
158 assert_equal checkway.nds.length, 2,
159 "saved way does not contain exactly one node"
160 assert_equal checkway.nds[0], node1.id,
161 "saved way does not contain the right node on pos 0"
162 assert_equal checkway.nds[1], node2.id,
163 "saved way does not contain the right node on pos 1"
164 assert_equal checkway.changeset_id, changeset_id,
165 "saved way does not belong to the correct changeset"
166 assert_equal user.id, checkway.changeset.user_id,
167 "saved way does not belong to user that created it"
168 assert_equal true, checkway.visible,
169 "saved way is not visible"
172 # -------------------------------------
173 # Test creating some invalid ways.
174 # -------------------------------------
176 def test_create_invalid
178 private_user = create(:user, :data_public => false)
179 private_open_changeset = create(:changeset, :user => private_user)
180 private_closed_changeset = create(:changeset, :closed, :user => private_user)
182 open_changeset = create(:changeset, :user => user)
183 closed_changeset = create(:changeset, :closed, :user => user)
185 ## First test with a private user to make sure that they are not authorized
186 basic_authorization private_user.email, "test"
188 # use the first user's open changeset
189 # create a way with non-existing node
190 xml = "<osm><way changeset='#{private_open_changeset.id}'>" \
191 "<nd ref='0'/><tag k='test' v='yes' /></way></osm>"
192 put :create, :body => xml
194 assert_response :forbidden,
195 "way upload with invalid node using a private user did not return 'forbidden'"
197 # create a way with no nodes
198 xml = "<osm><way changeset='#{private_open_changeset.id}'>" \
199 "<tag k='test' v='yes' /></way></osm>"
200 put :create, :body => xml
202 assert_response :forbidden,
203 "way upload with no node using a private userdid not return 'forbidden'"
205 # create a way inside a closed changeset
206 xml = "<osm><way changeset='#{private_closed_changeset.id}'>" \
207 "<nd ref='#{node.id}'/></way></osm>"
208 put :create, :body => xml
210 assert_response :forbidden,
211 "way upload to closed changeset with a private user did not return 'forbidden'"
213 ## Now test with a public user
214 basic_authorization user.email, "test"
216 # use the first user's open changeset
217 # create a way with non-existing node
218 xml = "<osm><way changeset='#{open_changeset.id}'>" \
219 "<nd ref='0'/><tag k='test' v='yes' /></way></osm>"
220 put :create, :body => xml
222 assert_response :precondition_failed,
223 "way upload with invalid node did not return 'precondition failed'"
224 assert_equal "Precondition failed: Way requires the nodes with id in (0), which either do not exist, or are not visible.", @response.body
226 # create a way with no nodes
227 xml = "<osm><way changeset='#{open_changeset.id}'>" \
228 "<tag k='test' v='yes' /></way></osm>"
229 put :create, :body => xml
231 assert_response :precondition_failed,
232 "way upload with no node did not return 'precondition failed'"
233 assert_equal "Precondition failed: Cannot create way: data is invalid.", @response.body
235 # create a way inside a closed changeset
236 xml = "<osm><way changeset='#{closed_changeset.id}'>" \
237 "<nd ref='#{node.id}'/></way></osm>"
238 put :create, :body => xml
240 assert_response :conflict,
241 "way upload to closed changeset did not return 'conflict'"
243 # create a way with a tag which is too long
244 xml = "<osm><way changeset='#{open_changeset.id}'>" \
245 "<nd ref='#{node.id}'/>" \
246 "<tag k='foo' v='#{'x' * 256}'/>" \
248 put :create, :body => xml
250 assert_response :bad_request,
251 "way upload to with too long tag did not return 'bad_request'"
254 # -------------------------------------
255 # Test deleting ways.
256 # -------------------------------------
259 private_user = create(:user, :data_public => false)
260 private_open_changeset = create(:changeset, :user => private_user)
261 private_closed_changeset = create(:changeset, :closed, :user => private_user)
262 private_way = create(:way, :changeset => private_open_changeset)
263 private_deleted_way = create(:way, :deleted, :changeset => private_open_changeset)
264 private_used_way = create(:way, :changeset => private_open_changeset)
265 create(:relation_member, :member => private_used_way)
267 open_changeset = create(:changeset, :user => user)
268 closed_changeset = create(:changeset, :closed, :user => user)
269 way = create(:way, :changeset => open_changeset)
270 deleted_way = create(:way, :deleted, :changeset => open_changeset)
271 used_way = create(:way, :changeset => open_changeset)
272 relation_member = create(:relation_member, :member => used_way)
273 relation = relation_member.relation
275 # first try to delete way without auth
276 delete :delete, :params => { :id => way.id }
277 assert_response :unauthorized
279 # now set auth using the private user
280 basic_authorization private_user.email, "test"
282 # this shouldn't work as with the 0.6 api we need pay load to delete
283 delete :delete, :params => { :id => private_way.id }
284 assert_response :forbidden
286 # Now try without having a changeset
287 xml = "<osm><way id='#{private_way.id}'/></osm>"
288 delete :delete, :params => { :id => private_way.id }, :body => xml.to_s
289 assert_response :forbidden
291 # try to delete with an invalid (closed) changeset
292 xml = update_changeset(private_way.to_xml, private_closed_changeset.id)
293 delete :delete, :params => { :id => private_way.id }, :body => xml.to_s
294 assert_response :forbidden
296 # try to delete with an invalid (non-existent) changeset
297 xml = update_changeset(private_way.to_xml, 0)
298 delete :delete, :params => { :id => private_way.id }, :body => xml.to_s
299 assert_response :forbidden
301 # Now try with a valid changeset
302 xml = private_way.to_xml
303 delete :delete, :params => { :id => private_way.id }, :body => xml.to_s
304 assert_response :forbidden
306 # check the returned value - should be the new version number
307 # valid delete should return the new version number, which should
308 # be greater than the old version number
309 # assert @response.body.to_i > current_ways(:visible_way).version,
310 # "delete request should return a new version number for way"
312 # this won't work since the way is already deleted
313 xml = private_deleted_way.to_xml
314 delete :delete, :params => { :id => private_deleted_way.id }, :body => xml.to_s
315 assert_response :forbidden
317 # this shouldn't work as the way is used in a relation
318 xml = private_used_way.to_xml
319 delete :delete, :params => { :id => private_used_way.id }, :body => xml.to_s
320 assert_response :forbidden,
321 "shouldn't be able to delete a way used in a relation (#{@response.body}), when done by a private user"
323 # this won't work since the way never existed
324 delete :delete, :params => { :id => 0 }
325 assert_response :forbidden
327 ### Now check with a public user
329 basic_authorization user.email, "test"
331 # this shouldn't work as with the 0.6 api we need pay load to delete
332 delete :delete, :params => { :id => way.id }
333 assert_response :bad_request
335 # Now try without having a changeset
336 xml = "<osm><way id='#{way.id}'/></osm>"
337 delete :delete, :params => { :id => way.id }, :body => xml.to_s
338 assert_response :bad_request
340 # try to delete with an invalid (closed) changeset
341 xml = update_changeset(way.to_xml, closed_changeset.id)
342 delete :delete, :params => { :id => way.id }, :body => xml.to_s
343 assert_response :conflict
345 # try to delete with an invalid (non-existent) changeset
346 xml = update_changeset(way.to_xml, 0)
347 delete :delete, :params => { :id => way.id }, :body => xml.to_s
348 assert_response :conflict
350 # Now try with a valid changeset
352 delete :delete, :params => { :id => way.id }, :body => xml.to_s
353 assert_response :success
355 # check the returned value - should be the new version number
356 # valid delete should return the new version number, which should
357 # be greater than the old version number
358 assert @response.body.to_i > way.version,
359 "delete request should return a new version number for way"
361 # this won't work since the way is already deleted
362 xml = deleted_way.to_xml
363 delete :delete, :params => { :id => deleted_way.id }, :body => xml.to_s
364 assert_response :gone
366 # this shouldn't work as the way is used in a relation
367 xml = used_way.to_xml
368 delete :delete, :params => { :id => used_way.id }, :body => xml.to_s
369 assert_response :precondition_failed,
370 "shouldn't be able to delete a way used in a relation (#{@response.body})"
371 assert_equal "Precondition failed: Way #{used_way.id} is still used by relations #{relation.id}.", @response.body
373 # this won't work since the way never existed
374 delete :delete, :params => { :id => 0 }
375 assert_response :not_found
379 # tests whether the API works and prevents incorrect use while trying
382 private_user = create(:user, :data_public => false)
383 private_way = create(:way, :changeset => create(:changeset, :user => private_user))
385 way = create(:way, :changeset => create(:changeset, :user => user))
387 create(:way_node, :way => private_way, :node => node)
388 create(:way_node, :way => way, :node => node)
390 ## First test with no user credentials
391 # try and update a way without authorisation
393 put :update, :params => { :id => way.id }, :body => xml.to_s
394 assert_response :unauthorized
396 ## Second test with the private user
399 basic_authorization private_user.email, "test"
401 ## trying to break changesets
403 # try and update in someone else's changeset
404 xml = update_changeset(private_way.to_xml,
405 create(:changeset).id)
406 put :update, :params => { :id => private_way.id }, :body => xml.to_s
407 assert_require_public_data "update with other user's changeset should be forbidden when date isn't public"
409 # try and update in a closed changeset
410 xml = update_changeset(private_way.to_xml,
411 create(:changeset, :closed, :user => private_user).id)
412 put :update, :params => { :id => private_way.id }, :body => xml.to_s
413 assert_require_public_data "update with closed changeset should be forbidden, when data isn't public"
415 # try and update in a non-existant changeset
416 xml = update_changeset(private_way.to_xml, 0)
417 put :update, :params => { :id => private_way.id }, :body => xml.to_s
418 assert_require_public_data("update with changeset=0 should be forbidden, when data isn't public")
420 ## try and submit invalid updates
421 xml = xml_replace_node(private_way.to_xml, node.id, 9999)
422 put :update, :params => { :id => private_way.id }, :body => xml.to_s
423 assert_require_public_data "way with non-existent node should be forbidden, when data isn't public"
425 xml = xml_replace_node(private_way.to_xml, node.id, create(:node, :deleted).id)
426 put :update, :params => { :id => private_way.id }, :body => xml.to_s
427 assert_require_public_data "way with deleted node should be forbidden, when data isn't public"
429 ## finally, produce a good request which will still not work
430 xml = private_way.to_xml
431 put :update, :params => { :id => private_way.id }, :body => xml.to_s
432 assert_require_public_data "should have failed with a forbidden when data isn't public"
434 ## Finally test with the public user
437 basic_authorization user.email, "test"
439 ## trying to break changesets
441 # try and update in someone else's changeset
442 xml = update_changeset(way.to_xml,
443 create(:changeset).id)
444 put :update, :params => { :id => way.id }, :body => xml.to_s
445 assert_response :conflict, "update with other user's changeset should be rejected"
447 # try and update in a closed changeset
448 xml = update_changeset(way.to_xml,
449 create(:changeset, :closed, :user => user).id)
450 put :update, :params => { :id => way.id }, :body => xml.to_s
451 assert_response :conflict, "update with closed changeset should be rejected"
453 # try and update in a non-existant changeset
454 xml = update_changeset(way.to_xml, 0)
455 put :update, :params => { :id => way.id }, :body => xml.to_s
456 assert_response :conflict, "update with changeset=0 should be rejected"
458 ## try and submit invalid updates
459 xml = xml_replace_node(way.to_xml, node.id, 9999)
460 put :update, :params => { :id => way.id }, :body => xml.to_s
461 assert_response :precondition_failed, "way with non-existent node should be rejected"
463 xml = xml_replace_node(way.to_xml, node.id, create(:node, :deleted).id)
464 put :update, :params => { :id => way.id }, :body => xml.to_s
465 assert_response :precondition_failed, "way with deleted node should be rejected"
467 ## next, attack the versioning
468 current_way_version = way.version
470 # try and submit a version behind
471 xml = xml_attr_rewrite(way.to_xml,
472 "version", current_way_version - 1)
473 put :update, :params => { :id => way.id }, :body => xml.to_s
474 assert_response :conflict, "should have failed on old version number"
476 # try and submit a version ahead
477 xml = xml_attr_rewrite(way.to_xml,
478 "version", current_way_version + 1)
479 put :update, :params => { :id => way.id }, :body => xml.to_s
480 assert_response :conflict, "should have failed on skipped version number"
482 # try and submit total crap in the version field
483 xml = xml_attr_rewrite(way.to_xml,
484 "version", "p1r4t3s!")
485 put :update, :params => { :id => way.id }, :body => xml.to_s
486 assert_response :conflict,
487 "should not be able to put 'p1r4at3s!' in the version field"
489 ## try an update with the wrong ID
490 xml = create(:way).to_xml
491 put :update, :params => { :id => way.id }, :body => xml.to_s
492 assert_response :bad_request,
493 "should not be able to update a way with a different ID from the XML"
495 ## try an update with a minimal valid XML doc which isn't a well-formed OSM doc.
497 put :update, :params => { :id => way.id }, :body => xml.to_s
498 assert_response :bad_request,
499 "should not be able to update a way with non-OSM XML doc."
501 ## finally, produce a good request which should work
503 put :update, :params => { :id => way.id }, :body => xml.to_s
504 assert_response :success, "a valid update request failed"
507 # ------------------------------------------------------------
509 # ------------------------------------------------------------
512 # Try adding a new tag to a way
514 private_user = create(:user, :data_public => false)
515 private_way = create(:way_with_nodes, :nodes_count => 2, :changeset => create(:changeset, :user => private_user))
517 way = create(:way_with_nodes, :nodes_count => 2, :changeset => create(:changeset, :user => user))
519 ## Try with the non-public user
521 basic_authorization private_user.email, "test"
523 # add an identical tag to the way
524 tag_xml = XML::Node.new("tag")
528 # add the tag into the existing xml
529 way_xml = private_way.to_xml
530 way_xml.find("//osm/way").first << tag_xml
533 put :update, :params => { :id => private_way.id }, :body => way_xml.to_s
534 assert_response :forbidden,
535 "adding a duplicate tag to a way for a non-public should fail with 'forbidden'"
537 ## Now try with the public user
539 basic_authorization user.email, "test"
541 # add an identical tag to the way
542 tag_xml = XML::Node.new("tag")
546 # add the tag into the existing xml
548 way_xml.find("//osm/way").first << tag_xml
551 put :update, :params => { :id => way.id }, :body => way_xml.to_s
552 assert_response :success,
553 "adding a new tag to a way should succeed"
554 assert_equal way.version + 1, @response.body.to_i
558 # Try adding a duplicate of an existing tag to a way
559 def test_add_duplicate_tags
560 private_user = create(:user, :data_public => false)
561 private_way = create(:way, :changeset => create(:changeset, :user => private_user))
562 private_existing_tag = create(:way_tag, :way => private_way)
564 way = create(:way, :changeset => create(:changeset, :user => user))
565 existing_tag = create(:way_tag, :way => way)
567 ## Try with the non-public user
569 basic_authorization private_user.email, "test"
571 # add an identical tag to the way
572 tag_xml = XML::Node.new("tag")
573 tag_xml["k"] = private_existing_tag.k
574 tag_xml["v"] = private_existing_tag.v
576 # add the tag into the existing xml
577 way_xml = private_way.to_xml
578 way_xml.find("//osm/way").first << tag_xml
581 put :update, :params => { :id => private_way.id }, :body => way_xml.to_s
582 assert_response :forbidden,
583 "adding a duplicate tag to a way for a non-public should fail with 'forbidden'"
585 ## Now try with the public user
587 basic_authorization user.email, "test"
589 # add an identical tag to the way
590 tag_xml = XML::Node.new("tag")
591 tag_xml["k"] = existing_tag.k
592 tag_xml["v"] = existing_tag.v
594 # add the tag into the existing xml
596 way_xml.find("//osm/way").first << tag_xml
599 put :update, :params => { :id => way.id }, :body => way_xml.to_s
600 assert_response :bad_request,
601 "adding a duplicate tag to a way should fail with 'bad request'"
602 assert_equal "Element way/#{way.id} has duplicate tags with key #{existing_tag.k}", @response.body
606 # Try adding a new duplicate tags to a way
607 def test_new_duplicate_tags
608 private_user = create(:user, :data_public => false)
609 private_way = create(:way, :changeset => create(:changeset, :user => private_user))
611 way = create(:way, :changeset => create(:changeset, :user => user))
613 ## First test with the non-public user so should be rejected
615 basic_authorization private_user.email, "test"
617 # create duplicate tag
618 tag_xml = XML::Node.new("tag")
619 tag_xml["k"] = "i_am_a_duplicate"
620 tag_xml["v"] = "foobar"
622 # add the tag into the existing xml
623 way_xml = private_way.to_xml
625 # add two copies of the tag
626 way_xml.find("//osm/way").first << tag_xml.copy(true) << tag_xml
629 put :update, :params => { :id => private_way.id }, :body => way_xml.to_s
630 assert_response :forbidden,
631 "adding new duplicate tags to a way using a non-public user should fail with 'forbidden'"
633 ## Now test with the public user
635 basic_authorization user.email, "test"
637 # create duplicate tag
638 tag_xml = XML::Node.new("tag")
639 tag_xml["k"] = "i_am_a_duplicate"
640 tag_xml["v"] = "foobar"
642 # add the tag into the existing xml
645 # add two copies of the tag
646 way_xml.find("//osm/way").first << tag_xml.copy(true) << tag_xml
649 put :update, :params => { :id => way.id }, :body => way_xml.to_s
650 assert_response :bad_request,
651 "adding new duplicate tags to a way should fail with 'bad request'"
652 assert_equal "Element way/#{way.id} has duplicate tags with key i_am_a_duplicate", @response.body
656 # Try adding a new duplicate tags to a way.
657 # But be a bit subtle - use unicode decoding ambiguities to use different
658 # binary strings which have the same decoding.
659 def test_invalid_duplicate_tags
660 private_user = create(:user, :data_public => false)
661 private_changeset = create(:changeset, :user => private_user)
663 changeset = create(:changeset, :user => user)
665 ## First make sure that you can't with a non-public user
667 basic_authorization private_user.email, "test"
669 # add the tag into the existing xml
670 way_str = "<osm><way changeset='#{private_changeset.id}'>"
671 way_str << "<tag k='addr:housenumber' v='1'/>"
672 way_str << "<tag k='addr:housenumber' v='2'/>"
673 way_str << "</way></osm>"
676 put :create, :body => way_str
677 assert_response :forbidden,
678 "adding new duplicate tags to a way with a non-public user should fail with 'forbidden'"
680 ## Now do it with a public user
682 basic_authorization user.email, "test"
684 # add the tag into the existing xml
685 way_str = "<osm><way changeset='#{changeset.id}'>"
686 way_str << "<tag k='addr:housenumber' v='1'/>"
687 way_str << "<tag k='addr:housenumber' v='2'/>"
688 way_str << "</way></osm>"
691 put :create, :body => way_str
692 assert_response :bad_request,
693 "adding new duplicate tags to a way should fail with 'bad request'"
694 assert_equal "Element way/ has duplicate tags with key addr:housenumber", @response.body
698 # test that a call to ways_for_node returns all ways that contain the node
699 # and none that don't.
700 def test_ways_for_node
704 create(:way_node, :way => way1, :node => node)
705 create(:way_node, :way => way2, :node => node)
706 # create an unrelated way
707 create(:way_with_nodes, :nodes_count => 2)
708 # create a way which used to use the node
709 way3_v1 = create(:old_way, :version => 1)
710 _way3_v2 = create(:old_way, :current_way => way3_v1.current_way, :version => 2)
711 create(:old_way_node, :old_way => way3_v1, :node => node)
713 get :ways_for_node, :params => { :id => node.id }
714 assert_response :success
715 ways_xml = XML::Parser.string(@response.body).parse
716 assert_not_nil ways_xml, "failed to parse ways_for_node response"
718 # check that the set of IDs match expectations
719 expected_way_ids = [way1.id,
721 found_way_ids = ways_xml.find("//osm/way").collect { |w| w["id"].to_i }
722 assert_equal expected_way_ids.sort, found_way_ids.sort,
723 "expected ways for node #{node.id} did not match found"
725 # check the full ways to ensure we're not missing anything
726 expected_way_ids.each do |id|
727 way_xml = ways_xml.find("//osm/way[@id='#{id}']").first
728 assert_ways_are_equal(Way.find(id),
729 Way.from_xml_node(way_xml))
734 # update the changeset_id of a way element
735 def update_changeset(xml, changeset_id)
736 xml_attr_rewrite(xml, "changeset", changeset_id)
740 # update an attribute in the way element
741 def xml_attr_rewrite(xml, name, value)
742 xml.find("//osm/way").first[name] = value.to_s
747 # replace a node in a way element
748 def xml_replace_node(xml, old_node, new_node)
749 xml.find("//osm/way/nd[@ref='#{old_node}']").first["ref"] = new_node.to_s