forked from MapComplete/MapComplete
Inject newly created notes into the map
This commit is contained in:
parent
7001216ab7
commit
80533597c1
6 changed files with 82 additions and 3 deletions
|
@ -23,6 +23,7 @@ import TileFreshnessCalculator from "./TileFreshnessCalculator";
|
||||||
import FullNodeDatabaseSource from "./TiledFeatureSource/FullNodeDatabaseSource";
|
import FullNodeDatabaseSource from "./TiledFeatureSource/FullNodeDatabaseSource";
|
||||||
import MapState from "../State/MapState";
|
import MapState from "../State/MapState";
|
||||||
import {ElementStorage} from "../ElementStorage";
|
import {ElementStorage} from "../ElementStorage";
|
||||||
|
import MetaTagging from "../MetaTagging";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,6 +62,8 @@ export default class FeaturePipeline {
|
||||||
private readonly oldestAllowedDate: Date;
|
private readonly oldestAllowedDate: Date;
|
||||||
private readonly osmSourceZoomLevel
|
private readonly osmSourceZoomLevel
|
||||||
private readonly localStorageSavers = new Map<string, SaveTileToLocalStorageActor>()
|
private readonly localStorageSavers = new Map<string, SaveTileToLocalStorageActor>()
|
||||||
|
|
||||||
|
private readonly newGeometryHandler : NewGeometryFromChangesFeatureSource;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
handleFeatureSource: (source: FeatureSourceForLayer & Tiled) => void,
|
handleFeatureSource: (source: FeatureSourceForLayer & Tiled) => void,
|
||||||
|
@ -300,6 +303,7 @@ export default class FeaturePipeline {
|
||||||
|
|
||||||
// Also load points/lines that are newly added.
|
// Also load points/lines that are newly added.
|
||||||
const newGeometry = new NewGeometryFromChangesFeatureSource(state.changes, state.allElements, state.osmConnection._oauth_config.url)
|
const newGeometry = new NewGeometryFromChangesFeatureSource(state.changes, state.allElements, state.osmConnection._oauth_config.url)
|
||||||
|
this.newGeometryHandler = newGeometry;
|
||||||
newGeometry.features.addCallbackAndRun(geometries => {
|
newGeometry.features.addCallbackAndRun(geometries => {
|
||||||
console.debug("New geometries are:", geometries)
|
console.debug("New geometries are:", geometries)
|
||||||
})
|
})
|
||||||
|
@ -482,4 +486,14 @@ export default class FeaturePipeline {
|
||||||
return updater;
|
return updater;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inject a new point
|
||||||
|
*/
|
||||||
|
InjectNewPoint(geojson) {
|
||||||
|
this.newGeometryHandler.features.data.push({
|
||||||
|
feature: geojson,
|
||||||
|
freshness: new Date()
|
||||||
|
})
|
||||||
|
this.newGeometryHandler.features.ping();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -18,7 +18,10 @@ export default class NewNoteUi extends Toggle {
|
||||||
isShown: UIEventSource<boolean>,
|
isShown: UIEventSource<boolean>,
|
||||||
state: {
|
state: {
|
||||||
LastClickLocation: UIEventSource<{ lat: number, lon: number }>,
|
LastClickLocation: UIEventSource<{ lat: number, lon: number }>,
|
||||||
osmConnection: OsmConnection, layoutToUse: LayoutConfig, featurePipeline: FeaturePipeline
|
osmConnection: OsmConnection,
|
||||||
|
layoutToUse: LayoutConfig,
|
||||||
|
featurePipeline: FeaturePipeline,
|
||||||
|
selectedElement: UIEventSource<any>
|
||||||
}) {
|
}) {
|
||||||
|
|
||||||
const t = Translations.t.notes;
|
const t = Translations.t.notes;
|
||||||
|
@ -37,7 +40,27 @@ export default class NewNoteUi extends Toggle {
|
||||||
}
|
}
|
||||||
txt += "\n\n #MapComplete #" + state?.layoutToUse?.id
|
txt += "\n\n #MapComplete #" + state?.layoutToUse?.id
|
||||||
const loc = state.LastClickLocation.data;
|
const loc = state.LastClickLocation.data;
|
||||||
state?.osmConnection?.openNote(loc.lat, loc.lon, txt)
|
const id = await state?.osmConnection?.openNote(loc.lat, loc.lon, txt)
|
||||||
|
const feature = {
|
||||||
|
type:"Feature",
|
||||||
|
geometry:{
|
||||||
|
type:"Point",
|
||||||
|
coordinates: [loc.lon, loc.lat]
|
||||||
|
},
|
||||||
|
properties: {
|
||||||
|
id: ""+id.id,
|
||||||
|
date_created: new Date().toISOString(),
|
||||||
|
_first_comment : txt,
|
||||||
|
comments:JSON.stringify( [{
|
||||||
|
text: txt,
|
||||||
|
html: txt,
|
||||||
|
user: state.osmConnection?.userDetails?.data?.name,
|
||||||
|
uid: state.osmConnection?.userDetails?.data?.uid
|
||||||
|
}]),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
state?.featurePipeline?.InjectNewPoint(feature)
|
||||||
|
state.selectedElement?.setData(feature)
|
||||||
text.GetValue().setData("")
|
text.GetValue().setData("")
|
||||||
isCreated.setData(true)
|
isCreated.setData(true)
|
||||||
})
|
})
|
||||||
|
@ -45,7 +68,13 @@ export default class NewNoteUi extends Toggle {
|
||||||
new Title(t.createNoteTitle),
|
new Title(t.createNoteTitle),
|
||||||
t.createNoteIntro,
|
t.createNoteIntro,
|
||||||
text,
|
text,
|
||||||
new Combine([new Toggle(undefined, t.warnAnonymous, state?.osmConnection?.isLoggedIn).SetClass("alert"), postNote]).SetClass("flex justify-end items-center")
|
new Combine([new Toggle(undefined, t.warnAnonymous.SetClass("alert"), state?.osmConnection?.isLoggedIn),
|
||||||
|
new Toggle(postNote,
|
||||||
|
t.textNeeded.SetClass("alert"),
|
||||||
|
text.GetValue().map(txt => txt.length > 3)
|
||||||
|
)
|
||||||
|
|
||||||
|
]).SetClass("flex justify-end items-center")
|
||||||
]).SetClass("flex flex-col border-2 border-black rounded-xl p-4");
|
]).SetClass("flex flex-col border-2 border-black rounded-xl p-4");
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -453,6 +453,7 @@
|
||||||
"loginToClose": "Login to close this note",
|
"loginToClose": "Login to close this note",
|
||||||
"createNoteTitle": "Create a new note here",
|
"createNoteTitle": "Create a new note here",
|
||||||
"createNote": "Create a new note",
|
"createNote": "Create a new note",
|
||||||
|
"textNeeded": "Enter a descriptive text to create a note",
|
||||||
"noteIsPublic": "This will be visible to everyone",
|
"noteIsPublic": "This will be visible to everyone",
|
||||||
"createNoteIntro": "Is something wrong or missing on the map? Create a note here. These will be checked by volunteers",
|
"createNoteIntro": "Is something wrong or missing on the map? Create a note here. These will be checked by volunteers",
|
||||||
"warnAnonymous": "You are not logged in. We won't be able to contact you to resolve your issue.",
|
"warnAnonymous": "You are not logged in. We won't be able to contact you to resolve your issue.",
|
||||||
|
|
|
@ -3402,6 +3402,17 @@
|
||||||
"question": "Who maintains this tower?",
|
"question": "Who maintains this tower?",
|
||||||
"render": "Maintained by <b>{operator}</b>"
|
"render": "Maintained by <b>{operator}</b>"
|
||||||
},
|
},
|
||||||
|
"elevator": {
|
||||||
|
"mappings": {
|
||||||
|
"0": {
|
||||||
|
"then": "This tower has an elevator which takes visitors to the top"
|
||||||
|
},
|
||||||
|
"1": {
|
||||||
|
"then": "This tower does not have an elevator"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"question": "Does this tower have an elevator?"
|
||||||
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"mappings": {
|
"mappings": {
|
||||||
"0": {
|
"0": {
|
||||||
|
@ -3410,6 +3421,10 @@
|
||||||
},
|
},
|
||||||
"question": "What is the name of this tower?",
|
"question": "What is the name of this tower?",
|
||||||
"render": "This tower is called <b>{name}</b>"
|
"render": "This tower is called <b>{name}</b>"
|
||||||
|
},
|
||||||
|
"step_count": {
|
||||||
|
"question": "How much individual steps does one have to climb to reach the top of this tower?",
|
||||||
|
"render": "This tower has {step_count} steps to reach the top"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"title": {
|
"title": {
|
||||||
|
|
|
@ -3302,6 +3302,17 @@
|
||||||
"question": "Wie onderhoudt deze toren?",
|
"question": "Wie onderhoudt deze toren?",
|
||||||
"render": "Wordt onderhouden door <b>{operator}</b>"
|
"render": "Wordt onderhouden door <b>{operator}</b>"
|
||||||
},
|
},
|
||||||
|
"elevator": {
|
||||||
|
"mappings": {
|
||||||
|
"0": {
|
||||||
|
"then": "Deze toren heeft een lift die bezoekers naar de top van de toren brengt"
|
||||||
|
},
|
||||||
|
"1": {
|
||||||
|
"then": "Deze toren heeft geen lift"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"question": "Heeft deze toren een lift?"
|
||||||
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"mappings": {
|
"mappings": {
|
||||||
"0": {
|
"0": {
|
||||||
|
@ -3310,6 +3321,10 @@
|
||||||
},
|
},
|
||||||
"question": "Heeft deze toren een naam?",
|
"question": "Heeft deze toren een naam?",
|
||||||
"render": "Deze toren heet <b>{name}</b>"
|
"render": "Deze toren heet <b>{name}</b>"
|
||||||
|
},
|
||||||
|
"step_count": {
|
||||||
|
"question": "Hoeveel treden moet men beklimmen op de top van de toren te bereiken?",
|
||||||
|
"render": "Deze toren heeft {step_count} traptredes"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"title": {
|
"title": {
|
||||||
|
|
|
@ -1096,6 +1096,11 @@
|
||||||
"shortDescription": "This theme shows all (touristic) maps that OpenStreetMap knows of",
|
"shortDescription": "This theme shows all (touristic) maps that OpenStreetMap knows of",
|
||||||
"title": "A map of maps"
|
"title": "A map of maps"
|
||||||
},
|
},
|
||||||
|
"nature": {
|
||||||
|
"description": "On this map, one can find interesting infromation for tourists and nature lovers, such as ",
|
||||||
|
"shortDescription": "A map for nature lovers, with interesting POI's",
|
||||||
|
"title": "Into nature"
|
||||||
|
},
|
||||||
"notes": {
|
"notes": {
|
||||||
"description": "A note is a pin on the map with some text to indicate something wrong.<br/><br/>Make sure to checkout the <a href='#filters'>filter view</a> to search for users and text.",
|
"description": "A note is a pin on the map with some text to indicate something wrong.<br/><br/>Make sure to checkout the <a href='#filters'>filter view</a> to search for users and text.",
|
||||||
"title": "Notes on OpenStreetMap"
|
"title": "Notes on OpenStreetMap"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue