Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: UWARG/common
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c1f343ff258d2ba493dc8bc283dc95d855dd63e7
Choose a base ref
...
head repository: UWARG/common
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a886a389be700cd3ada97c1f58187a5bf127bb1c
Choose a head ref
  • 1 commit
  • 3 files changed
  • 1 contributor

Commits on Feb 18, 2024

  1. Fix KML import (#25)

    * Import and formatting fixes
    
    * Renamed file
    Xierumeng authored Feb 18, 2024
    Copy the full SHA
    a886a38 View commit details
Showing with 22 additions and 20 deletions.
  1. +7 −7 kml/modules/ground_locations_to_kml.py
  2. +7 −5 kml/modules/location_ground.py
  3. +8 −8 kml/{test_waypoints_to_kml.py → test_ground_locations_to_kml.py}
14 changes: 7 additions & 7 deletions kml/modules/ground_locations_to_kml.py
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@

import simplekml

from kml.modules import location_ground
from . import location_ground


def ground_locations_to_kml(ground_locations: "list[location_ground.LocationGround]",
@@ -30,13 +30,13 @@ def ground_locations_to_kml(ground_locations: "list[location_ground.LocationGrou
"""
kml = simplekml.Kml()

for index, ground_location in enumerate(ground_locations):
ground_location_name = f"Point {index + 1}: {ground_location.name}"
lat = ground_location.latitude
lng = ground_location.longitude
for i, ground_location in enumerate(ground_locations):
ground_location_name = f"Point {i + 1}: {ground_location.name}"
latitude = ground_location.latitude
longitude = ground_location.longitude

# coords parameters are in the order: lon, lat, optional height
kml.newpoint(name=ground_location_name, coords=[(lng, lat)])
# Coordinates are in the order: longitude, latitude, optional height
kml.newpoint(name=ground_location_name, coords=[(longitude, latitude)])

kml_file_path = pathlib.Path(save_directory, f"{document_name_prefix}_{int(time.time())}.kml")

12 changes: 7 additions & 5 deletions kml/modules/location_ground.py
Original file line number Diff line number Diff line change
@@ -4,7 +4,8 @@

class LocationGround:
"""
LocationGround class represents a geographical ground location with a name, latitude, and longitude.
LocationGround class represents a geographical ground location with
a name, latitude, and longitude.
Attributes:
name (str): The name or label for the location.
@@ -29,7 +30,7 @@ def __init__(self, name: str, latitude: float, longitude: float):
self.latitude = latitude
self.longitude = longitude

def __eq__(self, other: "LocationGround"):
def __eq__(self, other: "LocationGround") -> bool:
"""
Checks if two LocationGround objects are equal.
@@ -45,8 +46,9 @@ def __eq__(self, other: "LocationGround"):
and self.longitude == other.longitude
)

def __repr__(self):
def __repr__(self) -> str:
"""
Returns a string representation of the LocationGround object.
String representation
"""
return f"LocationGround: {self.name}, latitude: {self.latitude}, longitude: {self.longitude})"
return \
f"LocationGround: {self.name}, latitude: {self.latitude}, longitude: {self.longitude}"
Original file line number Diff line number Diff line change
@@ -14,18 +14,18 @@


@pytest.fixture
def waypoints():
def locations():
"""
Waypoints input.
List of LocationGround.
"""
return [
location_ground.LocationGround("San Francisco", 37.7749, -122.4194),
location_ground.LocationGround("Los Angeles", 34.0522, -118.2437),
location_ground.LocationGround("New York City", 40.7128, -74.0060)
yield [
location_ground.LocationGround("San Francisco", 37.7749, -122.4194),
location_ground.LocationGround("Los Angeles", 34.0522, -118.2437),
location_ground.LocationGround("New York City", 40.7128, -74.0060),
]


def test_waypoints_to_kml_with_save_path(waypoints: "list[location_ground.LocationGround]",
def test_locations_to_kml_with_save_path(locations: "list[location_ground.LocationGround]",
tmp_path: pathlib.Path):
"""
Basic test case to save KML to the correct path when provided.
@@ -37,7 +37,7 @@ def test_waypoints_to_kml_with_save_path(waypoints: "list[location_ground.Locati
tmp_path.mkdir(parents=True, exist_ok=True)

result, actual_kml_file_path = ground_locations_to_kml.ground_locations_to_kml(
waypoints,
locations,
actual_kml_document_name,
tmp_path,
)