4 class RelationsControllerTest < ActionDispatch::IntegrationTest
6 # test all routes which lead to this controller
9 { :path => "/api/0.6/relations", :method => :get },
10 { :controller => "api/relations", :action => "index" }
13 { :path => "/api/0.6/relations.json", :method => :get },
14 { :controller => "api/relations", :action => "index", :format => "json" }
17 { :path => "/api/0.6/relations", :method => :post },
18 { :controller => "api/relations", :action => "create" }
21 { :path => "/api/0.6/relation/1", :method => :get },
22 { :controller => "api/relations", :action => "show", :id => "1" }
25 { :path => "/api/0.6/relation/1.json", :method => :get },
26 { :controller => "api/relations", :action => "show", :id => "1", :format => "json" }
29 { :path => "/api/0.6/relation/1/full", :method => :get },
30 { :controller => "api/relations", :action => "show", :full => true, :id => "1" }
33 { :path => "/api/0.6/relation/1/full.json", :method => :get },
34 { :controller => "api/relations", :action => "show", :full => true, :id => "1", :format => "json" }
37 { :path => "/api/0.6/relation/1", :method => :put },
38 { :controller => "api/relations", :action => "update", :id => "1" }
41 { :path => "/api/0.6/relation/1", :method => :delete },
42 { :controller => "api/relations", :action => "destroy", :id => "1" }
46 { :controller => "api/relations", :action => "create" },
47 { :path => "/api/0.6/relation/create", :method => :put }
52 # test fetching multiple relations
54 relation1 = create(:relation)
55 relation2 = create(:relation, :deleted)
56 relation3 = create(:relation, :with_history, :version => 2)
57 relation4 = create(:relation, :with_history, :version => 2)
58 relation4.old_relations.find_by(:version => 1).redact!(create(:redaction))
60 # check error when no parameter provided
61 get api_relations_path
62 assert_response :bad_request
64 # check error when no parameter value provided
65 get api_relations_path(:relations => "")
66 assert_response :bad_request
69 get api_relations_path(:relations => "#{relation1.id},#{relation2.id},#{relation3.id},#{relation4.id}")
70 assert_response :success
71 assert_select "osm" do
72 assert_select "relation", :count => 4
73 assert_select "relation[id='#{relation1.id}'][visible='true']", :count => 1
74 assert_select "relation[id='#{relation2.id}'][visible='false']", :count => 1
75 assert_select "relation[id='#{relation3.id}'][visible='true']", :count => 1
76 assert_select "relation[id='#{relation4.id}'][visible='true']", :count => 1
79 # test a working call with json format
80 get api_relations_path(:relations => "#{relation1.id},#{relation2.id},#{relation3.id},#{relation4.id}", :format => "json")
82 js = ActiveSupport::JSON.decode(@response.body)
84 assert_equal 4, js["elements"].count
85 assert_equal 4, (js["elements"].count { |a| a["type"] == "relation" })
86 assert_equal 1, (js["elements"].count { |a| a["id"] == relation1.id && a["visible"].nil? })
87 assert_equal 1, (js["elements"].count { |a| a["id"] == relation2.id && a["visible"] == false })
88 assert_equal 1, (js["elements"].count { |a| a["id"] == relation3.id && a["visible"].nil? })
89 assert_equal 1, (js["elements"].count { |a| a["id"] == relation4.id && a["visible"].nil? })
91 # check error when a non-existent relation is included
92 get api_relations_path(:relations => "#{relation1.id},#{relation2.id},#{relation3.id},#{relation4.id},0")
93 assert_response :not_found
96 # -------------------------------------
97 # Test showing relations.
98 # -------------------------------------
100 def test_show_not_found
101 get api_relation_path(0)
102 assert_response :not_found
105 def test_show_deleted
106 get api_relation_path(create(:relation, :deleted))
107 assert_response :gone
111 relation = create(:relation, :timestamp => "2021-02-03T00:00:00Z")
112 node = create(:node, :timestamp => "2021-04-05T00:00:00Z")
113 create(:relation_member, :relation => relation, :member => node)
115 get api_relation_path(relation)
117 assert_response :success
118 assert_not_nil @response.header["Last-Modified"]
119 assert_equal "2021-02-03T00:00:00Z", Time.parse(@response.header["Last-Modified"]).utc.xmlschema
120 assert_dom "node", :count => 0
121 assert_dom "relation", :count => 1 do
122 assert_dom "> @id", :text => relation.id.to_s
126 def test_full_not_found
127 get api_relation_path(999999, :full => true)
128 assert_response :not_found
131 def test_full_deleted
132 get api_relation_path(create(:relation, :deleted), :full => true)
133 assert_response :gone
137 relation = create(:relation)
139 get api_relation_path(relation, :full => true)
141 assert_response :success
142 assert_dom "relation", :count => 1 do
143 assert_dom "> @id", :text => relation.id.to_s
147 def test_full_with_node_member
148 relation = create(:relation)
150 create(:relation_member, :relation => relation, :member => node)
152 get api_relation_path(relation, :full => true)
154 assert_response :success
155 assert_dom "node", :count => 1 do
156 assert_dom "> @id", :text => node.id.to_s
158 assert_dom "relation", :count => 1 do
159 assert_dom "> @id", :text => relation.id.to_s
163 def test_full_with_way_member
164 relation = create(:relation)
165 way = create(:way_with_nodes)
166 create(:relation_member, :relation => relation, :member => way)
168 get api_relation_path(relation, :full => true)
170 assert_response :success
171 assert_dom "node", :count => 1 do
172 assert_dom "> @id", :text => way.nodes[0].id.to_s
174 assert_dom "way", :count => 1 do
175 assert_dom "> @id", :text => way.id.to_s
177 assert_dom "relation", :count => 1 do
178 assert_dom "> @id", :text => relation.id.to_s
182 def test_full_with_node_member_json
183 relation = create(:relation)
185 create(:relation_member, :relation => relation, :member => node)
187 get api_relation_path(relation, :full => true, :format => "json")
189 assert_response :success
190 js = ActiveSupport::JSON.decode(@response.body)
192 assert_equal 2, js["elements"].count
194 js_relations = js["elements"].filter { |e| e["type"] == "relation" }
195 assert_equal 1, js_relations.count
196 assert_equal relation.id, js_relations[0]["id"]
197 assert_equal 1, js_relations[0]["members"].count
198 assert_equal "node", js_relations[0]["members"][0]["type"]
199 assert_equal node.id, js_relations[0]["members"][0]["ref"]
201 js_nodes = js["elements"].filter { |e| e["type"] == "node" }
202 assert_equal 1, js_nodes.count
203 assert_equal node.id, js_nodes[0]["id"]
206 # -------------------------------------
207 # Test simple relation creation.
208 # -------------------------------------
211 private_user = create(:user, :data_public => false)
212 private_changeset = create(:changeset, :user => private_user)
214 changeset = create(:changeset, :user => user)
216 way = create(:way_with_nodes, :nodes_count => 2)
218 auth_header = bearer_authorization_header private_user
220 # create an relation without members
221 xml = "<osm><relation changeset='#{private_changeset.id}'><tag k='test' v='yes' /></relation></osm>"
222 post api_relations_path, :params => xml, :headers => auth_header
223 # hope for forbidden, due to user
224 assert_response :forbidden,
225 "relation upload should have failed with forbidden"
228 # create an relation with a node as member
229 # This time try with a role attribute in the relation
230 xml = "<osm><relation changeset='#{private_changeset.id}'>" \
231 "<member ref='#{node.id}' type='node' role='some'/>" \
232 "<tag k='test' v='yes' /></relation></osm>"
233 post api_relations_path, :params => xml, :headers => auth_header
234 # hope for forbidden due to user
235 assert_response :forbidden,
236 "relation upload did not return forbidden status"
239 # create an relation with a node as member, this time test that we don't
240 # need a role attribute to be included
241 xml = "<osm><relation changeset='#{private_changeset.id}'>" \
242 "<member ref='#{node.id}' type='node'/><tag k='test' v='yes' /></relation></osm>"
243 post api_relations_path, :params => xml, :headers => auth_header
244 # hope for forbidden due to user
245 assert_response :forbidden,
246 "relation upload did not return forbidden status"
249 # create an relation with a way and a node as members
250 xml = "<osm><relation changeset='#{private_changeset.id}'>" \
251 "<member type='node' ref='#{node.id}' role='some'/>" \
252 "<member type='way' ref='#{way.id}' role='other'/>" \
253 "<tag k='test' v='yes' /></relation></osm>"
254 post api_relations_path, :params => xml, :headers => auth_header
255 # hope for forbidden, due to user
256 assert_response :forbidden,
257 "relation upload did not return success status"
259 ## Now try with the public user
260 auth_header = bearer_authorization_header user
262 # create an relation without members
263 xml = "<osm><relation changeset='#{changeset.id}'><tag k='test' v='yes' /></relation></osm>"
264 post api_relations_path, :params => xml, :headers => auth_header
266 assert_response :success,
267 "relation upload did not return success status"
268 # read id of created relation and search for it
269 relationid = @response.body
270 checkrelation = Relation.find(relationid)
271 assert_not_nil checkrelation,
272 "uploaded relation not found in data base after upload"
274 assert_equal(0, checkrelation.members.length, "saved relation contains members but should not")
275 assert_equal(1, checkrelation.tags.length, "saved relation does not contain exactly one tag")
276 assert_equal changeset.id, checkrelation.changeset.id,
277 "saved relation does not belong in the changeset it was assigned to"
278 assert_equal user.id, checkrelation.changeset.user_id,
279 "saved relation does not belong to user that created it"
280 assert checkrelation.visible,
281 "saved relation is not visible"
282 # ok the relation is there but can we also retrieve it?
283 get api_relation_path(relationid)
284 assert_response :success
287 # create an relation with a node as member
288 # This time try with a role attribute in the relation
289 xml = "<osm><relation changeset='#{changeset.id}'>" \
290 "<member ref='#{node.id}' type='node' role='some'/>" \
291 "<tag k='test' v='yes' /></relation></osm>"
292 post api_relations_path, :params => xml, :headers => auth_header
294 assert_response :success,
295 "relation upload did not return success status"
296 # read id of created relation and search for it
297 relationid = @response.body
298 checkrelation = Relation.find(relationid)
299 assert_not_nil checkrelation,
300 "uploaded relation not found in data base after upload"
302 assert_equal(1, checkrelation.members.length, "saved relation does not contain exactly one member")
303 assert_equal(1, checkrelation.tags.length, "saved relation does not contain exactly one tag")
304 assert_equal changeset.id, checkrelation.changeset.id,
305 "saved relation does not belong in the changeset it was assigned to"
306 assert_equal user.id, checkrelation.changeset.user_id,
307 "saved relation does not belong to user that created it"
308 assert checkrelation.visible,
309 "saved relation is not visible"
310 # ok the relation is there but can we also retrieve it?
312 get api_relation_path(relationid)
313 assert_response :success
316 # create an relation with a node as member, this time test that we don't
317 # need a role attribute to be included
318 xml = "<osm><relation changeset='#{changeset.id}'>" \
319 "<member ref='#{node.id}' type='node'/><tag k='test' v='yes' /></relation></osm>"
320 post api_relations_path, :params => xml, :headers => auth_header
322 assert_response :success,
323 "relation upload did not return success status"
324 # read id of created relation and search for it
325 relationid = @response.body
326 checkrelation = Relation.find(relationid)
327 assert_not_nil checkrelation,
328 "uploaded relation not found in data base after upload"
330 assert_equal(1, checkrelation.members.length, "saved relation does not contain exactly one member")
331 assert_equal(1, checkrelation.tags.length, "saved relation does not contain exactly one tag")
332 assert_equal changeset.id, checkrelation.changeset.id,
333 "saved relation does not belong in the changeset it was assigned to"
334 assert_equal user.id, checkrelation.changeset.user_id,
335 "saved relation does not belong to user that created it"
336 assert checkrelation.visible,
337 "saved relation is not visible"
338 # ok the relation is there but can we also retrieve it?
340 get api_relation_path(relationid)
341 assert_response :success
344 # create an relation with a way and a node as members
345 xml = "<osm><relation changeset='#{changeset.id}'>" \
346 "<member type='node' ref='#{node.id}' role='some'/>" \
347 "<member type='way' ref='#{way.id}' role='other'/>" \
348 "<tag k='test' v='yes' /></relation></osm>"
349 post api_relations_path, :params => xml, :headers => auth_header
351 assert_response :success,
352 "relation upload did not return success status"
353 # read id of created relation and search for it
354 relationid = @response.body
355 checkrelation = Relation.find(relationid)
356 assert_not_nil checkrelation,
357 "uploaded relation not found in data base after upload"
359 assert_equal(2, checkrelation.members.length, "saved relation does not have exactly two members")
360 assert_equal(1, checkrelation.tags.length, "saved relation does not contain exactly one tag")
361 assert_equal changeset.id, checkrelation.changeset.id,
362 "saved relation does not belong in the changeset it was assigned to"
363 assert_equal user.id, checkrelation.changeset.user_id,
364 "saved relation does not belong to user that created it"
365 assert checkrelation.visible,
366 "saved relation is not visible"
367 # ok the relation is there but can we also retrieve it?
368 get api_relation_path(relationid)
369 assert_response :success
372 # ------------------------------------
373 # Test updating relations
374 # ------------------------------------
376 def test_update_wrong_id
378 changeset = create(:changeset, :user => user)
379 relation = create(:relation)
380 other_relation = create(:relation)
382 auth_header = bearer_authorization_header user
383 get api_relation_path(relation)
384 assert_response :success
385 rel = XML::Parser.string(@response.body).parse
387 update_changeset(rel, changeset.id)
388 put api_relation_path(other_relation), :params => rel.to_s, :headers => auth_header
389 assert_response :bad_request
392 # -------------------------------------
393 # Test creating some invalid relations.
394 # -------------------------------------
396 def test_create_invalid
398 changeset = create(:changeset, :user => user)
400 auth_header = bearer_authorization_header user
402 # create a relation with non-existing node as member
403 xml = "<osm><relation changeset='#{changeset.id}'>" \
404 "<member type='node' ref='0'/>" \
406 post api_relations_path, :params => xml, :headers => auth_header
408 assert_response :precondition_failed,
409 "relation upload with invalid node did not return 'precondition failed'"
410 assert_equal "Precondition failed: Relation with id cannot be saved due to Node with id 0", @response.body
413 # -------------------------------------
414 # Test creating a relation, with some invalid XML
415 # -------------------------------------
416 def test_create_invalid_xml
418 changeset = create(:changeset, :user => user)
421 auth_header = bearer_authorization_header user
423 # create some xml that should return an error
424 xml = "<osm><relation changeset='#{changeset.id}'>" \
425 "<member type='type' ref='#{node.id}' role=''/>" \
427 post api_relations_path, :params => xml, :headers => auth_header
429 assert_response :bad_request
430 assert_match(/Cannot parse valid relation from xml string/, @response.body)
431 assert_match(/The type is not allowed only, /, @response.body)
434 # -------------------------------------
435 # Test deleting relations.
436 # -------------------------------------
439 private_user = create(:user, :data_public => false)
440 private_user_closed_changeset = create(:changeset, :closed, :user => private_user)
442 closed_changeset = create(:changeset, :closed, :user => user)
443 changeset = create(:changeset, :user => user)
444 relation = create(:relation)
445 used_relation = create(:relation)
446 super_relation = create(:relation_member, :member => used_relation).relation
447 deleted_relation = create(:relation, :deleted)
448 multi_tag_relation = create(:relation)
449 create_list(:relation_tag, 4, :relation => multi_tag_relation)
451 ## First try to delete relation without auth
452 delete api_relation_path(relation)
453 assert_response :unauthorized
455 ## Then try with the private user, to make sure that you get a forbidden
456 auth_header = bearer_authorization_header private_user
458 # this shouldn't work, as we should need the payload...
459 delete api_relation_path(relation), :headers => auth_header
460 assert_response :forbidden
462 # try to delete without specifying a changeset
463 xml = "<osm><relation id='#{relation.id}'/></osm>"
464 delete api_relation_path(relation), :params => xml.to_s, :headers => auth_header
465 assert_response :forbidden
467 # try to delete with an invalid (closed) changeset
468 xml = update_changeset(xml_for_relation(relation),
469 private_user_closed_changeset.id)
470 delete api_relation_path(relation), :params => xml.to_s, :headers => auth_header
471 assert_response :forbidden
473 # try to delete with an invalid (non-existent) changeset
474 xml = update_changeset(xml_for_relation(relation), 0)
475 delete api_relation_path(relation), :params => xml.to_s, :headers => auth_header
476 assert_response :forbidden
478 # this won't work because the relation is in-use by another relation
479 xml = xml_for_relation(used_relation)
480 delete api_relation_path(used_relation), :params => xml.to_s, :headers => auth_header
481 assert_response :forbidden
483 # this should work when we provide the appropriate payload...
484 xml = xml_for_relation(relation)
485 delete api_relation_path(relation), :params => xml.to_s, :headers => auth_header
486 assert_response :forbidden
488 # this won't work since the relation is already deleted
489 xml = xml_for_relation(deleted_relation)
490 delete api_relation_path(deleted_relation), :params => xml.to_s, :headers => auth_header
491 assert_response :forbidden
493 # this won't work since the relation never existed
494 delete api_relation_path(0), :headers => auth_header
495 assert_response :forbidden
497 ## now set auth for the public user
498 auth_header = bearer_authorization_header user
500 # this shouldn't work, as we should need the payload...
501 delete api_relation_path(relation), :headers => auth_header
502 assert_response :bad_request
504 # try to delete without specifying a changeset
505 xml = "<osm><relation id='#{relation.id}' version='#{relation.version}' /></osm>"
506 delete api_relation_path(relation), :params => xml.to_s, :headers => auth_header
507 assert_response :bad_request
508 assert_match(/Changeset id is missing/, @response.body)
510 # try to delete with an invalid (closed) changeset
511 xml = update_changeset(xml_for_relation(relation),
513 delete api_relation_path(relation), :params => xml.to_s, :headers => auth_header
514 assert_response :conflict
516 # try to delete with an invalid (non-existent) changeset
517 xml = update_changeset(xml_for_relation(relation), 0)
518 delete api_relation_path(relation), :params => xml.to_s, :headers => auth_header
519 assert_response :conflict
521 # this won't work because the relation is in a changeset owned by someone else
522 xml = update_changeset(xml_for_relation(relation), create(:changeset).id)
523 delete api_relation_path(relation), :params => xml.to_s, :headers => auth_header
524 assert_response :conflict,
525 "shouldn't be able to delete a relation in a changeset owned by someone else (#{@response.body})"
527 # this won't work because the relation in the payload is different to that passed
528 xml = update_changeset(xml_for_relation(relation), changeset.id)
529 delete api_relation_path(create(:relation)), :params => xml.to_s, :headers => auth_header
530 assert_response :bad_request, "shouldn't be able to delete a relation when payload is different to the url"
532 # this won't work because the relation is in-use by another relation
533 xml = update_changeset(xml_for_relation(used_relation), changeset.id)
534 delete api_relation_path(used_relation), :params => xml.to_s, :headers => auth_header
535 assert_response :precondition_failed,
536 "shouldn't be able to delete a relation used in a relation (#{@response.body})"
537 assert_equal "Precondition failed: The relation #{used_relation.id} is used in relation #{super_relation.id}.", @response.body
539 # this should work when we provide the appropriate payload...
540 xml = update_changeset(xml_for_relation(multi_tag_relation), changeset.id)
541 delete api_relation_path(multi_tag_relation), :params => xml.to_s, :headers => auth_header
542 assert_response :success
544 # valid delete should return the new version number, which should
545 # be greater than the old version number
546 assert_operator @response.body.to_i, :>, multi_tag_relation.version, "delete request should return a new version number for relation"
548 # this won't work since the relation is already deleted
549 xml = update_changeset(xml_for_relation(deleted_relation), changeset.id)
550 delete api_relation_path(deleted_relation), :params => xml.to_s, :headers => auth_header
551 assert_response :gone
553 # Public visible relation needs to be deleted
554 xml = update_changeset(xml_for_relation(super_relation), changeset.id)
555 delete api_relation_path(super_relation), :params => xml.to_s, :headers => auth_header
556 assert_response :success
558 # this works now because the relation which was using this one
560 xml = update_changeset(xml_for_relation(used_relation), changeset.id)
561 delete api_relation_path(used_relation), :params => xml.to_s, :headers => auth_header
562 assert_response :success,
563 "should be able to delete a relation used in an old relation (#{@response.body})"
565 # this won't work since the relation never existed
566 delete api_relation_path(0), :headers => auth_header
567 assert_response :not_found
571 # test initial rate limit
572 def test_initial_rate_limit
577 node1 = create(:node)
578 node2 = create(:node)
580 # create a changeset that puts us near the initial rate limit
581 changeset = create(:changeset, :user => user,
582 :created_at => Time.now.utc - 5.minutes,
583 :num_changes => Settings.initial_changes_per_hour - 1)
585 # create authentication header
586 auth_header = bearer_authorization_header user
588 # try creating a relation
589 xml = "<osm><relation changeset='#{changeset.id}'>" \
590 "<member ref='#{node1.id}' type='node' role='some'/>" \
591 "<member ref='#{node2.id}' type='node' role='some'/>" \
593 post api_relations_path, :params => xml, :headers => auth_header
594 assert_response :success, "relation create did not return success status"
596 # get the id of the relation we created
597 relationid = @response.body
599 # try updating the relation, which should be rate limited
600 xml = "<osm><relation id='#{relationid}' version='1' changeset='#{changeset.id}'>" \
601 "<member ref='#{node2.id}' type='node' role='some'/>" \
602 "<member ref='#{node1.id}' type='node' role='some'/>" \
604 put api_relation_path(relationid), :params => xml, :headers => auth_header
605 assert_response :too_many_requests, "relation update did not hit rate limit"
607 # try deleting the relation, which should be rate limited
608 xml = "<osm><relation id='#{relationid}' version='2' changeset='#{changeset.id}'/></osm>"
609 delete api_relation_path(relationid), :params => xml, :headers => auth_header
610 assert_response :too_many_requests, "relation delete did not hit rate limit"
612 # try creating a relation, which should be rate limited
613 xml = "<osm><relation changeset='#{changeset.id}'>" \
614 "<member ref='#{node1.id}' type='node' role='some'/>" \
615 "<member ref='#{node2.id}' type='node' role='some'/>" \
617 post api_relations_path, :params => xml, :headers => auth_header
618 assert_response :too_many_requests, "relation create did not hit rate limit"
622 # test maximum rate limit
623 def test_maximum_rate_limit
628 node1 = create(:node)
629 node2 = create(:node)
631 # create a changeset to establish our initial edit time
632 changeset = create(:changeset, :user => user,
633 :created_at => Time.now.utc - 28.days)
635 # create changeset to put us near the maximum rate limit
636 total_changes = Settings.max_changes_per_hour - 1
637 while total_changes.positive?
638 changes = [total_changes, Changeset::MAX_ELEMENTS].min
639 changeset = create(:changeset, :user => user,
640 :created_at => Time.now.utc - 5.minutes,
641 :num_changes => changes)
642 total_changes -= changes
645 # create authentication header
646 auth_header = bearer_authorization_header user
648 # try creating a relation
649 xml = "<osm><relation changeset='#{changeset.id}'>" \
650 "<member ref='#{node1.id}' type='node' role='some'/>" \
651 "<member ref='#{node2.id}' type='node' role='some'/>" \
653 post api_relations_path, :params => xml, :headers => auth_header
654 assert_response :success, "relation create did not return success status"
656 # get the id of the relation we created
657 relationid = @response.body
659 # try updating the relation, which should be rate limited
660 xml = "<osm><relation id='#{relationid}' version='1' changeset='#{changeset.id}'>" \
661 "<member ref='#{node2.id}' type='node' role='some'/>" \
662 "<member ref='#{node1.id}' type='node' role='some'/>" \
664 put api_relation_path(relationid), :params => xml, :headers => auth_header
665 assert_response :too_many_requests, "relation update did not hit rate limit"
667 # try deleting the relation, which should be rate limited
668 xml = "<osm><relation id='#{relationid}' version='2' changeset='#{changeset.id}'/></osm>"
669 delete api_relation_path(relationid), :params => xml, :headers => auth_header
670 assert_response :too_many_requests, "relation delete did not hit rate limit"
672 # try creating a relation, which should be rate limited
673 xml = "<osm><relation changeset='#{changeset.id}'>" \
674 "<member ref='#{node1.id}' type='node' role='some'/>" \
675 "<member ref='#{node2.id}' type='node' role='some'/>" \
677 post api_relations_path, :params => xml, :headers => auth_header
678 assert_response :too_many_requests, "relation create did not hit rate limit"
684 # update the changeset_id of a node element
685 def update_changeset(xml, changeset_id)
686 xml_attr_rewrite(xml, "changeset", changeset_id)
690 # update an attribute in the node element
691 def xml_attr_rewrite(xml, name, value)
692 xml.find("//osm/relation").first[name] = value.to_s