Skip to content

Commit

Permalink
Challenge Rapid Dataset support (#2494)
Browse files Browse the repository at this point in the history
* add support for injecting datasets to rapid data param

* encode the data param url

---------

Co-authored-by: Jake Low <[email protected]>
  • Loading branch information
jschwarz2030 and jake-low authored Nov 13, 2024
1 parent 3807890 commit 7e09159
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lang/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@
"Admin.EditChallenge.form.preferredTags.label": "Preferred MR Tags",
"Admin.EditChallenge.form.presets.description": "Restrict the types of OSM features presented to mappers in iD by default when working on your tasks, helping to keep them focused on mapping things relevant to your challenge. For example, if your challenge is about mapping buildings, you could enable only presets related to buildings and then mappers would not be presented with the option to map an area as, say, a park or a lake.",
"Admin.EditChallenge.form.presets.label": "Restrict iD Editor Presets",
"Admin.EditChallenge.form.datasetUrl.description": "Optionally include a Rapid Editor dataset URL. Datasets can be used to provide geospatial data layers that can be overlaid, analyzed, and edited to create or update maps accurately",
"Admin.EditChallenge.form.datasetUrl.label": "Rapid Dataset URL",
"Admin.EditChallenge.form.remoteGeoJson.description": "Remote URL location from which to retrieve the GeoJSON",
"Admin.EditChallenge.form.remoteGeoJson.label": "I have a URL to the GeoJSON data",
"Admin.EditChallenge.form.remoteGeoJson.placeholder": "https://www.example.com/geojson.json",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,17 @@ will not be able to make sense of it.
"Insert a custom base map URL here. E.g. `https://'{s}'.tile.openstreetmap.org/'{z}'/'{x}'/'{y}'.png`",
},

datasetUrlLabel: {
id: "Admin.EditChallenge.form.datasetUrl.label",
defaultMessage: "Rapid Dataset URL",
},

datasetUrlDescription: {
id: "Admin.EditChallenge.form.datasetUrl.description",
defaultMessage:
"Optionally include a Rapid Editor dataset URL. Datasets can be used to provide geospatial data layers that can be overlaid, analyzed, and edited to create or update maps accurately",
},

exportablePropertiesLabel: {
id: "Admin.EditChallenge.form.exportableProperties.label",
defaultMessage: "Properties to export in CSV",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ export const jsSchema = (intl) => {
enumNames: _map(defaultBasemapChoices, 'name'),
default: ChallengeBasemap.none.toString(),
},
datasetUrl: {
title: intl.formatMessage(messages.datasetUrlLabel),
type: "string",
default: "",
},
},
dependencies: { // Only show customBasemap if defaultBasemap set to Custom
defaultBasemap: {
Expand Down Expand Up @@ -87,7 +92,7 @@ export const uiSchema = (intl, user, challengeData, extraErrors, options={}) =>
const toggleCollapsed = options.longForm && options.toggleCollapsed ? () => options.toggleCollapsed(STEP_ID) : undefined

return {
"ui:order": ["defaultBasemap", "customBasemap"],
"ui:order": ["defaultBasemap", "customBasemap", "datasetUrl"],
defaultBasemap: {
"ui:widget": "select",
"ui:help": intl.formatMessage(messages.defaultBasemapDescription),
Expand All @@ -100,5 +105,11 @@ export const uiSchema = (intl, user, challengeData, extraErrors, options={}) =>
"ui:help": intl.formatMessage(messages.customBasemapDescription),
"ui:collapsed": isCollapsed,
},
datasetUrl: {
"ui:emptyValue": "",
"ui:help": intl.formatMessage(messages.datasetUrlDescription),
"ui:collapsed": isCollapsed,
"ui:toggleCollapsed": toggleCollapsed
}
}
}
3 changes: 2 additions & 1 deletion src/services/Challenge/Challenge.js
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ export const fetchChallenges = function (
return function (dispatch) {
// The server wants keywords/tags represented as a comma-separated string.
let challengeData = _clone(originalChallengeData);

if (_isArray(challengeData.tags)) {
challengeData.tags = challengeData.tags.map(t => t.trim()).join(",");
} else if (challengeData.tags) {
Expand Down Expand Up @@ -1007,6 +1007,7 @@ export const fetchChallenges = function (
"overpassQL",
"overpassTargetType",
"parent",
"datasetUrl",
"remoteGeoJson",
"status",
"tags",
Expand Down
5 changes: 5 additions & 0 deletions src/services/Editor/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,10 @@ export const constructRapidURI = function (task, mapBounds, options, replacedCom
const sourceComponent =
"source=" + encodeURIComponent(task.parent.checkinSource);

const datasetUrl = _get(task.parent, "datasetUrl")
? "data=" + encodeURIComponent(task.parent.datasetUrl)
: null;

const presetsComponent = _isEmpty(task.parent.presets)
? null
: "presets=" + encodeURIComponent(task.parent.presets.join(","));
Expand All @@ -366,6 +370,7 @@ export const constructRapidURI = function (task, mapBounds, options, replacedCom
presetsComponent,
photoOverlayComponent,
mapUriComponent,
datasetUrl
]).join("&")
);
};
Expand Down

0 comments on commit 7e09159

Please sign in to comment.