First working version of snapping to already existing ways from the add-UI (still too slow though), partial fix of #436

This commit is contained in:
Pieter Vander Vennet 2021-08-07 21:19:01 +02:00
parent bf2d634208
commit 0a01561d37
15 changed files with 460 additions and 143 deletions

66
test.ts
View file

@ -2,40 +2,49 @@ import {UIEventSource} from "./Logic/UIEventSource";
import LayoutConfig from "./Customizations/JSON/LayoutConfig";
import {AllKnownLayouts} from "./Customizations/AllKnownLayouts";
import State from "./State";
import LocationInput from "./UI/Input/LocationInput";
import Loc from "./Models/Loc";
import {VariableUiElement} from "./UI/Base/VariableUIElement";
import AvailableBaseLayers from "./Logic/Actors/AvailableBaseLayers";
const layout = new UIEventSource<LayoutConfig>(AllKnownLayouts.allKnownLayouts.get("bookcases"))
const layout = new UIEventSource<LayoutConfig>(AllKnownLayouts.allKnownLayouts.get("cycle_infra"))
State.state = new State(layout.data)
const features = new UIEventSource<{ feature: any }[]>([
{
feature: {
"type": "Feature",
"properties": {"amenity": "public_bookcase", "id": "node/123"},
id: "node/123",
_matching_layer_id: "public_bookcase",
"properties": {},
"geometry": {
"type": "Point",
"type": "LineString",
"coordinates": [
3.220506906509399,
51.215009243433094
[
3.219616413116455,
51.215315026941276
],
[
3.221080899238586,
51.21564432998662
]
]
}
}
}, {
},
{
feature: {
"type": "Feature",
"properties": {
amenity: "public_bookcase",
id: "node/456"
},
_matching_layer_id: "public_bookcase",
id: "node/456",
"properties": {},
"geometry": {
"type": "Point",
"type": "LineString",
"coordinates": [
3.4243011474609375,
51.138432319543924
[
3.220340609550476,
51.21547967875836
],
[
3.2198095321655273,
51.216390293480515
]
]
}
}
@ -43,5 +52,22 @@ const features = new UIEventSource<{ feature: any }[]>([
])
features.data.map(f => State.state.allElements.addOrGetElement(f.feature))
const loc = new UIEventSource<Loc>({
zoom: 19,
lat: 51.21547967875836,
lon: 3.220340609550476
})
const li = new LocationInput(
{
mapBackground: AvailableBaseLayers.SelectBestLayerAccordingTo(loc, new UIEventSource<string | string[]>("map")),
snapTo: features,
snappedPointTags: {
"barrier": "cycle_barrier"
},
maxSnapDistance: 15,
requiresSnapping: false,
centerLocation: loc
}
)
li.SetStyle("height: 30rem").AttachTo("maindiv")
new VariableUiElement(li.GetValue().map(JSON.stringify)).AttachTo("extradiv")