This commit is contained in:
parent
24b773efe3
commit
7a113273f4
1 changed files with 10 additions and 5 deletions
|
|
@ -24,6 +24,11 @@ import logging
|
||||||
# импорт из модуля удовлетворяет strict no-implicit-reexport.
|
# импорт из модуля удовлетворяет strict no-implicit-reexport.
|
||||||
from ezdxf.enums import TextEntityAlignment
|
from ezdxf.enums import TextEntityAlignment
|
||||||
from ezdxf.filemanagement import new as ezdxf_new
|
from ezdxf.filemanagement import new as ezdxf_new
|
||||||
|
|
||||||
|
# Modelspace определён в ezdxf.layouts.layout и не в __all__ пакета ezdxf.layouts;
|
||||||
|
# импорт из модуля-определителя удовлетворяет strict no-implicit-reexport (как ezdxf_new).
|
||||||
|
from ezdxf.layouts.layout import Modelspace
|
||||||
|
from shapely.coords import CoordinateSequence
|
||||||
from shapely.geometry import Polygon
|
from shapely.geometry import Polygon
|
||||||
|
|
||||||
from app.schemas.concept import ConceptVariant
|
from app.schemas.concept import ConceptVariant
|
||||||
|
|
@ -44,7 +49,7 @@ _LAYER_BUILDINGS = "BUILDINGS"
|
||||||
_LABEL_HEIGHT_M = 2.0
|
_LABEL_HEIGHT_M = 2.0
|
||||||
|
|
||||||
|
|
||||||
def _ring_points(coords: object) -> list[tuple[float, float]]:
|
def _ring_points(coords: CoordinateSequence) -> list[tuple[float, float]]:
|
||||||
"""Кольцо (exterior/interior) как список (x, y) для LWPolyline (без замыкающей точки)."""
|
"""Кольцо (exterior/interior) как список (x, y) для LWPolyline (без замыкающей точки)."""
|
||||||
pts = list(coords)
|
pts = list(coords)
|
||||||
# Shapely дублирует первую точку в конце; close=True у ezdxf замкнёт сам.
|
# Shapely дублирует первую точку в конце; close=True у ezdxf замкнёт сам.
|
||||||
|
|
@ -53,7 +58,7 @@ def _ring_points(coords: object) -> list[tuple[float, float]]:
|
||||||
return [(float(x), float(y)) for x, y in pts]
|
return [(float(x), float(y)) for x, y in pts]
|
||||||
|
|
||||||
|
|
||||||
def _add_polygon(msp: object, poly: Polygon, layer: str) -> None:
|
def _add_polygon(msp: Modelspace, poly: Polygon, layer: str) -> None:
|
||||||
"""Нарисовать полигон на слое: внешнее кольцо + каждое внутреннее (отверстие).
|
"""Нарисовать полигон на слое: внешнее кольцо + каждое внутреннее (отверстие).
|
||||||
|
|
||||||
LWPolyline не умеет дырки, поэтому каждое interior-кольцо эмитируется отдельной
|
LWPolyline не умеет дырки, поэтому каждое interior-кольцо эмитируется отдельной
|
||||||
|
|
@ -151,15 +156,15 @@ def _feature_to_metric_polygon(parcel: Parcel, feature: object) -> Polygon | Non
|
||||||
return None
|
return None
|
||||||
coords = geometry.get("coordinates")
|
coords = geometry.get("coordinates")
|
||||||
# Shapely mapping() emits nested tuples; accept both tuple and list.
|
# Shapely mapping() emits nested tuples; accept both tuple and list.
|
||||||
if not isinstance(coords, (list, tuple)) or not coords:
|
if not isinstance(coords, list | tuple) or not coords:
|
||||||
return None
|
return None
|
||||||
ring = coords[0]
|
ring = coords[0]
|
||||||
if not isinstance(ring, (list, tuple)) or len(ring) < 4:
|
if not isinstance(ring, list | tuple) or len(ring) < 4:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
metric_pts: list[tuple[float, float]] = []
|
metric_pts: list[tuple[float, float]] = []
|
||||||
for pt in ring:
|
for pt in ring:
|
||||||
if not isinstance(pt, (list, tuple)) or len(pt) < 2:
|
if not isinstance(pt, list | tuple) or len(pt) < 2:
|
||||||
return None
|
return None
|
||||||
lon, lat = float(pt[0]), float(pt[1])
|
lon, lat = float(pt[0]), float(pt[1])
|
||||||
x, y = parcel.wgs84_to_metric(lon, lat)
|
x, y = parcel.wgs84_to_metric(lon, lat)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue