From 809c7bfdf19790349202dd42496758d0fe0f4782 Mon Sep 17 00:00:00 2001 From: Martin Skorupski Date: Wed, 18 Oct 2023 15:28:27 +0200 Subject: [PATCH] Create concrete classes for O-RAN Nodes - update functions on Tower Issue-ID: OAM-368 Change-Id: I7e803712069be4f262466805d74a11903bffee91 Signed-off-by: Martin Skorupski --- code/network-generator/model/python/tower.py | 37 +++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/code/network-generator/model/python/tower.py b/code/network-generator/model/python/tower.py index 2070348..869b3f5 100644 --- a/code/network-generator/model/python/tower.py +++ b/code/network-generator/model/python/tower.py @@ -19,17 +19,46 @@ A Class representing a Tower to mount O-RAN RUx """ from typing import Any, Dict +import model.python.hexagon as Hexagon +from model.python.hexagon import Hex, Layout, Point +from model.python.geo_location import GeoLocation + from model.python.o_ran_object import IORanObject from model.python.o_ran_node import ORanNode +import xml.etree.ElementTree as ET + + +# Define the "ITower" interface +class ITower(IORanObject): + def __init__(self, layout: Layout, hex: Hex = None, **kwargs): + super().__init__(**kwargs) # Define an abstract O-RAN Node class -class Tower(ORanNode): - def __init__(self, of: IORanObject = None, **kwargs): - super().__init__(of, **kwargs) +class Tower(ORanNode, ITower): + def __init__(self, tower_data: ITower = None, **kwargs): + super().__init__(tower_data, **kwargs) def toKml(self): - return None + 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__ + polygon: ET.Element = ET.SubElement(placemark, "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.geoLocation).point_to_geo_location + geo_locations: list[GeoLocation] = map(method, points) + text:list[str] = [] + for geo_location in list(geo_locations): + text.append(f"{geo_location.longitude},{geo_location.latitude},{geo_location.aboveMeanSeaLevel}") + coordinates.text = " ".join(text) + return placemark def toSvg(self): return None -- 2.16.6