forked from MapComplete/MapComplete
chore: automated housekeeping...
This commit is contained in:
parent
a190597905
commit
087e639020
382 changed files with 29496 additions and 2675 deletions
|
|
@ -1,4 +1,8 @@
|
|||
import { SpecialVisualization, SpecialVisualizationState, SpecialVisualizationSvelte } from "../SpecialVisualization"
|
||||
import {
|
||||
SpecialVisualization,
|
||||
SpecialVisualizationState,
|
||||
SpecialVisualizationSvelte,
|
||||
} from "../SpecialVisualization"
|
||||
import Maproulette from "../../Logic/Maproulette"
|
||||
import SvelteUIElement from "../Base/SvelteUIElement"
|
||||
import { PointImportButtonViz } from "../Popup/ImportButtons/PointImportButtonViz"
|
||||
|
|
@ -28,15 +32,15 @@ class MaprouletteSetStatusVis extends SpecialVisualizationSvelte {
|
|||
"\n" +
|
||||
"```json\n" +
|
||||
"{\n" +
|
||||
" \"id\": \"mark_duplicate\",\n" +
|
||||
" \"render\": {\n" +
|
||||
" \"special\": {\n" +
|
||||
" \"type\": \"maproulette_set_status\",\n" +
|
||||
" \"message\": {\n" +
|
||||
" \"en\": \"Mark as not found or false positive\"\n" +
|
||||
' "id": "mark_duplicate",\n' +
|
||||
' "render": {\n' +
|
||||
' "special": {\n' +
|
||||
' "type": "maproulette_set_status",\n' +
|
||||
' "message": {\n' +
|
||||
' "en": "Mark as not found or false positive"\n' +
|
||||
" },\n" +
|
||||
" \"status\": \"2\",\n" +
|
||||
" \"image\": \"close\"\n" +
|
||||
' "status": "2",\n' +
|
||||
' "image": "close"\n' +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
"}\n" +
|
||||
|
|
@ -73,14 +77,7 @@ class MaprouletteSetStatusVis extends SpecialVisualizationSvelte {
|
|||
]
|
||||
|
||||
constr(state, tagsSource, args) {
|
||||
let [
|
||||
message,
|
||||
image,
|
||||
message_closed,
|
||||
statusToSet,
|
||||
maproulette_id_key,
|
||||
askFeedback,
|
||||
] = args
|
||||
let [message, image, message_closed, statusToSet, maproulette_id_key, askFeedback] = args
|
||||
if (image === "") {
|
||||
image = "confirm"
|
||||
}
|
||||
|
|
@ -104,7 +101,8 @@ class MaprouletteSetStatusVis extends SpecialVisualizationSvelte {
|
|||
class LinkedDataFromWebsite extends SpecialVisualization {
|
||||
funcName = "linked_data_from_website"
|
||||
group = "data_import"
|
||||
docs = "Attempts to load (via a proxy) the specified website and parsed ld+json from there. Suitable data will be offered to import into OSM. Note: this element is added by default"
|
||||
docs =
|
||||
"Attempts to load (via a proxy) the specified website and parsed ld+json from there. Suitable data will be offered to import into OSM. Note: this element is added by default"
|
||||
args = [
|
||||
{
|
||||
name: "key",
|
||||
|
|
@ -152,88 +150,74 @@ class LinkedDataFromWebsite extends SpecialVisualization {
|
|||
tags: UIEventSource<Record<string, string>>,
|
||||
argument: string[],
|
||||
feature: Feature,
|
||||
layer: LayerConfig,
|
||||
layer: LayerConfig
|
||||
): BaseUIElement {
|
||||
const key = argument[0] ?? "website"
|
||||
const useProxy = argument[1] !== "no"
|
||||
const readonly = argument[3] === "readonly"
|
||||
const isClosed = (argument[4] ?? "yes") === "yes"
|
||||
|
||||
const countryStore: Store<string | undefined> = tags.mapD(
|
||||
(tags) => tags._country,
|
||||
)
|
||||
const countryStore: Store<string | undefined> = tags.mapD((tags) => tags._country)
|
||||
const sourceUrl: Store<string | undefined> = tags.mapD((tags) => {
|
||||
if (!tags[key] || tags[key] === "undefined") {
|
||||
return null
|
||||
}
|
||||
return tags[key]
|
||||
})
|
||||
const externalData: Store<{ success: GeoJsonProperties } | { error }> =
|
||||
sourceUrl.bindD(
|
||||
(url) => {
|
||||
const country = countryStore.data
|
||||
if (url.startsWith("https://data.velopark.be/")) {
|
||||
return Stores.FromPromiseWithErr(
|
||||
(async () => {
|
||||
try {
|
||||
const loadAll =
|
||||
layer.id.toLowerCase().indexOf("maproulette") >=
|
||||
0 // Dirty hack
|
||||
const features =
|
||||
await LinkedDataLoader.fetchVeloparkEntry(
|
||||
url,
|
||||
loadAll,
|
||||
)
|
||||
const feature =
|
||||
features.find(
|
||||
(f) => f.properties["ref:velopark"] === url,
|
||||
) ?? features[0]
|
||||
const properties = feature.properties
|
||||
properties["ref:velopark"] = url
|
||||
console.log(
|
||||
"Got properties from velopark:",
|
||||
properties,
|
||||
)
|
||||
return properties
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
throw e
|
||||
}
|
||||
})(),
|
||||
)
|
||||
}
|
||||
if (country === undefined) {
|
||||
return undefined
|
||||
}
|
||||
const externalData: Store<{ success: GeoJsonProperties } | { error }> = sourceUrl.bindD(
|
||||
(url) => {
|
||||
const country = countryStore.data
|
||||
if (url.startsWith("https://data.velopark.be/")) {
|
||||
return Stores.FromPromiseWithErr(
|
||||
(async () => {
|
||||
try {
|
||||
return await LinkedDataLoader.fetchJsonLd(
|
||||
const loadAll = layer.id.toLowerCase().indexOf("maproulette") >= 0 // Dirty hack
|
||||
const features = await LinkedDataLoader.fetchVeloparkEntry(
|
||||
url,
|
||||
{ country },
|
||||
useProxy ? "proxy" : "fetch-lod",
|
||||
loadAll
|
||||
)
|
||||
const feature =
|
||||
features.find((f) => f.properties["ref:velopark"] === url) ??
|
||||
features[0]
|
||||
const properties = feature.properties
|
||||
properties["ref:velopark"] = url
|
||||
console.log("Got properties from velopark:", properties)
|
||||
return properties
|
||||
} catch (e) {
|
||||
console.log(
|
||||
"Could not get with proxy/download LOD, attempting to download directly. Error for ",
|
||||
url,
|
||||
"is",
|
||||
e,
|
||||
)
|
||||
return await LinkedDataLoader.fetchJsonLd(
|
||||
url,
|
||||
{ country },
|
||||
"fetch-raw",
|
||||
)
|
||||
console.error(e)
|
||||
throw e
|
||||
}
|
||||
})(),
|
||||
})()
|
||||
)
|
||||
},
|
||||
[countryStore],
|
||||
)
|
||||
}
|
||||
if (country === undefined) {
|
||||
return undefined
|
||||
}
|
||||
return Stores.FromPromiseWithErr(
|
||||
(async () => {
|
||||
try {
|
||||
return await LinkedDataLoader.fetchJsonLd(
|
||||
url,
|
||||
{ country },
|
||||
useProxy ? "proxy" : "fetch-lod"
|
||||
)
|
||||
} catch (e) {
|
||||
console.log(
|
||||
"Could not get with proxy/download LOD, attempting to download directly. Error for ",
|
||||
url,
|
||||
"is",
|
||||
e
|
||||
)
|
||||
return await LinkedDataLoader.fetchJsonLd(url, { country }, "fetch-raw")
|
||||
}
|
||||
})()
|
||||
)
|
||||
},
|
||||
[countryStore]
|
||||
)
|
||||
|
||||
externalData.addCallbackAndRunD((lod) =>
|
||||
console.log("linked_data_from_website received the following data:", lod),
|
||||
console.log("linked_data_from_website received the following data:", lod)
|
||||
)
|
||||
|
||||
return new Toggle(
|
||||
|
|
@ -248,7 +232,7 @@ class LinkedDataFromWebsite extends SpecialVisualization {
|
|||
collapsed: isClosed,
|
||||
}),
|
||||
undefined,
|
||||
sourceUrl.map((url) => !!url),
|
||||
sourceUrl.map((url) => !!url)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -274,14 +258,15 @@ class CompareData extends SpecialVisualization {
|
|||
doc: "If 'yes', will not show 'apply'-buttons",
|
||||
},
|
||||
]
|
||||
docs = "Gives an interactive element which shows a tag comparison between the OSM-object and the upstream object. This allows to copy some or all tags into OSM"
|
||||
docs =
|
||||
"Gives an interactive element which shows a tag comparison between the OSM-object and the upstream object. This allows to copy some or all tags into OSM"
|
||||
|
||||
constr(
|
||||
state: SpecialVisualizationState,
|
||||
tagSource: UIEventSource<Record<string, string>>,
|
||||
args: string[],
|
||||
feature: Feature,
|
||||
layer: LayerConfig,
|
||||
layer: LayerConfig
|
||||
): BaseUIElement {
|
||||
const url = args[0]
|
||||
const readonly = args[3] === "yes"
|
||||
|
|
@ -296,7 +281,6 @@ class CompareData extends SpecialVisualization {
|
|||
externalData,
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
export class DataImportSpecialVisualisations {
|
||||
public static initList(): (SpecialVisualization & { group })[] {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue