Themes(benches): improve openbenches support

This commit is contained in:
Pieter Vander Vennet 2025-10-06 00:33:53 +02:00
parent e456e61ebf
commit 8212faa6e5
5 changed files with 21 additions and 15 deletions

View file

@ -90,9 +90,10 @@
},
"minzoom": 10,
"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,
"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}"
},
"calculatedTags": [

View file

@ -14,6 +14,7 @@ import OsmChangeAction from "../../src/Logic/Osm/Actions/OsmChangeAction"
import ChangeTagAction from "../../src/Logic/Osm/Actions/ChangeTagAction"
import { Tag as OsmTag } from "../../src/Logic/Tags/Tag"
import { Changes } from "../../src/Logic/Osm/Changes"
import ScriptUtils from "../ScriptUtils"
/**
* Note:
@ -264,10 +265,8 @@ class Openbenches extends Script {
let createTest = false
const osmData = await this.getAlreadyImported()
const openBenches = JSON.parse(readFileSync("openbenches_export_josm_.geojson", "utf-8"))
await this.conflate(osmData, openBenches)
// rmSync(dbFile)
/*
if(!existsSync(dbFile)){
console.log("No database file found at "+dbFile+", recreating the database")
await this.buildDatabase("/home/pietervdvn/git/openbenches.org/database", dbFile)
@ -312,13 +311,17 @@ class Openbenches extends Script {
}, null, " "), "utf-8")
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,
}, null, " "), "utf-8")
*/
const openBenches = JSON.parse(readFileSync("openbenches_export_josm_.geojson", "utf-8"))
// await this.conflate(osmData, openBenches)
}
}

View file

@ -16,7 +16,7 @@
export let message: string
export let image: string
export let message_closed: string
export let statusToSet: string
export let statusToSet: number
export let maproulette_id_key: string
export let askFeedback: string = ""
@ -38,14 +38,14 @@
async function apply() {
const maproulette_id = tags.data[maproulette_id_key] ?? tags.data.mr_taskId ?? tags.data.id
try {
const statusIndex = Maproulette.codeToIndex(statusToSet) ?? Number(statusToSet)
const statusIndex: number = Maproulette.codeToIndex(""+statusToSet) ?? Number(statusToSet)
if(statusIndex !== 0){
await Maproulette.singleton.closeTask(Number(maproulette_id), statusIndex, state, {
comment: feedback,
})
}
tags.data["mr_taskStatus"] = maprouletteStatus[statusIndex]
tags.data.status = statusToSet
tags.data.status = ""+statusToSet
tags.ping()
} catch (e) {
console.error(e)
@ -61,7 +61,7 @@
<Loading>
<Tr t={Translations.t.general.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}
<div class="interactive flex flex-col gap-y-1 border border-dashed border-gray-500 p-1">
<h3>{askFeedback}</h3>

View file

@ -55,7 +55,7 @@ export class PointImportButtonViz extends SpecialVisualizationSvelte {
feature = GeoOperations.centerpoint(feature)
} else {
return new SvelteUIElement(Tr, {
t: Translations.t.general.add.import.wrongType.SetClass("alert"),
t: Translations.t.general.add.import.wrongType,
})
}
}

View file

@ -88,14 +88,16 @@ class MaprouletteSetStatusVis extends SpecialVisualizationSvelte {
if (maproulette_id_key === "" || maproulette_id_key === undefined) {
maproulette_id_key = "mr_taskId"
}
statusToSet = statusToSet ?? "1"
if(statusToSet === ""){
statusToSet = "1"
}
return new SvelteUIElement(MaprouletteSetStatus, {
state,
tags,
message,
image,
message_closed,
statusToSet,
statusToSet: Number(statusToSet ?? 1),
maproulette_id_key,
askFeedback,
})