forked from MapComplete/MapComplete
Fix: maproulette import flow
This commit is contained in:
parent
f80054558f
commit
5f7cc351c9
18 changed files with 331 additions and 114 deletions
|
@ -254,6 +254,7 @@ class ClosestNObjectFunc implements ExtraFunction {
|
|||
const maxDistance = options?.maxDistance ?? 500
|
||||
const uniqueTag: string | undefined = options?.uniqueTag
|
||||
let allFeatures: Feature[][]
|
||||
console.log("Calculating closest", options?.maxFeatures, "features around", feature, "in layer", features)
|
||||
if (typeof features === "string") {
|
||||
const name = features
|
||||
const bbox = GeoOperations.bbox(
|
||||
|
@ -414,7 +415,7 @@ class GetParsed implements ExtraFunction {
|
|||
if (value === undefined) {
|
||||
return undefined
|
||||
}
|
||||
if(typeof value !== "string"){
|
||||
if (typeof value !== "string") {
|
||||
return value
|
||||
}
|
||||
try {
|
||||
|
|
|
@ -105,6 +105,10 @@ export default class GeoJsonSource implements FeatureSource {
|
|||
let i = 0
|
||||
let skipped = 0
|
||||
for (const feature of json.features) {
|
||||
if(feature.geometry.type === "Point"){
|
||||
// See https://github.com/maproulette/maproulette-backend/issues/242
|
||||
feature.geometry.coordinates = feature.geometry.coordinates.map(Number)
|
||||
}
|
||||
const props = feature.properties
|
||||
for (const key in props) {
|
||||
if (props[key] === null) {
|
||||
|
|
|
@ -72,4 +72,23 @@ export default class Maproulette {
|
|||
throw `Failed to close task: ${response.status}`
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a status text into the corresponding number
|
||||
*
|
||||
* Maproulette.codeToIndex("Created") // => 0
|
||||
* Maproulette.codeToIndex("qdsf") // => undefined
|
||||
*
|
||||
*/
|
||||
public static codeToIndex(code: string) : number | undefined{
|
||||
if(code === "Created"){
|
||||
return Maproulette.STATUS_OPEN
|
||||
}
|
||||
for (let i = 0; i < 9; i++) {
|
||||
if(Maproulette.STATUS_MEANING[""+i] === code){
|
||||
return i
|
||||
}
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import {GeoIndexedStoreForLayer} from "./FeatureSource/Actors/GeoIndexedStore"
|
|||
import {IndexedFeatureSource} from "./FeatureSource/FeatureSource"
|
||||
import OsmObjectDownloader from "./Osm/OsmObjectDownloader"
|
||||
import {Utils} from "../Utils";
|
||||
import {GeoJSONFeature} from "maplibre-gl";
|
||||
import {UIEventSource} from "./UIEventSource";
|
||||
|
||||
/**
|
||||
|
@ -206,13 +205,13 @@ export default class MetaTagging {
|
|||
private static createFunctionForFeature([key, code, isStrict]: [string, string, boolean],
|
||||
helperFunctions: Record<ExtraFuncType, (feature: Feature) => Function>,
|
||||
layerId: string = "unkown layer"
|
||||
): ((feature: GeoJSONFeature, propertiesStore?: UIEventSource<any>) => void) | undefined {
|
||||
): ((feature: Feature, propertiesStore?: UIEventSource<any>) => void) | undefined {
|
||||
if (code === undefined) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
|
||||
const calculateAndAssign: ((feat: GeoJSONFeature, store?: UIEventSource<any>) => string | any) = (feat, store) => {
|
||||
const calculateAndAssign: ((feat: Feature, store?: UIEventSource<any>) => string | any) = (feat, store) => {
|
||||
try {
|
||||
let result = new Function("feat", "{" + ExtraFunctions.types.join(", ") + "}", "return " + code + ";")(feat, helperFunctions)
|
||||
if (result === "") {
|
||||
|
@ -259,7 +258,7 @@ export default class MetaTagging {
|
|||
if (isStrict) {
|
||||
return calculateAndAssign
|
||||
}
|
||||
return (feature: any, store?: UIEventSource<any>) => {
|
||||
return (feature: Feature, store?: UIEventSource<any>) => {
|
||||
delete feature.properties[key]
|
||||
Utils.AddLazyProperty(feature.properties, key, () => calculateAndAssign(feature, store))
|
||||
}
|
||||
|
|
|
@ -132,6 +132,10 @@ class CountryTagger extends SimpleMetaTagger {
|
|||
CountryTagger.coder
|
||||
.GetCountryCodeAsync(lon, lat)
|
||||
.then((countries) => {
|
||||
if(!countries){
|
||||
console.warn("Country coder returned ", countries)
|
||||
return
|
||||
}
|
||||
const oldCountry = feature.properties["_country"]
|
||||
const newCountry = countries[0].trim().toLowerCase()
|
||||
if (oldCountry !== newCountry) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue