diff --git a/Logic/Osm/Actions/CreateNewNodeAction.ts b/Logic/Osm/Actions/CreateNewNodeAction.ts index d3f7e1f19..69621a563 100644 --- a/Logic/Osm/Actions/CreateNewNodeAction.ts +++ b/Logic/Osm/Actions/CreateNewNodeAction.ts @@ -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, + } } diff --git a/Logic/Osm/Changes.ts b/Logic/Osm/Changes.ts index 831c05800..8bcfe9654 100644 --- a/Logic/Osm/Changes.ts +++ b/Logic/Osm/Changes.ts @@ -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((feat.properties).date) diff --git a/UI/ImportFlow/CreateNotes.ts b/UI/ImportFlow/CreateNotes.ts index 2b19f83dd..f398c9808 100644 --- a/UI/ImportFlow/CreateNotes.ts +++ b/UI/ImportFlow/CreateNotes.ts @@ -22,6 +22,11 @@ export class CreateNotes extends Combine { const src = f.properties["source"] ?? f.properties["src"] ?? v.source delete f.properties["source"] delete f.properties["src"] + let extraNote = "" + if(f.properties["note"]){ + extraNote = f.properties["note"]+"\n" + delete f.properties["note"] + } const tags: string [] = [] for (const key in f.properties) { @@ -33,7 +38,7 @@ export class CreateNotes extends Combine { const lat = f.geometry.coordinates[1] const lon = f.geometry.coordinates[0] const text = [v.intro, - '', + extraNote, "Source: " + src, 'More information at ' + v.wikilink, '', diff --git a/UI/ImportFlow/ImportHelperGui.ts b/UI/ImportFlow/ImportHelperGui.ts index 732da1235..824f0f9c2 100644 --- a/UI/ImportFlow/ImportHelperGui.ts +++ b/UI/ImportFlow/ImportHelperGui.ts @@ -27,10 +27,7 @@ export default class ImportHelperGui extends LeftIndex { constructor() { const state = new UserRelatedState(undefined) - // We disable the userbadge, as various 'showData'-layers will give a read-only view in this case - state.featureSwitchUserbadge.setData(false) - - const {flow, furthestStep, titles} = + const {flow, furthestStep, titles} = FlowPanelFactory .start("Introduction", new Introdution()) .then("Login", _ => new LoginToImport(state)) diff --git a/UI/ImportFlow/PreviewPanel.ts b/UI/ImportFlow/PreviewPanel.ts index 2cf25d576..9c9655a38 100644 --- a/UI/ImportFlow/PreviewPanel.ts +++ b/UI/ImportFlow/PreviewPanel.ts @@ -99,6 +99,7 @@ export class PreviewPanel extends Combine implements FlowStep<{ features: { prop super([ new Title(t.inspectDataTitle.Subs({count: geojson.features.length})), + "Extra remark: An attribute with 'source' or 'src' will be added as 'source' into the map pin; an attribute 'note' will be added into the map pin as well. These values won't be imported", ...attributeOverview, confirm ]); diff --git a/UI/Popup/ImportButton.ts b/UI/Popup/ImportButton.ts index eaa147e7a..39dde1e0f 100644 --- a/UI/Popup/ImportButton.ts +++ b/UI/Popup/ImportButton.ts @@ -538,10 +538,15 @@ export class ImportPointButton extends AbstractImportButton { if (snapOntoWayId !== undefined) { snapOnto = await OsmObject.DownloadObjectAsync(snapOntoWayId) } + let specialMotivation = undefined + if(args.note_id !== undefined){ + specialMotivation = "source: https://osm.org/note/"+args.note_id + } const newElementAction = new CreateNewNodeAction(tags, location.lat, location.lon, { theme: state.layoutToUse.id, changeType: "import", - snapOnto: snapOnto + snapOnto: snapOnto, + specialMotivation }) await state.changes.applyAction(newElementAction) diff --git a/import_helper.html b/import_helper.html index 7d20f1022..a64cc840a 100644 --- a/import_helper.html +++ b/import_helper.html @@ -4,10 +4,15 @@ + + + + + MapComplete Import Helper diff --git a/test.ts b/test.ts index e69de29bb..0598faa63 100644 --- a/test.ts +++ b/test.ts @@ -0,0 +1,24 @@ +import {Utils} from "./Utils"; + +const features = [] +for (let lat = 49; lat < 52; lat+=0.05) { + for (let lon = 2.5; lon < 6.5; lon+=0.025) { + features.push({ + type:"Feature", + properties: {}, + geometry:{ + type:"Point", + coordinates: [lon, lat] + } + }) + } +} + +const geojson = { + type:"FeatureCollection", + features +} + +Utils.offerContentsAsDownloadableFile(JSON.stringify(geojson, null, " "), "raster.geojson",{ + mimetype:"application/geo+json" +}) \ No newline at end of file