1 # Copyright 2023 highstreet technologies GmbH
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
18 A Class representing a Tower to mount O-RAN RUx
20 from typing import Any, Dict
22 import model.python.hexagon as Hexagon
23 from model.python.hexagon import Hex, Layout, Point
24 from model.python.geo_location import GeoLocation
26 from model.python.o_ran_object import IORanObject
27 from model.python.o_ran_node import ORanNode
28 import xml.etree.ElementTree as ET
31 # Define the "ITower" interface
32 class ITower(IORanObject):
33 def __init__(self, layout: Layout, hex: Hex = None, **kwargs):
34 super().__init__(**kwargs)
37 # Define an abstract O-RAN Node class
38 class Tower(ORanNode, ITower):
39 def __init__(self, tower_data: ITower = None, **kwargs):
40 super().__init__(tower_data, **kwargs)
43 placemark: ET.Element = ET.Element("Placemark")
44 name: ET.Element = ET.SubElement(placemark, "name")
46 style: ET.Element = ET.SubElement(placemark, "styleUrl")
47 style.text = "#" + self.__class__.__name__
48 polygon: ET.Element = ET.SubElement(placemark, "Polygon")
49 outer_boundary: ET.Element = ET.SubElement(polygon, "outerBoundaryIs")
50 linear_ring: ET.Element = ET.SubElement(outer_boundary, "LinearRing")
51 coordinates: ET.Element = ET.SubElement(linear_ring, "coordinates")
52 points: list[Point] = Hexagon.polygon_corners(self.layout, self.position)
53 points.append(points[0])
55 method = GeoLocation(self.geoLocation).point_to_geo_location
56 geo_locations: list[GeoLocation] = map(method, points)
58 for geo_location in list(geo_locations):
59 text.append(f"{geo_location.longitude},{geo_location.latitude},{geo_location.aboveMeanSeaLevel}")
60 coordinates.text = " ".join(text)