X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=code%2Fnetwork-generator%2Fmodel%2Fpython%2Ftower.py;h=46a906e5f9e861df528a6a823a751571842aa717;hb=a54969af42280658929f06ddece99710e959439f;hp=2070348009861c98a792bd4ffc4a0d87b975ad50;hpb=9ea4e241e3ec0c9dffd3db7fd7ab5a2cf3d13e7d;p=oam.git diff --git a/code/network-generator/model/python/tower.py b/code/network-generator/model/python/tower.py index 2070348..46a906e 100644 --- a/code/network-generator/model/python/tower.py +++ b/code/network-generator/model/python/tower.py @@ -17,19 +17,70 @@ """ A Class representing a Tower to mount O-RAN RUx """ -from typing import Any, Dict - -from model.python.o_ran_object import IORanObject +import model.python.hexagon as Hexagon +from model.python.point import Point +from model.python.geo_location import GeoLocation from model.python.o_ran_node import ORanNode +import xml.etree.ElementTree as ET # Define an abstract O-RAN Node class class Tower(ORanNode): - def __init__(self, of: IORanObject = None, **kwargs): - super().__init__(of, **kwargs) + # def __init__(self, **kwargs): + # super().__init__(**kwargs) - def toKml(self): - return None + def toKml(self) -> ET.Element: + placemark: ET.Element = ET.Element("Placemark") + name: ET.Element = ET.SubElement(placemark, "name") + name.text = self.name + style: ET.Element = ET.SubElement(placemark, "styleUrl") + style.text = "#" + self.__class__.__name__ + multi_geometry: ET.Element = ET.SubElement(placemark, "MultiGeometry") + polygon: ET.Element = ET.SubElement(multi_geometry, "Polygon") + outer_boundary: ET.Element = ET.SubElement(polygon, "outerBoundaryIs") + linear_ring: ET.Element = ET.SubElement(outer_boundary, "LinearRing") + coordinates: ET.Element = ET.SubElement(linear_ring, "coordinates") + + points: list[Point] = Hexagon.polygon_corners(self.layout, self.position) + points.append(points[0]) + method = GeoLocation( + self.parent.parent.parent.parent.geoLocation + ).point_to_geo_location + geo_locations: list[GeoLocation] = list(map(method, points)) + text: list[str] = [] + for geo_location in geo_locations: + text.append( + f"{geo_location.longitude},{geo_location.latitude},{geo_location.aboveMeanSeaLevel}" + ) + coordinates.text = " ".join(text) + + # cells + cell_angle = self.parent.parent.parent.parent.parent.configuration()["pattern"][ + "o-ran-ru" + ]["cell-angle"] + for index in range(int(360 / cell_angle)): + line: ET.Element = ET.SubElement(multi_geometry, "LineString") + tessellate: ET.Element = ET.SubElement(line, "tessellate") + tessellate.text = "1" + coordinates: ET.Element = ET.SubElement(line, "coordinates") + + intersect: Point = Point( + (points[2 * index+2].x + points[2 * index + 1].x) / 2, + (points[2 * index+2].y + points[2 * index + 1].y) / 2, + ) + intersect_geo_location: GeoLocation = GeoLocation( + self.parent.parent.parent.parent.geoLocation + ).point_to_geo_location(intersect) + text: list[str] = [] + text.append( + f"{intersect_geo_location.longitude},{intersect_geo_location.latitude},{intersect_geo_location.aboveMeanSeaLevel}" + ) + text.append( + f"{self.geoLocation['longitude']},{self.geoLocation['latitude']},{self.geoLocation['aboveMeanSeaLevel']}" + ) + coordinates.text = " ".join(text) + + return placemark - def toSvg(self): + def toSvg(self) -> None: return None