forked from MapComplete/MapComplete
Merge plant_detection
This commit is contained in:
commit
25ec71aff1
15 changed files with 780 additions and 158 deletions
|
@ -2,15 +2,17 @@ import OsmChangeAction from "./OsmChangeAction";
|
|||
import {Changes} from "../Changes";
|
||||
import {ChangeDescription} from "./ChangeDescription";
|
||||
import {TagsFilter} from "../../Tags/TagsFilter";
|
||||
import {OsmTags} from "../../../Models/OsmFeature";
|
||||
|
||||
export default class ChangeTagAction extends OsmChangeAction {
|
||||
private readonly _elementId: string;
|
||||
private readonly _tagsFilter: TagsFilter;
|
||||
private readonly _currentTags: any;
|
||||
private readonly _currentTags: Record<string, string> | OsmTags;
|
||||
private readonly _meta: { theme: string, changeType: string };
|
||||
|
||||
constructor(elementId: string,
|
||||
tagsFilter: TagsFilter, currentTags: any, meta: {
|
||||
tagsFilter: TagsFilter,
|
||||
currentTags: Record<string, string>, meta: {
|
||||
theme: string,
|
||||
changeType: "answer" | "soft-delete" | "add-image" | string
|
||||
}) {
|
||||
|
|
346
Logic/Web/PlantNet.ts
Normal file
346
Logic/Web/PlantNet.ts
Normal file
File diff suppressed because one or more lines are too long
|
@ -354,6 +354,25 @@ export default class Wikidata {
|
|||
throw "Unknown id type: " + id
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a SPARQL-query, return the result
|
||||
*
|
||||
* @param keys: how variables are named. Every key not ending with 'Label' should appear in at least one statement
|
||||
* @param statements
|
||||
* @constructor
|
||||
*/
|
||||
public static async Sparql<T>(keys: string[], statements: string[]):Promise< (T & Record<string, {type: string, value: string}>) []> {
|
||||
const query = "SELECT "+keys.map(k => k.startsWith("?") ? k : "?"+k).join(" ")+"\n" +
|
||||
"WHERE\n" +
|
||||
"{\n" +
|
||||
statements.map(stmt => stmt.endsWith(".") ? stmt : stmt+".").join("\n") +
|
||||
" SERVICE wikibase:label { bd:serviceParam wikibase:language \"[AUTO_LANGUAGE]\". }\n" +
|
||||
"}"
|
||||
const url = wds.sparqlQuery(query)
|
||||
const result = await Utils.downloadJsonCached(url, 24 * 60 * 60 * 1000)
|
||||
return result.results.bindings
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a wikidata page
|
||||
* @returns the entity of the given value
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue