forked from MapComplete/MapComplete
Concept for rendering maproulette tasks
This commit is contained in:
parent
063d7e4637
commit
a7f2c26a1d
2 changed files with 167 additions and 0 deletions
|
@ -82,6 +82,28 @@ export default class GeoJsonSource implements FeatureSourceForLayer, Tiled {
|
||||||
Utils.downloadJsonCached(url, 60 * 60)
|
Utils.downloadJsonCached(url, 60 * 60)
|
||||||
.then(json => {
|
.then(json => {
|
||||||
self.state.setData("loaded")
|
self.state.setData("loaded")
|
||||||
|
// TODO: move somewhere else, just for testing
|
||||||
|
// Check for maproulette data
|
||||||
|
if (url.startsWith("https://maproulette.org/api/v2/")) {
|
||||||
|
console.log("MapRoulette data detected")
|
||||||
|
const data = json;
|
||||||
|
let maprouletteFeatures: any[] = [];
|
||||||
|
data.forEach(element => {
|
||||||
|
maprouletteFeatures.push({
|
||||||
|
type: "Feature",
|
||||||
|
geometry: {
|
||||||
|
type: "Point",
|
||||||
|
coordinates: [element.point.lng, element.point.lat]
|
||||||
|
},
|
||||||
|
properties: {
|
||||||
|
// Map all properties to the feature
|
||||||
|
...element,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
json.features = maprouletteFeatures;
|
||||||
|
}
|
||||||
|
|
||||||
if (json.features === undefined || json.features === null) {
|
if (json.features === undefined || json.features === null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
145
assets/themes/maproulette/maproulette.json
Normal file
145
assets/themes/maproulette/maproulette.json
Normal file
|
@ -0,0 +1,145 @@
|
||||||
|
{
|
||||||
|
"id": "maproulette",
|
||||||
|
"title": {
|
||||||
|
"en": "MapRoulette Test"
|
||||||
|
},
|
||||||
|
"description": {
|
||||||
|
"en": "MapRoulette Test"
|
||||||
|
},
|
||||||
|
"version": "1.0.0",
|
||||||
|
"hideFromOverview": true,
|
||||||
|
"icon": "./assets/svg/bug.svg",
|
||||||
|
"maintainer": "",
|
||||||
|
"startLat": 0,
|
||||||
|
"startLon": 0,
|
||||||
|
"startZoom": 4,
|
||||||
|
"layers": [
|
||||||
|
{
|
||||||
|
"id": "maproulette",
|
||||||
|
"source": {
|
||||||
|
"geoJson": "https://maproulette.org/api/v2/tasks/box/{x_min}/{y_min}/{x_max}/{y_max}",
|
||||||
|
"geoJsonZoomLevel": 16,
|
||||||
|
"osmTags": "id~*"
|
||||||
|
},
|
||||||
|
"mapRendering": [
|
||||||
|
{
|
||||||
|
"location": [
|
||||||
|
"point",
|
||||||
|
"centroid"
|
||||||
|
],
|
||||||
|
"icon": {
|
||||||
|
"render": "pin:white",
|
||||||
|
"mappings": [
|
||||||
|
{
|
||||||
|
"if": "status=0",
|
||||||
|
"then": "pin:#959DFF"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"if": "status=1",
|
||||||
|
"then": "pin:#65D2DA"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"if": "status=2",
|
||||||
|
"then": "pin:#F7BB59"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"if": "status=3",
|
||||||
|
"then": "pin:#F7BB59"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"if": "status=4",
|
||||||
|
"then": "pin:#737373"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"if": "status=5",
|
||||||
|
"then": "pin:#CCB186"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"if": "status=6",
|
||||||
|
"then": "pin:#FF5E63"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"if": "status=9",
|
||||||
|
"then": "pin:#FF349C"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"iconSize": "40,40,center"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"tagRenderings": [
|
||||||
|
{
|
||||||
|
"id": "link",
|
||||||
|
"render": "<a href='https://maproulette.org/challenge/{parentId}/task/{id}'>View this task</a>"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "status",
|
||||||
|
"render": "Current status: {status}",
|
||||||
|
"mappings": [
|
||||||
|
{
|
||||||
|
"if": "status=0",
|
||||||
|
"then": {
|
||||||
|
"en": "Task is created"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"if": "status=1",
|
||||||
|
"then": {
|
||||||
|
"en": "Task is fixed"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"if": "status=2",
|
||||||
|
"then": {
|
||||||
|
"en": "Task is a false positive"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"if": "status=3",
|
||||||
|
"then": {
|
||||||
|
"en": "Task is skipped"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"if": "status=4",
|
||||||
|
"then": {
|
||||||
|
"en": "Task is deleted"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"if": "status=5",
|
||||||
|
"then": {
|
||||||
|
"en": "Task is already fixed"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"if": "status=6",
|
||||||
|
"then": {
|
||||||
|
"en": "Task is marked as too hard"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"if": "status=9",
|
||||||
|
"then": {
|
||||||
|
"en": "Task is disabled"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"all_tags"
|
||||||
|
],
|
||||||
|
"description": {
|
||||||
|
"en": "Layer showing all tasks in MapRoulette"
|
||||||
|
},
|
||||||
|
"minzoom": 15,
|
||||||
|
"name": {
|
||||||
|
"en": "MapRoulette Tasks"
|
||||||
|
},
|
||||||
|
"title": {
|
||||||
|
"render": {
|
||||||
|
"en": "MapRoulette Item: {parentName}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue