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 typing import overload
22 from network_generation.model.python.o_ran_termination_point import ORanTerminationPoint
23 from network_generation.model.python.o_ran_object import IORanObject
24 from network_generation.model.python.o_ran_node import ORanNode
25 import network_generation.model.python.hexagon as Hexagon
26 from network_generation.model.python.point import Point
27 from network_generation.model.python.geo_location import GeoLocation
28 import xml.etree.ElementTree as ET
31 # Define the "INrCellDu" interface
32 class INrCellDu(IORanObject):
33 def __init__(self, cell_angel: int, azimuth: int, **kwargs):
34 super().__init__(**kwargs)
35 self._cell_angle = cell_angel
36 self._azimuth = azimuth
39 # Define an abstract O-RAN Node class
40 class NrCellDu(ORanNode, INrCellDu):
41 def __init__(self, cell_data: INrCellDu = None, **kwargs):
42 super().__init__(cell_data, **kwargs)
44 cell_data["cellAngle"] if cell_data and "cellAngle" in cell_data else 120
47 cell_data["azimuth"] if cell_data and "azimuth" in cell_data else 0
51 def termination_points(self) -> list[ORanTerminationPoint]:
52 result: list[ORanTerminationPoint] = super().termination_points
53 result.append(ORanTerminationPoint({"id": self.name, "name": self.name}))
56 def to_topology_nodes(self) -> list[dict[str, dict]]:
57 # a cell is not a node it is a Termination Point
58 result: list[dict[str, dict]] = [] # super().to_topology_nodes()
61 def to_topology_links(self) -> list[dict[str, dict]]:
62 # as a cell is not a node, it does not have links
63 result: list[dict[str, dict]] = [] # super().to_topology_links()
66 def toKml(self) -> ET.Element:
67 placemark: ET.Element = ET.Element("Placemark")
68 name: ET.Element = ET.SubElement(placemark, "name")
70 style: ET.Element = ET.SubElement(placemark, "styleUrl")
71 style.text = "#" + self.__class__.__name__
72 multi_geometry: ET.Element = ET.SubElement(placemark, "MultiGeometry")
73 polygon: ET.Element = ET.SubElement(multi_geometry, "Polygon")
74 outer_boundary: ET.Element = ET.SubElement(polygon, "outerBoundaryIs")
75 linear_ring: ET.Element = ET.SubElement(outer_boundary, "LinearRing")
76 coordinates: ET.Element = ET.SubElement(linear_ring, "coordinates")
78 points: list[Point] = Hexagon.polygon_corners(self.layout, self.position)
80 self.parent.parent.parent.parent.parent.parent.geoLocation
81 ).point_to_geo_location
82 geo_locations: list[GeoLocation] = list(map(method, points))
85 index: int = 1 + int(self._azimuth / self._cell_angle)
86 network_center: GeoLocation = GeoLocation(
87 self.parent.parent.parent.parent.parent.parent.geoLocation
90 intersect1: Point = Point(
91 (points[(2 * index + 1) % 6].x + points[(2 * index + 2) % 6].x) / 2,
92 (points[(2 * index + 1) % 6].y + points[(2 * index + 2) % 6].y) / 2,
94 intersect_geo_location1: GeoLocation = network_center.point_to_geo_location(
98 intersect2: Point = Point(
99 (points[(2 * index + 3) % 6].x + points[(2 * index + 4) % 6].x) / 2,
100 (points[(2 * index + 3) % 6].y + points[(2 * index + 4) % 6].y) / 2,
102 intersect_geo_location2: GeoLocation = network_center.point_to_geo_location(
106 tower: GeoLocation = GeoLocation(self.geoLocation)
108 cell_polygon: list[GeoLocation] = []
109 cell_polygon.append(tower)
110 cell_polygon.append(intersect_geo_location1)
111 cell_polygon.append(geo_locations[(2 * index + 2) % 6])
112 cell_polygon.append(geo_locations[(2 * index + 3) % 6])
113 cell_polygon.append(intersect_geo_location2)
115 cell_polygon.append(tower)
117 for geo_location in cell_polygon:
119 f"{'%.6f' % geo_location.longitude},{'%.6f' % geo_location.latitude},{'%.6f' % geo_location.aboveMeanSeaLevel}"
121 coordinates.text = " ".join(text)
125 def toSvg(self) -> None: