forked from MapComplete/MapComplete
		
	Chore: cleanup typings and linting errors
This commit is contained in:
		
							parent
							
								
									15cbadc4e0
								
							
						
					
					
						commit
						fffc959c0d
					
				
					 6 changed files with 21 additions and 41 deletions
				
			
		|  | @ -21,24 +21,8 @@ class ServerLdScrape extends Script { | |||
|             /* { | ||||
|                 "User-Agent": "MapComplete/openstreetmap scraper; pietervdvn@posteo.net; https://source.mapcomplete.org/MapComplete", | ||||
|                 "accept": "application/html" | ||||
|             }, | ||||
|             { | ||||
|                 Host: host, | ||||
|                 "User-Agent": "Mozilla/5.0 (Windows NT 10.0; rv:122.0) Gecko/20100101 Firefox/122.0", | ||||
|                 "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,* /*;q=0.8", TODO remove space in * /* | ||||
|                 "Accept-Language": "en-US,en;q=0.5", | ||||
|                 "Accept-Encoding": "gzip, deflate, br", | ||||
|                 "Alt-Used": host, | ||||
|                 DNT: 1, | ||||
|                 "Sec-GPC": 1, | ||||
|                 "Upgrade-Insecure-Requests": 1, | ||||
|                 "Sec-Fetch-Dest": "document", | ||||
|                 "Sec-Fetch-Mode": "navigate", | ||||
|                 "Sec-Fetch-Site": "cross-site", | ||||
|                 "Sec-Fetch-User":"?1", | ||||
|                 "TE": "trailers", | ||||
|                 Connection: "keep-alive" | ||||
|             }*/ | ||||
|             },*/ | ||||
| 
 | ||||
|         ] | ||||
|         for (let i = 0; i < headers.length; i++) { | ||||
|             try { | ||||
|  |  | |||
|  | @ -11,15 +11,14 @@ import ChangeTagAction from "./ChangeTagAction" | |||
| import { And } from "../../Tags/And" | ||||
| import { Utils } from "../../../Utils" | ||||
| import { OsmConnection } from "../OsmConnection" | ||||
| import { Feature } from "@turf/turf" | ||||
| import { Geometry, LineString, Point } from "geojson" | ||||
| import { Feature, Geometry, LineString, Point } from "geojson" | ||||
| import FullNodeDatabaseSource from "../../FeatureSource/TiledFeatureSource/FullNodeDatabaseSource" | ||||
| 
 | ||||
| export default class ReplaceGeometryAction extends OsmChangeAction implements PreviewableAction { | ||||
|     /** | ||||
|      * The target feature - mostly used for the metadata | ||||
|      */ | ||||
|     private readonly feature: any | ||||
|     private readonly feature: Feature | ||||
|     private readonly state: { | ||||
|         osmConnection: OsmConnection | ||||
|         fullNodeDatabase?: FullNodeDatabaseSource | ||||
|  | @ -48,7 +47,7 @@ export default class ReplaceGeometryAction extends OsmChangeAction implements Pr | |||
|             osmConnection: OsmConnection | ||||
|             fullNodeDatabase?: FullNodeDatabaseSource | ||||
|         }, | ||||
|         feature: any, | ||||
|         feature: Feature, | ||||
|         wayToReplaceId: string, | ||||
|         options: { | ||||
|             theme: string | ||||
|  | @ -65,13 +64,13 @@ export default class ReplaceGeometryAction extends OsmChangeAction implements Pr | |||
|         const geom = this.feature.geometry | ||||
|         let coordinates: [number, number][] | ||||
|         if (geom.type === "LineString") { | ||||
|             coordinates = geom.coordinates | ||||
|             coordinates = <[number, number][]>geom.coordinates | ||||
|         } else if (geom.type === "Polygon") { | ||||
|             coordinates = geom.coordinates[0] | ||||
|             coordinates = <[number, number][]>geom.coordinates[0] | ||||
|         } | ||||
|         this.targetCoordinates = coordinates | ||||
| 
 | ||||
|         this.identicalTo = coordinates.map((_) => undefined) | ||||
|         this.identicalTo = coordinates.map(() => undefined) | ||||
| 
 | ||||
|         for (let i = 0; i < coordinates.length; i++) { | ||||
|             if (this.identicalTo[i] !== undefined) { | ||||
|  | @ -204,7 +203,6 @@ export default class ReplaceGeometryAction extends OsmChangeAction implements Pr | |||
|         if (nodeDb === undefined) { | ||||
|             throw "PANIC: replaceGeometryAction needs the FullNodeDatabase, which is undefined. This should be initialized by having the 'type_node'-layer enabled in your theme. (NB: the replacebutton has type_node as dependency)" | ||||
|         } | ||||
|         const self = this | ||||
|         let parsed: OsmObject[] | ||||
|         { | ||||
|             // Gather the needed OsmObjects
 | ||||
|  | @ -214,6 +212,7 @@ export default class ReplaceGeometryAction extends OsmChangeAction implements Pr | |||
|             if (idN < 0 || type !== "way") { | ||||
|                 throw "Invalid ID to conflate: " + this.wayToReplaceId | ||||
|             } | ||||
| 
 | ||||
|             const url = `${ | ||||
|                 this.state.osmConnection?._oauth_config?.url ?? "https://api.openstreetmap.org" | ||||
|             }/api/0.6/${this.wayToReplaceId}/full` | ||||
|  | @ -270,7 +269,7 @@ export default class ReplaceGeometryAction extends OsmChangeAction implements Pr | |||
|             const partOfSomeWay = parentWayIds.length > 0 | ||||
|             const hasTags = Object.keys(node.tags).length > 1 | ||||
| 
 | ||||
|             const nodeDistances = this.targetCoordinates.map((_) => undefined) | ||||
|             const nodeDistances = this.targetCoordinates.map(() => undefined) | ||||
|             for (let i = 0; i < this.targetCoordinates.length; i++) { | ||||
|                 if (this.identicalTo[i] !== undefined) { | ||||
|                     continue | ||||
|  | @ -295,7 +294,7 @@ export default class ReplaceGeometryAction extends OsmChangeAction implements Pr | |||
|             }) | ||||
|         } | ||||
| 
 | ||||
|         const closestIds = this.targetCoordinates.map((_) => undefined) | ||||
|         const closestIds = this.targetCoordinates.map(() => undefined) | ||||
|         const unusedIds = new Map< | ||||
|             number, | ||||
|             { | ||||
|  | @ -330,7 +329,7 @@ export default class ReplaceGeometryAction extends OsmChangeAction implements Pr | |||
|                     // We found a candidate... Search the corresponding target id:
 | ||||
|                     let targetId: number = undefined | ||||
|                     let lowestDistance = Number.MAX_VALUE | ||||
|                     let nodeDistances = distances.get(candidate) | ||||
|                     const nodeDistances = distances.get(candidate) | ||||
|                     for (let i = 0; i < nodeDistances.length; i++) { | ||||
|                         const d = nodeDistances[i] | ||||
|                         if (d !== undefined && d < lowestDistance) { | ||||
|  | @ -400,7 +399,7 @@ export default class ReplaceGeometryAction extends OsmChangeAction implements Pr | |||
|                     properties: {}, | ||||
|                     geometry: { | ||||
|                         type: "LineString", | ||||
|                         coordinates: self.targetCoordinates, | ||||
|                         coordinates: this.targetCoordinates | ||||
|                     }, | ||||
|                 } | ||||
|                 const projected = GeoOperations.nearestPoint(way, [node.lon, node.lat]) | ||||
|  | @ -528,7 +527,7 @@ export default class ReplaceGeometryAction extends OsmChangeAction implements Pr | |||
| 
 | ||||
|         // Some nodes might need to be deleted
 | ||||
|         if (detachedNodes.size > 0) { | ||||
|             detachedNodes.forEach(({ hasTags, reason }, nodeId) => { | ||||
|             detachedNodes.forEach(({ hasTags }, nodeId) => { | ||||
|                 const parentWays = nodeDb.GetParentWays(nodeId) | ||||
|                 const index = parentWays.data.map((w) => w.id).indexOf(osmWay.id) | ||||
|                 if (index < 0) { | ||||
|  |  | |||
|  | @ -233,7 +233,6 @@ export class Changes { | |||
|             ...addSource(DeleteAction.metatags, "DeleteAction"), | ||||
|             // TODO
 | ||||
|             /* | ||||
|             ...DeleteAction.metatags, | ||||
|             ...LinkImageAction.metatags, | ||||
|             ...OsmChangeAction.metatags, | ||||
|             ...RelationSplitHandler.metatags, | ||||
|  |  | |||
|  | @ -9,7 +9,8 @@ import FilteredLayer from "../../../Models/FilteredLayer" | |||
| import LayerConfig from "../../../Models/ThemeConfig/LayerConfig" | ||||
| import { LayerConfigJson } from "../../../Models/ThemeConfig/Json/LayerConfigJson" | ||||
| import conflation_json from "../../../../assets/layers/conflation/conflation.json" | ||||
| import ThemeViewState from "../../../Models/ThemeViewState" | ||||
| import { SpecialVisualizationState } from "../../SpecialVisualization" | ||||
| import { OsmTags } from "../../../Models/OsmFeature" | ||||
| 
 | ||||
| export interface ImportFlowArguments { | ||||
|     readonly text: string | ||||
|  | @ -65,7 +66,7 @@ ${Utils.special_visualizations_importRequirementDocs} | |||
|      * Given the tagsstore of the point which represents the challenge, creates a new store with tags that should be applied onto the newly created point, | ||||
|      */ | ||||
|     public static getTagsToApply( | ||||
|         originalFeatureTags: UIEventSource<any>, | ||||
|         originalFeatureTags: UIEventSource<OsmTags>, | ||||
|         args: { tags: string } | ||||
|     ): Store<Tag[]> { | ||||
|         if (originalFeatureTags === undefined) { | ||||
|  | @ -109,9 +110,7 @@ ${Utils.special_visualizations_importRequirementDocs} | |||
|      * Others (e.g.: snapOnto-layers) are not to be handled here | ||||
|      */ | ||||
|     public static getLayerDependencies(argsRaw: string[], argSpec?): string[] { | ||||
|         const args: ImportFlowArguments = <any>( | ||||
|             Utils.ParseVisArgs(argSpec ?? ImportFlowUtils.generalArguments, argsRaw) | ||||
|         ) | ||||
|         const args = Utils.ParseVisArgs<ImportFlowArguments>(argSpec ?? ImportFlowUtils.generalArguments, argsRaw) | ||||
|         return args.targetLayer.split(" ") | ||||
|     } | ||||
| 
 | ||||
|  | @ -139,14 +138,14 @@ ${Utils.special_visualizations_importRequirementDocs} | |||
|  * This class works together closely with ImportFlow.svelte | ||||
|  */ | ||||
| export default abstract class ImportFlow<ArgT extends ImportFlowArguments> { | ||||
|     public readonly state: ThemeViewState | ||||
|     public readonly state: SpecialVisualizationState | ||||
|     public readonly args: ArgT | ||||
|     public readonly targetLayer: FilteredLayer[] | ||||
|     public readonly tagsToApply: Store<Tag[]> | ||||
|     protected readonly _originalFeatureTags: UIEventSource<Record<string, string>> | ||||
| 
 | ||||
|     constructor( | ||||
|         state: ThemeViewState, | ||||
|         state: SpecialVisualizationState, | ||||
|         args: ArgT, | ||||
|         tagsToApply: Store<Tag[]>, | ||||
|         originalTags: UIEventSource<Record<string, string>> | ||||
|  |  | |||
|  | @ -137,7 +137,6 @@ | |||
|           } | ||||
|           unseenFreeformValues.splice(index, 1) | ||||
|         } | ||||
|         // TODO this has _to much_ values | ||||
|         freeformInput.set(unseenFreeformValues.join(";")) | ||||
|         if (checkedMappings.length + 1 < mappings.length) { | ||||
|           checkedMappings.push(unseenFreeformValues.length > 0) | ||||
|  |  | |||
|  | @ -81,7 +81,7 @@ In the case that MapComplete is pointed to the testing grounds, the edit will be | |||
|     /** | ||||
|      * Parses the arguments for special visualisations | ||||
|      */ | ||||
|     public static ParseVisArgs<T extends Record<string, string>>( | ||||
|     public static ParseVisArgs<T = Record<string, string>>( | ||||
|         specs: { name: string; defaultValue?: string }[], | ||||
|         args: string[] | ||||
|     ): T { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue