Skip to content

Commit

Permalink
fix errors in coordinate transformation and field creation
Browse files Browse the repository at this point in the history
  • Loading branch information
rodja committed May 7, 2024
1 parent ca48eee commit e4f4d99
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
2 changes: 2 additions & 0 deletions field_friend/interface/components/leaflet_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from nicegui import app, events, ui
from nicegui.elements.leaflet_layers import TileLayer

from field_friend.automations.field_provider import Field

from .key_controls import KeyControls

if TYPE_CHECKING:
Expand Down
18 changes: 7 additions & 11 deletions field_friend/navigation/point_transformation.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
from typing import List

import numpy as np
from geographiclib.geodesic import Geodesic


def wgs84_to_cartesian(reference, point) -> List[float]:
def wgs84_to_cartesian(reference, point) -> list[float]:
r = Geodesic.WGS84.Inverse(reference[0], reference[1], point[0], point[1])
s = r['s12']
a = -np.deg2rad(r['azi1'])
x = s * np.cos(a)
y = s * np.sin(a)
cartesian_coords = [x, y]
return cartesian_coords
a = np.deg2rad(r['azi1'])
x = s * np.sin(a)
y = s * np.cos(a)
return [x, y]


def cartesian_to_wgs84(reference, point) -> List[float]:
def cartesian_to_wgs84(reference, point) -> list[float]:
r = Geodesic.WGS84.Direct(reference[0], reference[1], 90.0, point[0])
r = Geodesic.WGS84.Direct(r['lat2'], r['lon2'], 0.0, point[1])
wgs84_coords = [r['lat2'], r['lon2']]
return wgs84_coords
return [r['lat2'], r['lon2']]


def get_new_position(reference, distance, yaw):
Expand Down

0 comments on commit e4f4d99

Please sign in to comment.