More work on import flow

This commit is contained in:
Pieter Vander Vennet 2022-01-25 00:48:05 +01:00
parent 33ef83c4a9
commit fa179af601
8 changed files with 54 additions and 12 deletions

View file

@ -20,7 +20,7 @@ export default class CreateNewNodeAction extends OsmCreateAction {
private readonly _lon: number;
private readonly _snapOnto: OsmWay;
private readonly _reusePointDistance: number;
private meta: { changeType: "create" | "import"; theme: string };
private meta: { changeType: "create" | "import"; theme: string; specialMotivation?: string };
private readonly _reusePreviouslyCreatedPoint: boolean;
constructor(basicTags: Tag[],
@ -29,7 +29,9 @@ export default class CreateNewNodeAction extends OsmCreateAction {
allowReuseOfPreviouslyCreatedPoints?: boolean,
snapOnto?: OsmWay,
reusePointWithinMeters?: number,
theme: string, changeType: "create" | "import" | null
theme: string,
changeType: "create" | "import" | null,
specialMotivation?: string
}) {
super(null,basicTags !== undefined && basicTags.length > 0)
this._basicTags = basicTags;
@ -43,7 +45,8 @@ export default class CreateNewNodeAction extends OsmCreateAction {
this._reusePreviouslyCreatedPoint = options?.allowReuseOfPreviouslyCreatedPoints ?? (basicTags.length === 0)
this.meta = {
theme: options.theme,
changeType: options.changeType
changeType: options.changeType,
}
}

View file

@ -131,16 +131,18 @@ export class Changes {
private calculateDistanceToChanges(change: OsmChangeAction, changeDescriptions: ChangeDescription[]) {
if (this.state === undefined) {
// No state loaded -> we can't calculate...
const locations = this.state?.historicalUserLocations?.features?.data
if (locations === undefined) {
// No state loaded or no locations -> we can't calculate...
return;
}
if (!change.trackStatistics) {
// Probably irrelevant, such as a new helper node
return;
}
const now = new Date()
const recentLocationPoints = this.state.historicalUserLocations.features.data.map(ff => ff.feature)
const recentLocationPoints = locations.map(ff => ff.feature)
.filter(feat => feat.geometry.type === "Point")
.filter(feat => {
const visitTime = new Date((<GeoLocationPointProperties>feat.properties).date)