Merge develop

This commit is contained in:
Pieter Vander Vennet 2024-01-28 03:27:17 +01:00
commit 94f39e89fe
174 changed files with 3695 additions and 3420 deletions

View file

@ -15,7 +15,7 @@ export interface ExtraFuncParams {
*/
getFeaturesWithin: (
layerId: string,
bbox: BBox,
bbox: BBox
) => Feature<Geometry, Record<string, string>>[][]
getFeatureById: (id: string) => Feature<Geometry, Record<string, string>>
}
@ -71,7 +71,7 @@ class EnclosingFunc implements ExtraFunction {
if (
GeoOperations.completelyWithin(
<Feature>feat,
<Feature<Polygon | MultiPolygon, any>>otherFeature,
<Feature<Polygon | MultiPolygon, any>>otherFeature
)
) {
result.push({ feat: otherFeature })
@ -162,7 +162,7 @@ class IntersectionFunc implements ExtraFunction {
for (const otherFeature of otherFeatures) {
const intersections = GeoOperations.LineIntersections(
feat,
<Feature<any, Record<string, string>>>otherFeature,
<Feature<any, Record<string, string>>>otherFeature
)
if (intersections.length === 0) {
continue
@ -192,7 +192,7 @@ class DistanceToFunc implements ExtraFunction {
// Feature._lon and ._lat is conveniently place by one of the other metatags
return GeoOperations.distanceBetween(
[arg0, lat],
GeoOperations.centerpointCoordinates(feature),
GeoOperations.centerpointCoordinates(feature)
)
}
if (typeof arg0 === "string") {
@ -207,7 +207,7 @@ class DistanceToFunc implements ExtraFunction {
// arg0 is probably a geojsonfeature
return GeoOperations.distanceBetween(
GeoOperations.centerpointCoordinates(arg0),
GeoOperations.centerpointCoordinates(feature),
GeoOperations.centerpointCoordinates(feature)
)
}
}
@ -253,29 +253,34 @@ class ClosestNObjectFunc implements ExtraFunction {
params: ExtraFuncParams,
feature: any,
features: string | string[] | Feature[],
options?: { maxFeatures?: number; uniqueTag?: string | undefined; maxDistance?: number },
options?: { maxFeatures?: number; uniqueTag?: string | undefined; maxDistance?: number }
): { feat: any; distance: number }[] {
const maxFeatures = options?.maxFeatures ?? 1
const maxDistance = options?.maxDistance ?? 500
const uniqueTag: string | undefined = options?.uniqueTag
let allFeatures: Feature[][]
if (typeof features === "string") {
features = [features]
} else {
allFeatures = []
for (const spec of features) {
if (typeof spec === "string") {
const name = spec
const bbox = GeoOperations.bbox(
GeoOperations.buffer(GeoOperations.bbox(feature), maxDistance),
)
const coors = <[number, number][]>bbox.geometry.coordinates
allFeatures.push(...params.getFeaturesWithin(name, new BBox(coors)))
} else {
allFeatures.push([spec])
}
}
let allFeatures: Feature[][] = []
for (const spec of features) {
if (typeof spec === "string") {
const name = spec
const bbox = GeoOperations.bbox(
GeoOperations.buffer(GeoOperations.bbox(feature), maxDistance)
)
const coors = <[number, number][]>bbox.geometry.coordinates
allFeatures.push(...params.getFeaturesWithin(name, new BBox(coors)))
} else {
allFeatures.push([spec])
}
}
console.log(
"Determining features which are close to",
features,
"other features:",
allFeatures
)
if (features === undefined) {
return
}
@ -283,7 +288,7 @@ class ClosestNObjectFunc implements ExtraFunction {
const selfCenter = GeoOperations.centerpointCoordinates(feature)
let closestFeatures: { feat: any; distance: number }[] = []
for (const feats of allFeatures) {
for (const feats of allFeatures ?? []) {
for (const otherFeature of feats) {
if (otherFeature.properties === undefined) {
console.warn("OtherFeature does not have properties:", otherFeature)
@ -296,14 +301,14 @@ class ClosestNObjectFunc implements ExtraFunction {
}
const distance = GeoOperations.distanceBetween(
GeoOperations.centerpointCoordinates(otherFeature),
selfCenter,
selfCenter
)
if (distance === undefined || distance === null || isNaN(distance)) {
console.error(
"Could not calculate the distance between",
feature,
"and",
otherFeature,
otherFeature
)
throw "Undefined distance!"
}
@ -313,7 +318,7 @@ class ClosestNObjectFunc implements ExtraFunction {
"Got a suspiciously zero distance between",
otherFeature,
"and self-feature",
feature,
feature
)
}
@ -347,7 +352,7 @@ class ClosestNObjectFunc implements ExtraFunction {
const uniqueTagsMatch =
otherFeature.properties[uniqueTag] !== undefined &&
closestFeature.feat.properties[uniqueTag] ===
otherFeature.properties[uniqueTag]
otherFeature.properties[uniqueTag]
if (uniqueTagsMatch) {
targetIndex = -1
if (closestFeature.distance > distance) {
@ -440,7 +445,7 @@ class GetParsed implements ExtraFunction {
return parsed
} catch (e) {
console.warn(
"Could not parse property " + key + " due to: " + e + ", the value is " + value,
"Could not parse property " + key + " due to: " + e + ", the value is " + value
)
return undefined
}
@ -464,10 +469,10 @@ export class ExtraFunctions {
]),
"To enable this feature, add a field `calculatedTags` in the layer object, e.g.:",
"````",
"\"calculatedTags\": [",
" \"_someKey=javascript-expression (lazy execution)\",",
" \"_some_other_key:=javascript expression (strict execution)",
" \"name=feat.properties.name ?? feat.properties.ref ?? feat.properties.operator\",",
'"calculatedTags": [',
' "_someKey=javascript-expression (lazy execution)",',
' "_some_other_key:=javascript expression (strict execution)',
' "name=feat.properties.name ?? feat.properties.ref ?? feat.properties.operator",',
" \"_distanceCloserThen3Km=distanceTo(feat)( some_lon, some_lat) < 3 ? 'yes' : 'no'\" ",
" ]",
"````",
@ -506,7 +511,7 @@ export class ExtraFunctions {
]
public static constructHelpers(
params: ExtraFuncParams,
params: ExtraFuncParams
): Record<ExtraFuncType, (feature: Feature) => Function> {
const record: Record<string, (feature: GeoJSONFeature) => Function> = {}
for (const f of ExtraFunctions.allFuncs) {

View file

@ -159,7 +159,6 @@ export default class FavouritesFeatureSource extends StaticFeatureSource {
public removeFavourite(feature: Feature, tags?: UIEventSource<Record<string, string>>) {
const id = feature.properties.id.replace("/", "-")
const pref = this._osmConnection.GetPreference("favourite-" + id)
this._osmConnection.preferencesHandler.removeAllWithPrefix("mapcomplete-favourite-" + id)
if (tags) {
delete tags.data._favourite

View file

@ -46,7 +46,6 @@ export default class LayoutSource extends FeatureSourceMerger {
)
const overpassSource = LayoutSource.setupOverpass(
backend,
osmLayers,
bounds,
zoom,
@ -132,7 +131,6 @@ export default class LayoutSource extends FeatureSourceMerger {
}
private static setupOverpass(
backend: string,
osmLayers: LayerConfig[],
bounds: Store<BBox>,
zoom: Store<number>,

View file

@ -48,7 +48,7 @@ export default class NearbyFeatureSource implements FeatureSource {
flayer.layerDef.minzoom,
flayer.isDisplayed
)
calcSource.addCallbackAndRunD((features) => {
calcSource.addCallbackAndRunD(() => {
this.update()
})
this._allSources.push(calcSource)

View file

@ -103,7 +103,7 @@ export default class OverpassFeatureSource implements FeatureSource {
if (!result) {
return
}
const [bounds, date, updatedLayers] = result
const [bounds, _, __] = result
this._lastQueryBBox = bounds
}

View file

@ -133,7 +133,7 @@ export class Mapillary extends ImageProvider {
return [this.PrepareUrlAsync(key, value)]
}
public async DownloadAttribution(url: string): Promise<LicenseInfo> {
public async DownloadAttribution(_: string): Promise<LicenseInfo> {
const license = new LicenseInfo()
license.artist = undefined
license.license = "CC BY-SA 4.0"

View file

@ -15,11 +15,11 @@ export default class Maproulette {
public static readonly STATUS_MEANING = {
0: "Open",
1: "Fixed",
2: "False positive",
2: "False_positive",
3: "Skipped",
4: "Deleted",
5: "Already fixed",
6: "Too hard",
6: "Too_hard",
9: "Disabled",
}
public static singleton = new Maproulette()

View file

@ -416,7 +416,7 @@ export class OsmConnection {
): Promise<{ id: number }> {
if (this._dryRun.data) {
console.warn("Dryrun enabled - not actually uploading GPX ", gpx)
return new Promise<{ id: number }>((ok, error) => {
return new Promise<{ id: number }>((ok) => {
window.setTimeout(
() => ok({ id: Math.floor(Math.random() * 1000) }),
Math.random() * 5000

View file

@ -615,7 +615,7 @@ export default class SimpleMetaTaggers {
isLazy: true,
includesDates: true,
},
(feature, layer, tagsStore) => {
(feature) => {
Utils.AddLazyProperty(feature.properties, "_last_edit:passed_time", () => {
const lastEditTimestamp = new Date(
feature.properties["_last_edit:timestamp"]

View file

@ -20,11 +20,11 @@ export default class ComparingTag implements TagsFilter {
this._boundary = boundary
}
asChange(properties: Record<string, string>): { k: string; v: string }[] {
asChange(_: Record<string, string>): { k: string; v: string }[] {
throw "A comparable tag can not be used to be uploaded to OSM"
}
asHumanString(linkToWiki: boolean, shorten: boolean, properties: Record<string, string>) {
asHumanString() {
return this._key + this._representation + this._boundary
}

View file

@ -1,4 +1,3 @@
import exp from "constants"
import { Utils } from "../../Utils"
export interface TagInfoStats {
@ -16,9 +15,8 @@ export interface TagInfoStats {
}
export default class TagInfo {
private readonly _backend: string
public static readonly global = new TagInfo()
private readonly _backend: string
constructor(backend = "https://taginfo.openstreetmap.org/") {
this._backend = backend

View file

@ -122,7 +122,7 @@ export default class ThemeViewStateHashActor {
private loadStateFromHash(hash: string) {
const state = this._state
const parts = hash.split(":")
outer: for (const { toggle, name, showOverOthers, submenu } of state.guistate.allToggles) {
outer: for (const { toggle, name, submenu } of state.guistate.allToggles) {
for (const part of parts) {
if (part === name) {
toggle.setData(true)