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 3GPP new radio cell du (NrCellDu)
20 from model.python.o_ran_object import IORanObject
21 from model.python.o_ran_node import ORanNode
22 import model.python.hexagon as Hexagon
23 from model.python.point import Point
24 from model.python.geo_location import GeoLocation
25 import xml.etree.ElementTree as ET
28 # Define the "INrCellDu" interface
29 class INrCellDu(IORanObject):
30 def __init__(self, cell_angel: int, azimuth: int, **kwargs):
31 super().__init__(**kwargs)
32 self._cell_angle = cell_angle
33 self._azimuth = azimuth
36 # Define an abstract O-RAN Node class
37 class NrCellDu(ORanNode, INrCellDu):
38 def __init__(self, cell_data: INrCellDu = None, **kwargs):
39 super().__init__(cell_data, **kwargs)
41 cell_data["cellAngle"] if cell_data and "cellAngle" in cell_data else 120
44 cell_data["azimuth"] if cell_data and "azimuth" in cell_data else 0
47 def toKml(self) -> ET.Element:
48 placemark: ET.Element = ET.Element("Placemark")
49 name: ET.Element = ET.SubElement(placemark, "name")
51 style: ET.Element = ET.SubElement(placemark, "styleUrl")
52 style.text = "#" + self.__class__.__name__
53 multi_geometry: ET.Element = ET.SubElement(placemark, "MultiGeometry")
54 polygon: ET.Element = ET.SubElement(multi_geometry, "Polygon")
55 outer_boundary: ET.Element = ET.SubElement(polygon, "outerBoundaryIs")
56 linear_ring: ET.Element = ET.SubElement(outer_boundary, "LinearRing")
57 coordinates: ET.Element = ET.SubElement(linear_ring, "coordinates")
59 points: list[Point] = Hexagon.polygon_corners(self.layout, self.position)
61 self.parent.parent.parent.parent.parent.parent.geoLocation
62 ).point_to_geo_location
63 geo_locations: list[GeoLocation] = list(map(method, points))
67 index: int = 1 + int(self._azimuth/self._cell_angle)
68 network_center:GeoLocation = GeoLocation(self.parent.parent.parent.parent.parent.parent.geoLocation)
70 intersect1: Point = Point(
71 (points[(2 * index +1) % 6].x + points[(2 * index +2) % 6].x) / 2,
72 (points[(2 * index +1) % 6].y + points[(2 * index +2) % 6].y) / 2,
74 intersect_geo_location1: GeoLocation = network_center.point_to_geo_location(intersect1)
76 intersect2: Point = Point(
77 (points[(2 * index +3) % 6].x + points[(2 * index +4) % 6].x) / 2,
78 (points[(2 * index +3) % 6].y + points[(2 * index +4) % 6].y) / 2,
80 intersect_geo_location2: GeoLocation = network_center.point_to_geo_location(intersect2)
82 tower:GeoLocation = GeoLocation(self.geoLocation)
84 cell_polygon: list[GeoLocation] = []
85 cell_polygon.append(tower)
86 cell_polygon.append(intersect_geo_location1)
87 cell_polygon.append(geo_locations[(2 * index + 2) % 6])
88 cell_polygon.append(geo_locations[(2 * index + 3) % 6])
89 cell_polygon.append(intersect_geo_location2)
91 cell_polygon.append(tower)
93 for geo_location in cell_polygon:
95 f"{'%.6f' % geo_location.longitude},{'%.6f' % geo_location.latitude},{'%.6f' % geo_location.aboveMeanSeaLevel}"
97 coordinates.text = " ".join(text)
101 def toSvg(self) -> None: