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 import xml.etree.ElementTree as ET
21 from typing import overload
23 import network_generation.model.python.hexagon as Hexagon
24 from network_generation.model.python.geo_location import GeoLocation
25 from network_generation.model.python.o_ran_node import ORanNode
26 from network_generation.model.python.o_ran_object import IORanObject
27 from network_generation.model.python.o_ran_termination_point import (
30 from network_generation.model.python.point import Point
33 # Define the "INrCellDu" interface
34 class INrCellDu(IORanObject):
35 def __init__(self, cell_angel: int, azimuth: int, **kwargs):
36 super().__init__(**kwargs)
37 self._cell_angle = cell_angel
38 self._azimuth = azimuth
41 # Define an abstract O-RAN Node class
42 class NrCellDu(ORanNode, INrCellDu):
43 def __init__(self, cell_data: INrCellDu = None, **kwargs):
44 super().__init__(cell_data, **kwargs)
46 cell_data["cellAngle"]
47 if cell_data and "cellAngle" in cell_data
51 cell_data["azimuth"] if cell_data and "azimuth" in cell_data else 0
55 def termination_points(self) -> list[ORanTerminationPoint]:
56 result: list[ORanTerminationPoint] = super().termination_points
58 ORanTerminationPoint({"id": self.name, "name": self.name})
62 def to_topology_nodes(self) -> list[dict[str, dict]]:
63 # a cell is not a node it is a Termination Point
64 result: list[dict[str, dict]] = [] # super().to_topology_nodes()
67 def to_topology_links(self) -> list[dict[str, dict]]:
68 # as a cell is not a node, it does not have links
69 result: list[dict[str, dict]] = [] # super().to_topology_links()
72 def toKml(self) -> ET.Element:
73 placemark: ET.Element = ET.Element("Placemark")
74 name: ET.Element = ET.SubElement(placemark, "name")
76 style: ET.Element = ET.SubElement(placemark, "styleUrl")
77 style.text = "#" + self.__class__.__name__
78 multi_geometry: ET.Element = ET.SubElement(placemark, "MultiGeometry")
79 polygon: ET.Element = ET.SubElement(multi_geometry, "Polygon")
80 outer_boundary: ET.Element = ET.SubElement(polygon, "outerBoundaryIs")
81 linear_ring: ET.Element = ET.SubElement(outer_boundary, "LinearRing")
82 coordinates: ET.Element = ET.SubElement(linear_ring, "coordinates")
84 points: list[Point] = Hexagon.polygon_corners(
85 self.layout, self.position
88 self.parent.parent.parent.parent.parent.parent.geoLocation
89 ).point_to_geo_location
90 geo_locations: list[GeoLocation] = list(map(method, points))
93 index: int = 1 + int(self._azimuth / self._cell_angle)
94 network_center: GeoLocation = GeoLocation(
95 self.parent.parent.parent.parent.parent.parent.geoLocation
98 intersect1: Point = Point(
99 (points[(2 * index + 1) % 6].x + points[(2 * index + 2) % 6].x)
101 (points[(2 * index + 1) % 6].y + points[(2 * index + 2) % 6].y)
104 intersect_geo_location1: GeoLocation = (
105 network_center.point_to_geo_location(intersect1)
108 intersect2: Point = Point(
109 (points[(2 * index + 3) % 6].x + points[(2 * index + 4) % 6].x)
111 (points[(2 * index + 3) % 6].y + points[(2 * index + 4) % 6].y)
114 intersect_geo_location2: GeoLocation = (
115 network_center.point_to_geo_location(intersect2)
118 tower: GeoLocation = GeoLocation(self.geoLocation)
120 cell_polygon: list[GeoLocation] = []
121 cell_polygon.append(tower)
122 cell_polygon.append(intersect_geo_location1)
123 cell_polygon.append(geo_locations[(2 * index + 2) % 6])
124 cell_polygon.append(geo_locations[(2 * index + 3) % 6])
125 cell_polygon.append(intersect_geo_location2)
127 cell_polygon.append(tower)
129 for geo_location in cell_polygon:
131 f"{'%.6f' % geo_location.longitude},{'%.6f' % geo_location.latitude},{'%.6f' % geo_location.aboveMeanSeaLevel}"
133 coordinates.text = " ".join(text)
137 def toSvg(self) -> None: