More work on import flow
This commit is contained in:
parent
33ef83c4a9
commit
fa179af601
8 changed files with 54 additions and 12 deletions
|
@ -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,
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
'',
|
||||
|
|
|
@ -27,9 +27,6 @@ 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} =
|
||||
FlowPanelFactory
|
||||
.start("Introduction", new Introdution())
|
||||
|
|
|
@ -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
|
||||
]);
|
||||
|
|
|
@ -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: <OsmWay>snapOnto
|
||||
snapOnto: <OsmWay>snapOnto,
|
||||
specialMotivation
|
||||
})
|
||||
|
||||
await state.changes.applyAction(newElementAction)
|
||||
|
|
|
@ -4,10 +4,15 @@
|
|||
<meta charset="UTF-8">
|
||||
<meta content="width=device-width, initial-scale=1.0, user-scalable=no" name="viewport">
|
||||
<link href="./vendor/leaflet.css" rel="stylesheet"/>
|
||||
<link href="./css/userbadge.css" rel="stylesheet"/>
|
||||
<link href="./css/tabbedComponent.css" rel="stylesheet"/>
|
||||
<link href="./css/mobile.css" rel="stylesheet"/>
|
||||
<link href="./css/openinghourstable.css" rel="stylesheet"/>
|
||||
<link href="./css/tagrendering.css" rel="stylesheet"/>
|
||||
<link href="css/ReviewElement.css" rel="stylesheet"/>
|
||||
<link href="./css/index-tailwind-output.css" rel="stylesheet"/>
|
||||
<meta content="website" property="og:type">
|
||||
<link href="./css/wikipedia.css" rel="stylesheet"/>
|
||||
|
||||
<title>MapComplete Import Helper</title>
|
||||
<link href="./assets/svg/add.svg" rel="icon" sizes="any" type="image/svg+xml">
|
||||
|
|
24
test.ts
24
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"
|
||||
})
|
Loading…
Reference in a new issue