mirror of
https://github.com/umap-project/umap.git
synced 2025-04-29 11:52:38 +02:00
parent
cd4b2189ee
commit
c804a01bfb
2 changed files with 45 additions and 3 deletions
|
@ -866,14 +866,15 @@ export class LineString extends Path {
|
||||||
|
|
||||||
mergeShapes() {
|
mergeShapes() {
|
||||||
if (!this.isMulti()) return
|
if (!this.isMulti()) return
|
||||||
const latlngs = this.getLatLngs()
|
const latlngs = this.ui.getLatLngs()
|
||||||
if (!latlngs.length) return
|
if (!latlngs.length) return
|
||||||
while (latlngs.length > 1) {
|
while (latlngs.length > 1) {
|
||||||
latlngs.splice(0, 2, this._mergeShapes(latlngs[1], latlngs[0]))
|
latlngs.splice(0, 2, this._mergeShapes(latlngs[1], latlngs[0]))
|
||||||
}
|
}
|
||||||
this.ui.setLatLngs(latlngs[0])
|
this.ui.setLatLngs(latlngs[0])
|
||||||
if (!this.editEnabled()) this.edit()
|
this.pullGeometry()
|
||||||
this.editor.reset()
|
if (!this.ui.editEnabled()) this.edit()
|
||||||
|
this.ui.editor.reset()
|
||||||
this.isDirty = true
|
this.isDirty = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -351,3 +351,44 @@ def test_can_delete_shape_using_toolbar(live_server, page, tilelayer, settings):
|
||||||
53.159947,
|
53.159947,
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def test_can_merge_lines(live_server, page, tilelayer, settings):
|
||||||
|
settings.UMAP_ALLOW_ANONYMOUS = True
|
||||||
|
page.goto(f"{live_server.url}/en/map/new/")
|
||||||
|
page.get_by_title("Draw a polyline").click()
|
||||||
|
map = page.locator("#map")
|
||||||
|
map.click(position={"x": 100, "y": 100})
|
||||||
|
map.click(position={"x": 100, "y": 200})
|
||||||
|
map.click(position={"x": 100, "y": 200})
|
||||||
|
|
||||||
|
page.get_by_title("Add a line to the current multi").click()
|
||||||
|
map.click(position={"x": 200, "y": 100})
|
||||||
|
map.click(position={"x": 200, "y": 200})
|
||||||
|
map.click(position={"x": 200, "y": 200})
|
||||||
|
|
||||||
|
# Glue end nodes
|
||||||
|
map.drag_to(
|
||||||
|
map, source_position={"x": 200, "y": 200}, target_position={"x": 100, "y": 200}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Right click and merge nodes
|
||||||
|
map.click(button="right", position={"x": 100, "y": 200})
|
||||||
|
map.get_by_role("link", name="Merge lines").click()
|
||||||
|
data = save_and_get_json(page)
|
||||||
|
assert len(data["features"]) == 1
|
||||||
|
assert data["features"][0]["geometry"]["type"] == "LineString"
|
||||||
|
assert data["features"][0]["geometry"]["coordinates"] == [
|
||||||
|
[
|
||||||
|
-9.865723,
|
||||||
|
54.457267,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
-9.865723,
|
||||||
|
53.159947,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
-7.668457,
|
||||||
|
54.457267,
|
||||||
|
],
|
||||||
|
]
|
||||||
|
|
Loading…
Reference in a new issue