Skip to content

Commit

Permalink
openEditor: Use idempotent remote control commands for JOSM
Browse files Browse the repository at this point in the history
Signed-off-by: Taylor Smock <[email protected]>
  • Loading branch information
tsmock authored and HelNershingThapa committed Jun 21, 2023
1 parent 63a624a commit 9582691
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions frontend/src/utils/openEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,16 @@ function loadTasksBoundaries(project, selectedTasks) {
const layerName = `Boundary for task${selectedTasks.length > 1 ? 's:' : ':'} ${selectedTasks.join(
',',
)} of TM Project #${project.projectId} - Do not edit or upload`;
const emptyTaskLayerParams = {
const tmTaskLayerParams = {
new_layer: true,
layer_name: layerName,
data: '<?xml version="1.0" encoding="utf8"?><osm generator="JOSM" upload="never" version="0.6"></osm>',
};
const tmTaskLayerParams = {
new_layer: false,
layer_locked: true,
download_policy: "never",
upload_policy: "never",
url: getTaskXmlUrl(project.projectId, selectedTasks).href,
};

return callJosmRemoteControl(formatJosmUrl('load_data', emptyTaskLayerParams)).then((result) =>
callJosmRemoteControl(formatJosmUrl('import', tmTaskLayerParams)),
);
return callJosmRemoteControl(formatJosmUrl('import', tmTaskLayerParams));
}

export function getImageryInfo(url) {
Expand Down Expand Up @@ -185,24 +182,18 @@ function loadImageryonJosm(project) {
}

function loadOsmDataToTasks(project, bbox, newLayer) {
const emptyOSMLayerParams = {
new_layer: newLayer,
layer_name: 'OSM Data',
data: '<?xml version="1.0" encoding="utf8"?><osm generator="JOSM" version="0.6"></osm>',
};
const loadAndZoomParams = {
left: bbox[0],
bottom: bbox[1],
right: bbox[2],
top: bbox[3],
changeset_comment: project.changesetComment,
changeset_source: project.imagery ? project.imagery : '',
new_layer: false,
new_layer: newLayer,
layer_name: 'OSM Data',
};

return callJosmRemoteControl(formatJosmUrl('load_data', emptyOSMLayerParams)).then((result) => {
return callJosmRemoteControl(formatJosmUrl('load_and_zoom', loadAndZoomParams));
});
return callJosmRemoteControl(formatJosmUrl('load_and_zoom', loadAndZoomParams));
}

export function formatJosmUrl(endpoint, params) {
Expand Down

0 comments on commit 9582691

Please sign in to comment.