forked from MapComplete/MapComplete
Themes(benches): improve openbenches support
This commit is contained in:
parent
e456e61ebf
commit
8212faa6e5
5 changed files with 21 additions and 15 deletions
|
@ -90,9 +90,10 @@
|
||||||
},
|
},
|
||||||
"minzoom": 10,
|
"minzoom": 10,
|
||||||
"source": {
|
"source": {
|
||||||
"#": "Alternatively, if combined with `geojsonZoomLevel`, use geoJson with {y_min}, {y_max}, {x_min} and {x_max}. Only replace <id> in the next string: `https://maproulette.org/api/v2/challenge/view/<id>?bbox={x_min},{y_max},{x_max},{y_min}`",
|
|
||||||
"geoJsonZoomLevel": 12,
|
"geoJsonZoomLevel": 12,
|
||||||
"idKey": "",
|
"#": "The 'staging'-url is a test maproulette",
|
||||||
|
"#geoJson": "https://staging.maproulette.org/api/v2/challenge/view/70?bbox={x_min},{y_max},{x_max},{y_min}",
|
||||||
|
|
||||||
"geoJson": "https://maproulette.org/api/v2/challenge/view/53298?bbox={x_min},{y_max},{x_max},{y_min}"
|
"geoJson": "https://maproulette.org/api/v2/challenge/view/53298?bbox={x_min},{y_max},{x_max},{y_min}"
|
||||||
},
|
},
|
||||||
"calculatedTags": [
|
"calculatedTags": [
|
||||||
|
|
|
@ -14,6 +14,7 @@ import OsmChangeAction from "../../src/Logic/Osm/Actions/OsmChangeAction"
|
||||||
import ChangeTagAction from "../../src/Logic/Osm/Actions/ChangeTagAction"
|
import ChangeTagAction from "../../src/Logic/Osm/Actions/ChangeTagAction"
|
||||||
import { Tag as OsmTag } from "../../src/Logic/Tags/Tag"
|
import { Tag as OsmTag } from "../../src/Logic/Tags/Tag"
|
||||||
import { Changes } from "../../src/Logic/Osm/Changes"
|
import { Changes } from "../../src/Logic/Osm/Changes"
|
||||||
|
import ScriptUtils from "../ScriptUtils"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Note:
|
* Note:
|
||||||
|
@ -264,10 +265,8 @@ class Openbenches extends Script {
|
||||||
let createTest = false
|
let createTest = false
|
||||||
|
|
||||||
const osmData = await this.getAlreadyImported()
|
const osmData = await this.getAlreadyImported()
|
||||||
const openBenches = JSON.parse(readFileSync("openbenches_export_josm_.geojson", "utf-8"))
|
|
||||||
await this.conflate(osmData, openBenches)
|
|
||||||
// rmSync(dbFile)
|
// rmSync(dbFile)
|
||||||
/*
|
|
||||||
if(!existsSync(dbFile)){
|
if(!existsSync(dbFile)){
|
||||||
console.log("No database file found at "+dbFile+", recreating the database")
|
console.log("No database file found at "+dbFile+", recreating the database")
|
||||||
await this.buildDatabase("/home/pietervdvn/git/openbenches.org/database", dbFile)
|
await this.buildDatabase("/home/pietervdvn/git/openbenches.org/database", dbFile)
|
||||||
|
@ -312,13 +311,17 @@ class Openbenches extends Script {
|
||||||
}, null, " "), "utf-8")
|
}, null, " "), "utf-8")
|
||||||
|
|
||||||
const maproulette = features.map(f => {
|
const maproulette = features.map(f => {
|
||||||
f.properties = {tags: JSON.stringify(f.properties)}
|
const properties = {tags: JSON.stringify(f.properties)}
|
||||||
|
properties["id"] = "openbenches/"+f.properties["openbenches:id"]
|
||||||
|
return {...f, properties}
|
||||||
})
|
})
|
||||||
writeFileSync(`openbenches_export_maproulette_${createTest ? "_test" : ""}.geojson`, JSON.stringify({
|
writeFileSync(`openbenches_export_maproulette${createTest ? "_test" : ""}.geojson`, JSON.stringify({
|
||||||
type: "FeatureCollection", features: maproulette,
|
type: "FeatureCollection", features: maproulette,
|
||||||
}, null, " "), "utf-8")
|
}, null, " "), "utf-8")
|
||||||
|
|
||||||
*/
|
|
||||||
|
const openBenches = JSON.parse(readFileSync("openbenches_export_josm_.geojson", "utf-8"))
|
||||||
|
// await this.conflate(osmData, openBenches)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
export let message: string
|
export let message: string
|
||||||
export let image: string
|
export let image: string
|
||||||
export let message_closed: string
|
export let message_closed: string
|
||||||
export let statusToSet: string
|
export let statusToSet: number
|
||||||
export let maproulette_id_key: string
|
export let maproulette_id_key: string
|
||||||
|
|
||||||
export let askFeedback: string = ""
|
export let askFeedback: string = ""
|
||||||
|
@ -38,14 +38,14 @@
|
||||||
async function apply() {
|
async function apply() {
|
||||||
const maproulette_id = tags.data[maproulette_id_key] ?? tags.data.mr_taskId ?? tags.data.id
|
const maproulette_id = tags.data[maproulette_id_key] ?? tags.data.mr_taskId ?? tags.data.id
|
||||||
try {
|
try {
|
||||||
const statusIndex = Maproulette.codeToIndex(statusToSet) ?? Number(statusToSet)
|
const statusIndex: number = Maproulette.codeToIndex(""+statusToSet) ?? Number(statusToSet)
|
||||||
if(statusIndex !== 0){
|
if(statusIndex !== 0){
|
||||||
await Maproulette.singleton.closeTask(Number(maproulette_id), statusIndex, state, {
|
await Maproulette.singleton.closeTask(Number(maproulette_id), statusIndex, state, {
|
||||||
comment: feedback,
|
comment: feedback,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
tags.data["mr_taskStatus"] = maprouletteStatus[statusIndex]
|
tags.data["mr_taskStatus"] = maprouletteStatus[statusIndex]
|
||||||
tags.data.status = statusToSet
|
tags.data.status = ""+statusToSet
|
||||||
tags.ping()
|
tags.ping()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
|
@ -61,7 +61,7 @@
|
||||||
<Loading>
|
<Loading>
|
||||||
<Tr t={Translations.t.general.loading} />
|
<Tr t={Translations.t.general.loading} />
|
||||||
</Loading>
|
</Loading>
|
||||||
{:else if $status === Maproulette.STATUS_OPEN || (statusToSet === ""+Maproulette.STATUS_OPEN && $status !== Maproulette.STATUS_OPEN)}
|
{:else if $status !== statusToSet && ($status === Maproulette.STATUS_OPEN || statusToSet === Maproulette.STATUS_OPEN)}
|
||||||
{#if askFeedback !== "" && askFeedback !== undefined}
|
{#if askFeedback !== "" && askFeedback !== undefined}
|
||||||
<div class="interactive flex flex-col gap-y-1 border border-dashed border-gray-500 p-1">
|
<div class="interactive flex flex-col gap-y-1 border border-dashed border-gray-500 p-1">
|
||||||
<h3>{askFeedback}</h3>
|
<h3>{askFeedback}</h3>
|
||||||
|
|
|
@ -55,7 +55,7 @@ export class PointImportButtonViz extends SpecialVisualizationSvelte {
|
||||||
feature = GeoOperations.centerpoint(feature)
|
feature = GeoOperations.centerpoint(feature)
|
||||||
} else {
|
} else {
|
||||||
return new SvelteUIElement(Tr, {
|
return new SvelteUIElement(Tr, {
|
||||||
t: Translations.t.general.add.import.wrongType.SetClass("alert"),
|
t: Translations.t.general.add.import.wrongType,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,14 +88,16 @@ class MaprouletteSetStatusVis extends SpecialVisualizationSvelte {
|
||||||
if (maproulette_id_key === "" || maproulette_id_key === undefined) {
|
if (maproulette_id_key === "" || maproulette_id_key === undefined) {
|
||||||
maproulette_id_key = "mr_taskId"
|
maproulette_id_key = "mr_taskId"
|
||||||
}
|
}
|
||||||
statusToSet = statusToSet ?? "1"
|
if(statusToSet === ""){
|
||||||
|
statusToSet = "1"
|
||||||
|
}
|
||||||
return new SvelteUIElement(MaprouletteSetStatus, {
|
return new SvelteUIElement(MaprouletteSetStatus, {
|
||||||
state,
|
state,
|
||||||
tags,
|
tags,
|
||||||
message,
|
message,
|
||||||
image,
|
image,
|
||||||
message_closed,
|
message_closed,
|
||||||
statusToSet,
|
statusToSet: Number(statusToSet ?? 1),
|
||||||
maproulette_id_key,
|
maproulette_id_key,
|
||||||
askFeedback,
|
askFeedback,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue