Refactoring: port import flow

This commit is contained in:
Pieter Vander Vennet 2023-06-01 02:52:21 +02:00
parent 8ed4da4e9d
commit ace7caada1
48 changed files with 852 additions and 574 deletions

View file

@ -1,16 +1,16 @@
import { OsmNode, OsmObject, OsmRelation, OsmWay } from "./OsmObject"
import { Store, UIEventSource } from "../UIEventSource"
import {OsmNode, OsmObject, OsmRelation, OsmWay} from "./OsmObject"
import {Store, UIEventSource} from "../UIEventSource"
import Constants from "../../Models/Constants"
import OsmChangeAction from "./Actions/OsmChangeAction"
import { ChangeDescription, ChangeDescriptionTools } from "./Actions/ChangeDescription"
import { Utils } from "../../Utils"
import { LocalStorageSource } from "../Web/LocalStorageSource"
import {ChangeDescription, ChangeDescriptionTools} from "./Actions/ChangeDescription"
import {Utils} from "../../Utils"
import {LocalStorageSource} from "../Web/LocalStorageSource"
import SimpleMetaTagger from "../SimpleMetaTagger"
import { FeatureSource, IndexedFeatureSource } from "../FeatureSource/FeatureSource"
import { GeoLocationPointProperties } from "../State/GeoLocationState"
import { GeoOperations } from "../GeoOperations"
import { ChangesetHandler, ChangesetTag } from "./ChangesetHandler"
import { OsmConnection } from "./OsmConnection"
import {FeatureSource, IndexedFeatureSource} from "../FeatureSource/FeatureSource"
import {GeoLocationPointProperties} from "../State/GeoLocationState"
import {GeoOperations} from "../GeoOperations"
import {ChangesetHandler, ChangesetTag} from "./ChangesetHandler"
import {OsmConnection} from "./OsmConnection"
import FeaturePropertiesStore from "../FeatureSource/Actors/FeaturePropertiesStore"
import OsmObjectDownloader from "./OsmObjectDownloader"
@ -25,9 +25,9 @@ export class Changes {
public readonly state: { allElements?: IndexedFeatureSource; osmConnection: OsmConnection }
public readonly extraComment: UIEventSource<string> = new UIEventSource(undefined)
public readonly backend: string
public readonly isUploading = new UIEventSource(false)
private readonly historicalUserLocations?: FeatureSource
private _nextId: number = -1 // Newly assigned ID's are negative
public readonly isUploading = new UIEventSource(false)
private readonly previouslyCreated: OsmObject[] = []
private readonly _leftRightSensitive: boolean
private readonly _changesetHandler: ChangesetHandler
@ -246,11 +246,12 @@ export class Changes {
switch (change.type) {
case "node":
// @ts-ignore
const nlat = change.changes.lat
const nlat = Utils.Round7(change.changes.lat)
// @ts-ignore
const nlon = change.changes.lon
const nlon = Utils.Round7(change.changes.lon)
const n = <OsmNode>obj
if (n.lat !== nlat || n.lon !== nlon) {
console.log("Node moved:", n.lat, nlat, n.lon, nlon)
n.lat = nlat
n.lon = nlon
changed = true
@ -407,7 +408,7 @@ export class Changes {
neededIds.map(async (id) => {
try {
const osmObj = await downloader.DownloadObjectAsync(id)
return { id, osmObj }
return {id, osmObj}
} catch (e) {
console.error(
"Could not download OSM-object",
@ -421,7 +422,7 @@ export class Changes {
osmObjects = Utils.NoNull(osmObjects)
for (const { osmObj, id } of osmObjects) {
for (const {osmObj, id} of osmObjects) {
if (osmObj === "deleted") {
pending = pending.filter((ch) => ch.type + "/" + ch.id !== id)
}
@ -572,9 +573,9 @@ export class Changes {
)
console.log(
"Using current-open-changeset-" +
theme +
" from the preferences, got " +
openChangeset.data
theme +
" from the preferences, got " +
openChangeset.data
)
return await self.flushSelectChanges(pendingChanges, openChangeset)