From c4f6ee09220c539928ff50a6fe9d010d610b8e0b Mon Sep 17 00:00:00 2001 From: Martin Skorupski Date: Tue, 8 Oct 2024 18:45:47 +0200 Subject: [PATCH] All links to kml - add to method 'toKml' generic folder, placemark, point, and line representation - fix GeoLocation type issue Issue-ID: OAM-395 Change-Id: I0bd116604f173f7843a09aabed35e8ce719b2e14 Signed-off-by: Martin Skorupski --- .../network_generation/model/python/o_ran_node.py | 55 ++++++++++++++++++++-- 1 file changed, 50 insertions(+), 5 deletions(-) diff --git a/code/network-generator/network_generation/model/python/o_ran_node.py b/code/network-generator/network_generation/model/python/o_ran_node.py index 8ad877b..9586de8 100644 --- a/code/network-generator/network_generation/model/python/o_ran_node.py +++ b/code/network-generator/network_generation/model/python/o_ran_node.py @@ -106,9 +106,7 @@ class ORanNode(ORanObject): self._address: AddressType = cast( AddressType, o_ran_node_data["address"] ) - self._geo_location: GeoLocation = cast( - GeoLocation, o_ran_node_data["geoLocation"] - ) + self._geo_location: GeoLocation = o_ran_node_data["geoLocation"] self._url: str = str(o_ran_node_data["url"]) self._position: Hex = cast(Hex, o_ran_node_data["position"]) self._layout: Layout = cast(Layout, o_ran_node_data["layout"]) @@ -274,8 +272,55 @@ class ORanNode(ORanObject): return result @abstractmethod - def toKml(self) -> ET.Element | None: - pass + def toKml(self) -> ET.Element: + folder: ET.Element = ET.Element("Folder") + open: ET.Element = ET.SubElement(folder, "open") + open.text = "1" + name: ET.Element = ET.SubElement(folder, "name") + name.text = self.name + + placemark: ET.Element = ET.SubElement(folder, "Placemark") + name: ET.Element = ET.SubElement(placemark, "name") + name.text = self.name + style: ET.Element = ET.SubElement(placemark, "styleUrl") + style.text = f'#{self.__class__.__name__}' + multi_geometry: ET.Element = ET.SubElement(placemark, "MultiGeometry") + + # my position as point + point: ET.Element = ET.SubElement(multi_geometry, "Point") + point_coordinates: ET.Element = ET.SubElement(point, "coordinates") + + point_gl = self.geo_location + point_coordinates.text = ",".join([ + str("%.6f" % float(point_gl.longitude)), + str("%.6f" % float(point_gl.latitude)), + str("%.6f" % float(point_gl.aboveMeanSeaLevel)), + ]) + + # link to parent + if (getattr(self.parent, 'geo_location', None) is not None): + line: ET.Element = ET.SubElement(multi_geometry, "LineString") + extrude: ET.Element = ET.SubElement(line, "extrude") + extrude.text = "1" + tessellate: ET.Element = ET.SubElement(line, "tessellate") + tessellate.text = "1" + coordinates: ET.Element = ET.SubElement(line, "coordinates") + + my_gl = self.geo_location + parent_gl = self.parent.geo_location + coordinates.text = " ".join([ + ",".join([ + str("%.6f" % float(my_gl.longitude)), + str("%.6f" % float(my_gl.latitude)), + str("%.6f" % float(my_gl.aboveMeanSeaLevel)), + ]), + ",".join([ + str("%.6f" % float(parent_gl.longitude)), + str("%.6f" % float(parent_gl.latitude)), + str("%.6f" % float(parent_gl.aboveMeanSeaLevel)), + ]), + ]) + return folder @abstractmethod def toSvg(self) -> ET.Element: -- 2.16.6