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,21 +1,21 @@
import OsmChangeAction from "./OsmChangeAction"
import { Changes } from "../Changes"
import { ChangeDescription } from "./ChangeDescription"
import { Tag } from "../../Tags/Tag"
import { FeatureSource } from "../../FeatureSource/FeatureSource"
import { OsmNode, OsmObject, OsmWay } from "../OsmObject"
import { GeoOperations } from "../../GeoOperations"
import OsmChangeAction, {PreviewableAction} from "./OsmChangeAction"
import {Changes} from "../Changes"
import {ChangeDescription} from "./ChangeDescription"
import {Tag} from "../../Tags/Tag"
import {FeatureSource} from "../../FeatureSource/FeatureSource"
import {OsmNode, OsmObject, OsmWay} from "../OsmObject"
import {GeoOperations} from "../../GeoOperations"
import StaticFeatureSource from "../../FeatureSource/Sources/StaticFeatureSource"
import CreateNewNodeAction from "./CreateNewNodeAction"
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 {And} from "../../Tags/And"
import {Utils} from "../../../Utils"
import {OsmConnection} from "../OsmConnection"
import {Feature} from "@turf/turf"
import {Geometry, LineString, Point} from "geojson"
import FullNodeDatabaseSource from "../../FeatureSource/TiledFeatureSource/FullNodeDatabaseSource"
export default class ReplaceGeometryAction extends OsmChangeAction {
export default class ReplaceGeometryAction extends OsmChangeAction implements PreviewableAction{
/**
* The target feature - mostly used for the metadata
*/
@ -38,9 +38,14 @@ export default class ReplaceGeometryAction extends OsmChangeAction {
private readonly identicalTo: number[]
private readonly newTags: Tag[] | undefined
/**
* Not really the 'new' element, but the target that has been applied.
* Added for compatibility with other systems
*/
public readonly newElementId: string
constructor(
state: {
osmConnection: OsmConnection
osmConnection: OsmConnection,
fullNodeDatabase?: FullNodeDatabaseSource
},
feature: any,
@ -55,6 +60,7 @@ export default class ReplaceGeometryAction extends OsmChangeAction {
this.feature = feature
this.wayToReplaceId = wayToReplaceId
this.theme = options.theme
this.newElementId = wayToReplaceId
const geom = this.feature.geometry
let coordinates: [number, number][]
@ -81,7 +87,6 @@ export default class ReplaceGeometryAction extends OsmChangeAction {
this.newTags = options.newTags
}
// noinspection JSUnusedGlobalSymbols
public async getPreview(): Promise<FeatureSource> {
const { closestIds, allNodesById, detachedNodes, reprojectedNodes } =
await this.GetClosestIds()
@ -455,6 +460,7 @@ export default class ReplaceGeometryAction extends OsmChangeAction {
}
}
console.log("Adding tags", this.newTags,"to conflated way nr", this.wayToReplaceId)
if (this.newTags !== undefined && this.newTags.length > 0) {
const addExtraTags = new ChangeTagAction(
this.wayToReplaceId,