feat(extract): Küste, Straßenflächen, Brückenerkennung, Mittellinien
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
38aed38b02
commit
ab1d64a1c2
2 files changed
+130
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import numpy as np
|
||||
from leonida.classify import CLASSES
|
||||
from leonida.vectors import land_polygons, mask_polygons, road_polygons
|
||||
|
||||
def test_square_becomes_one_polygon_with_right_area():
|
||||
mask = np.zeros((100, 100), dtype=bool)
|
||||
mask[20:60, 30:80] = True # 40 x 50 Pixel = 2000 m²
|
||||
polys = mask_polygons(mask, min_area=10, simplify=1.0)
|
||||
assert len(polys) == 1
|
||||
assert abs(polys[0].area - 2000) < 60 # Vereinfachung darf etwas abweichen
|
||||
|
||||
def test_island_keeps_its_lagoon():
|
||||
labels = np.full((80, 80), CLASSES["wasser"], dtype=np.uint8)
|
||||
labels[10:70, 10:70] = CLASSES["land"]
|
||||
labels[30:50, 30:50] = CLASSES["wasser"] # Lagune
|
||||
polys = land_polygons(labels)
|
||||
assert len(polys) == 1
|
||||
assert len(polys[0].interiors) == 1
|
||||
|
||||
def test_road_over_water_is_flagged_as_bridge():
|
||||
labels = np.full((60, 60), CLASSES["wasser"], dtype=np.uint8)
|
||||
labels[0:10, :] = CLASSES["land"]
|
||||
labels[25:31, :] = CLASSES["strasse"] # Damm quer durchs Wasser
|
||||
roads = road_polygons(labels)
|
||||
assert len(roads) == 1
|
||||
assert roads[0][1] is True
|
||||
|
||||
def test_crossing_roads_form_a_single_polygon():
|
||||
labels = np.full((60, 60), CLASSES["land"], dtype=np.uint8)
|
||||
labels[28:32, :] = CLASSES["strasse"]
|
||||
labels[:, 28:32] = CLASSES["strasse"]
|
||||
roads = road_polygons(labels)
|
||||
assert len(roads) == 1 # Kreuzung, kein Zerfall in vier Arme
|
||||
Reference in new issue
Block a user