Fix snapping to layers for the import button
This commit is contained in:
parent
4f403c4bfc
commit
ae045b75cf
3 changed files with 14 additions and 9 deletions
|
@ -34,6 +34,7 @@ import ReplaceGeometryAction from "../../Logic/Osm/Actions/ReplaceGeometryAction
|
||||||
import CreateWayWithPointReuseAction from "../../Logic/Osm/Actions/CreateWayWithPointReuseAction";
|
import CreateWayWithPointReuseAction from "../../Logic/Osm/Actions/CreateWayWithPointReuseAction";
|
||||||
import OsmChangeAction from "../../Logic/Osm/Actions/OsmChangeAction";
|
import OsmChangeAction from "../../Logic/Osm/Actions/OsmChangeAction";
|
||||||
import FeatureSource from "../../Logic/FeatureSource/FeatureSource";
|
import FeatureSource from "../../Logic/FeatureSource/FeatureSource";
|
||||||
|
import {OsmObject, OsmWay} from "../../Logic/Osm/OsmObject";
|
||||||
|
|
||||||
|
|
||||||
export interface ImportButtonState {
|
export interface ImportButtonState {
|
||||||
|
@ -300,7 +301,7 @@ export default class ImportButton extends Toggle {
|
||||||
importClicked: UIEventSource<boolean>): BaseUIElement {
|
importClicked: UIEventSource<boolean>): BaseUIElement {
|
||||||
|
|
||||||
const confirmationMap = Minimap.createMiniMap({
|
const confirmationMap = Minimap.createMiniMap({
|
||||||
allowMoving: true,
|
allowMoving: false,
|
||||||
background: o.state.backgroundLayer
|
background: o.state.backgroundLayer
|
||||||
})
|
})
|
||||||
confirmationMap.SetStyle("height: 20rem; overflow: hidden").SetClass("rounded-xl")
|
confirmationMap.SetStyle("height: 20rem; overflow: hidden").SetClass("rounded-xl")
|
||||||
|
@ -411,18 +412,21 @@ export default class ImportButton extends Toggle {
|
||||||
isImported: UIEventSource<boolean>,
|
isImported: UIEventSource<boolean>,
|
||||||
importClicked: UIEventSource<boolean>): BaseUIElement {
|
importClicked: UIEventSource<boolean>): BaseUIElement {
|
||||||
|
|
||||||
async function confirm() {
|
async function confirm(tags: any[], location: { lat: number, lon: number }, snapOntoWayId: string) {
|
||||||
|
|
||||||
if (isImported.data) {
|
if (isImported.data) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
o.originalTags.data["_imported"] = "yes"
|
o.originalTags.data["_imported"] = "yes"
|
||||||
o.originalTags.ping() // will set isImported as per its definition
|
o.originalTags.ping() // will set isImported as per its definition
|
||||||
const geometry = o.feature.geometry
|
let snapOnto : OsmObject = undefined
|
||||||
const lat = geometry.coordinates[1]
|
if(snapOntoWayId !== undefined){
|
||||||
const lon = geometry.coordinates[0];
|
snapOnto = await OsmObject.DownloadObjectAsync(snapOntoWayId)
|
||||||
const newElementAction = new CreateNewNodeAction(o.newTags.data, lat, lon, {
|
}
|
||||||
|
const newElementAction = new CreateNewNodeAction(tags, location.lat, location.lon, {
|
||||||
theme: o.state.layoutToUse.id,
|
theme: o.state.layoutToUse.id,
|
||||||
changeType: "import"
|
changeType: "import",
|
||||||
|
snapOnto: <OsmWay> snapOnto
|
||||||
})
|
})
|
||||||
|
|
||||||
await o.state.changes.applyAction(newElementAction)
|
await o.state.changes.applyAction(newElementAction)
|
||||||
|
|
|
@ -91,7 +91,7 @@ export default class SimpleAddUI extends Toggle {
|
||||||
return presetsOverview
|
return presetsOverview
|
||||||
}
|
}
|
||||||
|
|
||||||
function confirm(tags, location, snapOntoWayId?: string) {
|
function confirm(tags:any[], location: {lat: number, lon:number}, snapOntoWayId?: string) {
|
||||||
if (snapOntoWayId === undefined) {
|
if (snapOntoWayId === undefined) {
|
||||||
createNewPoint(tags, location, undefined)
|
createNewPoint(tags, location, undefined)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -98,7 +98,8 @@ export default class ConfirmLocationOfPoint extends Combine {
|
||||||
]).SetClass("flex flex-col")
|
]).SetClass("flex flex-col")
|
||||||
).SetClass("font-bold break-words")
|
).SetClass("font-bold break-words")
|
||||||
.onClick(() => {
|
.onClick(() => {
|
||||||
confirm(preset.tags, (preciseInput?.GetValue()?.data ?? loc), preciseInput?.snappedOnto?.data?.properties?.id);
|
console.log("The confirmLocationPanel - precise input yielded ", preciseInput?.GetValue()?.data)
|
||||||
|
confirm(preset.tags, preciseInput?.GetValue()?.data ?? loc, preciseInput?.snappedOnto?.data?.properties?.id);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (preciseInput !== undefined) {
|
if (preciseInput !== undefined) {
|
||||||
|
|
Loading…
Reference in a new issue