Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add converter between AV2 city coordinate systems, and WGS84 and UTM #28

Merged
merged 14 commits into from
Apr 12, 2022
Prev Previous commit
Next Next commit
improve typing and docstrings
  • Loading branch information
John Lambert committed Mar 27, 2022
commit 918c4214bb236b286363ddf9b86b8157950185a3
14 changes: 7 additions & 7 deletions src/av2/geometry/utm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"""Utilities for converting AV2 city coordinates to UTM or WGS84 coordinate systems."""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add some information about these two coordinate systems here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I added some references.


from enum import Enum
from enum import unique, Enum
from typing import Dict, Final, Tuple, Union

import numpy as np
Expand Down Expand Up @@ -69,29 +69,29 @@ def convert_city_coords_to_utm(points_city: Union[NDArrayFloat, NDArrayInt], cit
"""Convert city coordinates to UTM coordinates.

Args:
points_city: 2d coordinates, representing query points in the city coordinate frame.
points_city: (N,2) array, representing 2d query points in the city coordinate frame.
city_name: name of city, where query points are located.

Returns:
Points in the UTM coordinate system, as (easting, northing).
Array of shape (N,2), representing points in the UTM coordinate system, as (easting, northing).
"""
lat, long = CITY_ORIGIN_LATLONG_DICT[city_name]
# get (easting, northing) of origin
origin_utm = convert_gps_to_utm(lat=lat, long=long, city_name=city_name)

points_utm: NDArrayFloat = points_city + origin_utm
points_utm: NDArrayFloat = points_city.astype(float) + np.array(origin_utm, dtype=float) # type: ignore
return points_utm


def convert_city_coords_to_wgs84(points_city: Union[NDArrayFloat, NDArrayInt], city_name: CityName) -> NDArrayFloat:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def convert_city_coords_to_wgs84(points_city: Union[NDArrayFloat, NDArrayInt], city_name: CityName) -> NDArrayFloat:
def convert_city_coords_to_wgs84(points_xy_city: Union[NDArrayFloat, NDArrayInt], city_name: CityName) -> NDArrayFloat:

Prefer xy to make it clear these points are 2D.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit biased towards what we have, since I think points_xy_city is maybe getting a bit too long for a name.

"""Convert city coordinates to WGS84 coordinates.

Args:
points_city: 2d coordinates, representing query points in the city coordinate frame.
points_city: (N,2) array, representing 2d query points in the city coordinate frame.
city_name: name of city, where query points are located.

Returns:
Points in the WGS84 coordinate system, as (lat, long).
Array of shape (N,2), representing points in the WGS84 coordinate system, as (lat, long).
"""
points_utm = convert_city_coords_to_utm(points_city, city_name)

Expand Down