--- title: "解決iD上傳的衝突(已解決)" tags: Project,hackpad --- # 解決iD上傳的衝突(已解決) > [點此觀看原始內容](https://osmtw.hackpad.tw/pISINgmW01z) 解決iD上傳的衝突(已解決) [https://www.facebook.com/mcdlee/posts/10204308597859719](https://www.facebook.com/mcdlee/posts/10204308597859719) @劉婕昕 和 [黃裕翔](https://www.facebook.com/yellowsoarfb) 發現從 iD 的頁面 source 可以呈現正在編輯的 [‪#‎](https://www.facebook.com/hashtag/osm?source=feed_text&story_id=10204308597859719)OSM‬ 圖資,也許可以藉此保留.osm,減輕編輯衝突的損失。 ## 以Chrome為例 ### 取得iD編輯內容 當iD因衝突而無法上傳編輯內容的時候,可以透過右鍵選單的檢閱元素功能,在Resources分類底下Local Storage中的osm項目中,找到以「id_網址」為名的Key項目之Value內容。 ### 格式轉換 將之轉換為符合xml格式之「.osm」檔案(參考:[http://wiki.openstreetmap.org/wiki/JOSM\_file\_format](http://wiki.openstreetmap.org/wiki/JOSM_file_format)),如此便可以透過JOSM解決iD上傳問題。 ### Javascript library iD Editor 有個 API 叫做 connection.osmChangeJXON(changeset_id, changes) 可以生成 [osmChange](http://wiki.openstreetmap.org/wiki/OsmChange)  XML 檔案。 原始上傳程式碼,理論上會存成一組 changeset, 如果知道 changeset id,可以直接下載。 > 如果有衝突就不會上傳,不會上傳應該就不會有changset,那應該就抓不到changset id了?@@ > [name=yellowsoar] ``` connection.putChangeset = function(changes, comment, imageryUsed, callback) { oauth.xhr({ method: 'PUT', path: '/api/0.6/changeset/create', options: { header: { 'Content-Type': 'text/xml' } }, content: JXON.stringify(connection.changesetJXON(connection.changesetTags(comment, imageryUsed))) }, function(err, changeset_id) { if (err) return callback(err); oauth.xhr({ method: 'POST', path: '/api/0.6/changeset/' + changeset_id + '/upload', options: { header: { 'Content-Type': 'text/xml' } }, content: JXON.stringify(connection.osmChangeJXON(changeset_id, changes)) }, function(err) { if (err) return callback(err); oauth.xhr({ method: 'PUT', path: '/api/0.6/changeset/' + changeset_id + '/close' }, function(err) { callback(err, changeset_id); }); }); }); }; ``` ## 結案 iD在某個版本(待查),加入編輯衝突的處理機制