Skip to content

Commit

Permalink
force compute_flight_positions and compute_future_flight_positions to…
Browse files Browse the repository at this point in the history
… return valid coordinates
  • Loading branch information
clementzach committed Jan 19, 2024
1 parent 4972e87 commit 913e362
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions forest/jasmine/data2mobmat.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,12 @@ def gps_to_mobmat(

return mobmat

def force_valid_longitude(longitude):
"""Forces a longitude coordinate to be within -180 and 180
Args:
longitude: float. The longitude to be coerced
"""
return (longitude + 180) % 360 - 180

def compute_flight_positions(
index: int, mobmat: np.ndarray, interval: float
Expand Down Expand Up @@ -656,8 +662,8 @@ def compute_flight_positions(
# Update the mobility matrix with the new start and end positions
mobmat[index, 1] = start_x
mobmat[index, 4] = end_x
mobmat[index, 2] = start_y
mobmat[index, 5] = end_y
mobmat[index, 2] = force_valid_longitude(start_y)
mobmat[index, 5] = force_valid_longitude(end_y)

return mobmat

Expand Down Expand Up @@ -704,8 +710,8 @@ def compute_future_flight_positions(
# Update the mobility matrix with the new start and end positions
mobmat[index, 1] = start_x
mobmat[index, 4] = end_x
mobmat[index, 2] = start_y
mobmat[index, 5] = end_y
mobmat[index, 2] = force_valid_longitude(start_y)
mobmat[index, 5] = force_valid_longitude(end_y)

return mobmat

Expand Down

0 comments on commit 913e362

Please sign in to comment.