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 multi_geometry: ET.Element = ET.SubElement(placemark, "MultiGeometry")
49 polygon: ET.Element = ET.SubElement(multi_geometry, "Polygon")
50 outer_boundary: ET.Element = ET.SubElement(polygon, "outerBoundaryIs")
51 linear_ring: ET.Element = ET.SubElement(outer_boundary, "LinearRing")
52 coordinates: ET.Element = ET.SubElement(linear_ring, "coordinates")
53 points: list[Point] = Hexagon.polygon_corners(self.layout, self.position)
54 points.append(points[0])
55 method = GeoLocation(self.geoLocation).point_to_geo_location
56 geo_locations: list[GeoLocation] = list(map(method, points))
58 for geo_location in geo_locations:
60 f"{geo_location.longitude},{geo_location.latitude},{geo_location.aboveMeanSeaLevel}"
62 coordinates.text = " ".join(text)
65 cell_angle = self.parent.parent.parent.parent.parent.configuration()["pattern"][
68 for index in range(int(360 / cell_angle)):
69 line: ET.Element = ET.SubElement(multi_geometry, "LineString")
70 tessellate: ET.Element = ET.SubElement(line, "tessellate")
72 coordinates: ET.Element = ET.SubElement(line, "coordinates")
74 intersect: Point = Point(
75 points[2 * index].x - points[2 * index + 1].x / 2,
76 points[2 * index].y - points[2 * index + 1].y / 2,
78 intersect_geo_location: GeoLocation = GeoLocation(
80 ).point_to_geo_location(intersect)
83 f"{intersect_geo_location.longitude},{intersect_geo_location.latitude},{intersect_geo_location.aboveMeanSeaLevel}"
86 f"{self.geoLocation['longitude']},{self.geoLocation['latitude']},{self.geoLocation['aboveMeanSeaLevel']}"
88 coordinates.text = " ".join(text)