Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def read_sls(self, filename: Path) -> None:
logging.info(f"Reading SLS file {filename}")
with filename.open("r") as fh:
for line in fh.readlines():
name, _, polygon, lower, upper = line.split()
self.elements[name].append(
Airspace(
name,
[
ExtrudedPolygon(
self.polygons[polygon],
float(lower),
float(upper),
)
size = len(self)
return self.assign(
**{
column_name: geo.distance(
self.data.latitude.values,
self.data.longitude.values,
other.latitude * np.ones(size),
other.longitude * np.ones(size),
)
/ 1852 # in nautical miles
}
)
from .airspace import Airspace # noqa: F811
if isinstance(other, Airspace):
other = other.flatten()
if isinstance(other, Polygon):
bounds = other.bounds
projection = pyproj.Proj(
proj="aea", # equivalent projection
lat_1=bounds[1],
lat_2=bounds[3],
lat_0=(bounds[1] + bounds[3]) / 2,
lon_0=(bounds[0] + bounds[2]) / 2,
)
transformer = pyproj.Transformer.from_proj(
pyproj.Proj("epsg:4326"), projection, always_xy=True
)
def plot(self, ax: GeoAxesSubplot, **kwargs) -> None: # coverage: ignore
flat = self.flatten()
if isinstance(flat, base.BaseMultipartGeometry):
for poly in flat:
# quick and dirty
sub = Airspace("", [ExtrudedPolygon(poly, 0, 0)])
sub.plot(ax, **kwargs)
return
if "facecolor" not in kwargs:
kwargs["facecolor"] = "None"
if "edgecolor" not in kwargs:
kwargs["edgecolor"] = ax._get_lines.get_next_color()
if "projection" in ax.__dict__:
ax.add_geometries([flat], crs=PlateCarree(), **kwargs)
else:
ax.add_patch(MplPolygon(list(flat.exterior.coords), **kwargs))
designator = ts.find("aixm:designator", self.ns)
if (
designator is not None
and cmp(name, designator.text)
and (
type_ is None
or ts.find("aixm:type", self.ns).text == type_
)
):
polygon = self.make_polygon(ts)
type_ = ts.find("aixm:type", self.ns).text
name_ = ts.find("aixm:name", self.ns)
if len(polygon) > 0:
airspace = Airspace(
name=name_.text if name_ is not None else None,
elements=polygon,
type_=type_,
designator=designator.text
if designator is not None
else None,
)
yield airspace
else:
warnings.warn(
f"{designator.text} produces an empty airspace",
RuntimeWarning,
)
def below(self, level: int) -> "Airspace":
return Airspace(
self.name,
list(c for c in self.elements if c.lower <= level),
type_=self.type,
)