Skip to content

Commit

Permalink
Added RapiD editor to the list of editors
Browse files Browse the repository at this point in the history
  • Loading branch information
Zack LaVergne authored and pantierra committed Jul 22, 2019
1 parent 7922a0e commit a8787ca
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 3 deletions.
14 changes: 12 additions & 2 deletions client/app/admin/edit-project/edit-project.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,17 @@
id: false,
josm: false,
potlatch2: false,
fieldpapers: false
fieldpapers: false,
rapid: false
};

// Editors for validation
vm.validationEditors = {
id: false,
josm: false,
potlatch2: false,
fieldpapers: false
fieldpapers: false,
rapid: false
};

// Tags
Expand Down Expand Up @@ -1023,6 +1025,7 @@
vm.mappingEditors.josm = vm.project.mappingEditors.indexOf("JOSM") != -1;
vm.mappingEditors.potlatch2 = vm.project.mappingEditors.indexOf("POTLATCH_2") != -1;
vm.mappingEditors.fieldpapers = vm.project.mappingEditors.indexOf("FIELD_PAPERS") != -1;
vm.mappingEditors.rapid = vm.project.mappingEditors.indexOf("RAPID") != -1;
}
}

Expand All @@ -1043,6 +1046,9 @@
if (vm.mappingEditors.fieldpapers){
mappingEditorsArray.push("FIELD_PAPERS");
}
if (vm.mappingEditors.rapid){
mappingEditorsArray.push("RAPID");
}
return mappingEditorsArray;
}

Expand All @@ -1057,6 +1063,7 @@
vm.validationEditors.josm = vm.project.validationEditors.indexOf("JOSM") != -1;
vm.validationEditors.potlatch2 = vm.project.validationEditors.indexOf("POTLATCH_2") != -1;
vm.validationEditors.fieldpapers = vm.project.validationEditors.indexOf("FIELD_PAPERS") != -1;
vm.validationEditors.rapid = vm.project.validationEditors.indexOf("RAPID") != -1;
}
}

Expand All @@ -1077,6 +1084,9 @@
if (vm.validationEditors.fieldpapers){
validationEditorsArray.push("FIELD_PAPERS");
}
if (vm.validationEditors.rapid){
validationEditorsArray.push("RAPID");
}
return validationEditorsArray;
}

Expand Down
6 changes: 6 additions & 0 deletions client/app/admin/edit-project/edit-project.html
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,9 @@ <h1 class="section__aside-title">{{ 'In this area' | translate }}</h1>
<label class="form__option">
<input type="checkbox" ng-model="editProjectCtrl.mappingEditors.fieldpapers"/>{{ 'Field Papers' | translate }}
</label>
<label class="form__option">
<input type="checkbox" ng-model="editProjectCtrl.mappingEditors.rapid"/>{{ 'RapiD' | translate }}
</label>
<p class="error" ng-show="editProjectCtrl.project.mappingEditors.length < 1">
{{ 'You need at least one mapping editor.' | translate }}
</p>
Expand All @@ -527,6 +530,9 @@ <h1 class="section__aside-title">{{ 'In this area' | translate }}</h1>
<label class="form__option">
<input type="checkbox" ng-model="editProjectCtrl.validationEditors.fieldpapers"/>{{ 'Field Papers' | translate }}
</label>
<label class="form__option">
<input type="checkbox" ng-model="editProjectCtrl.validationEditors.rapid"/>{{ 'RapiD' | translate }}
</label>
<p class="error" ng-show="editProjectCtrl.project.validationEditors.length < 1">
{{ 'You need at least one validation editor.' | translate }}
</p>
Expand Down
15 changes: 15 additions & 0 deletions client/app/project/project.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -1604,6 +1604,15 @@
else if (editor === 'fieldpapers') {
editorService.launchFieldPapersEditor(center);
}
else if (editor === 'rapid') {
editorService.launchRapidEditor(
center,
changesetComment,
imageryUrl,
vm.projectData.projectId,
vm.getSelectTaskIds()
);
}
else if (editor === 'josm') {

if (taskCount > 1) {
Expand Down Expand Up @@ -2108,6 +2117,12 @@
"value": "fieldpapers"
});
}
if (editors.includes("RAPID")) {
result.push({
"name": "RapiD",
"value": "rapid"
});
}
return result;
};
}
Expand Down
34 changes: 34 additions & 0 deletions client/app/services/editor.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
launchFieldPapersEditor: launchFieldPapersEditor,
launchPotlatch2Editor: launchPotlatch2Editor,
launchIdEditor: launchIdEditor,
launchRapidEditor: launchRapidEditor,
getGPXUrl: getGPXUrl,
getOSMXMLUrl: getOSMXMLUrl
};
Expand Down Expand Up @@ -79,6 +80,39 @@
$window.open(url);
}

/**
* Launch the RapiD editor
* @param centroid
* @param changesetComment
* @param imageryUrl
* @param projectId
* @param taskId
*/
function launchRapidEditor(centroid, changesetComment, imageryUrl, projectId, taskId){
var base = 'https://www.mapwith.ai/rapid?';
var zoom = mapService.getOSMMap().getView().getZoom();
var url = base + '#map=' +
[zoom, centroid[1], centroid[0]].join('/');
// Add changeset comment
var changeset = ''; // default to empty string
if (changesetComment && changesetComment !== ''){
changeset = changesetComment;
}
url += '&comment=' + encodeURIComponent(changeset);
// Add imagery
if (imageryUrl && imageryUrl !== '') {
// url is supposed to look like tms[22]:http://hiu...
var urlForImagery = imageryUrl.substring(imageryUrl.indexOf('http'));
urlForImagery = urlForImagery.replace('zoom', 'z');
url += "&background=custom:" + encodeURIComponent(urlForImagery);
}
// Add GPX
if (projectId && projectId !== '' && taskId && taskId !== '') {
url += "&gpx=" + getGPXUrl(projectId, taskId);
}
$window.open(url);
}

/**
* Round to a certain amount of decimals
* @param input
Expand Down
2 changes: 1 addition & 1 deletion server/models/dtos/project_dto.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def is_known_editor(value):
except KeyError:
raise ValidationError(f'Unknown editor: {value} Valid values are {Editors.ID.name}, '
f'{Editors.JOSM.name}, {Editors.POTLATCH_2.name}, '
f'{Editors.FIELD_PAPERS.name}')
f'{Editors.FIELD_PAPERS.name}, {Editors.RAPID.name}')


def is_known_task_creation_mode(value):
Expand Down
1 change: 1 addition & 0 deletions server/models/postgis/statuses.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,4 @@ class Editors(Enum):
JOSM = 1
POTLATCH_2 = 2
FIELD_PAPERS = 3
RAPID = 4

0 comments on commit a8787ca

Please sign in to comment.