2021-07-15 20:47:28 +02:00
|
|
|
/**
|
|
|
|
* An action is a change to the OSM-database
|
|
|
|
* It will generate some new/modified/deleted objects, which are all bundled by the 'changes'-object
|
|
|
|
*/
|
|
|
|
import {Changes} from "../Changes";
|
|
|
|
import {ChangeDescription} from "./ChangeDescription";
|
|
|
|
|
|
|
|
export default abstract class OsmChangeAction {
|
|
|
|
|
2021-11-09 01:49:07 +01:00
|
|
|
public readonly trackStatistics: boolean;
|
|
|
|
/**
|
|
|
|
* The ID of the object that is the center of this change.
|
2021-12-10 04:00:02 +01:00
|
|
|
* Null if the action creates a new object (at initialization)
|
2021-11-09 01:49:07 +01:00
|
|
|
* Undefined if such an id does not make sense
|
|
|
|
*/
|
|
|
|
public readonly mainObjectId: string;
|
2022-01-26 21:40:38 +01:00
|
|
|
private isUsed = false
|
|
|
|
|
2021-11-09 01:49:07 +01:00
|
|
|
constructor(mainObjectId: string, trackStatistics: boolean = true) {
|
|
|
|
this.trackStatistics = trackStatistics;
|
|
|
|
this.mainObjectId = mainObjectId
|
|
|
|
}
|
2021-07-18 14:52:09 +02:00
|
|
|
|
|
|
|
public Perform(changes: Changes) {
|
|
|
|
if (this.isUsed) {
|
2022-02-14 02:26:03 +01:00
|
|
|
throw "This ChangeAction is already used"
|
2021-07-18 14:52:09 +02:00
|
|
|
}
|
|
|
|
this.isUsed = true;
|
|
|
|
return this.CreateChangeDescriptions(changes)
|
|
|
|
}
|
|
|
|
|
2021-09-22 05:02:09 +02:00
|
|
|
protected abstract CreateChangeDescriptions(changes: Changes): Promise<ChangeDescription[]>
|
2021-12-10 04:00:02 +01:00
|
|
|
}
|
|
|
|
|
2022-01-26 21:40:38 +01:00
|
|
|
export abstract class OsmCreateAction extends OsmChangeAction {
|
2021-12-10 04:00:02 +01:00
|
|
|
|
2022-01-26 21:40:38 +01:00
|
|
|
public newElementId: string
|
2021-12-10 04:00:02 +01:00
|
|
|
public newElementIdNumber: number
|
2022-01-26 21:40:38 +01:00
|
|
|
|
2021-12-10 04:00:02 +01:00
|
|
|
}
|