Skip to content

Commit

Permalink
Add changelog. Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
cmarmo committed May 25, 2023
1 parent 65af784 commit a95410d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
5 changes: 2 additions & 3 deletions astropy/coordinates/representation/geodetic.py
Expand Up @@ -147,7 +147,6 @@ def from_cartesian(cls, cart):
lon, lat, height = erfa.gc2gde(
cls._equatorial_radius, cls._flattening, cart.get_xyz(xyz_axis=-1)
)
lon = _compute_longitude(lon, cls._positive_longitude, cls._wrap_angle)
if not cls._ographic:
# Compute planetocentric angles
xyz = cart.get_xyz()
Expand All @@ -167,8 +166,8 @@ def from_cartesian(cls, cart):
(d - r_spheroid),
(np.abs(xyz[2]) - np.abs(z_spheroid)),
)

return cls(lon, lat, height, copy=False)
lon = _compute_longitude(lon, cls._positive_longitude, cls._wrap_angle)
return cls(lon, lat.to(u.deg), height, copy=False)


@format_doc(geodetic_base_doc)
Expand Down
3 changes: 2 additions & 1 deletion astropy/coordinates/tests/test_representation.py
Expand Up @@ -1866,11 +1866,12 @@ def test_represent_as(self):

# make sure represent_as() passes through the differentials
for name in REPRESENTATION_CLASSES:
print(name)
if name == "radial":
# TODO: Converting a CartesianDifferential to a
# RadialDifferential fails, even on `main`
continue
elif name.endswith("geodetic"):
elif "geodetic" in name:
# TODO: Geodetic representations do not have differentials yet
continue
new_rep = rep1.represent_as(
Expand Down
2 changes: 2 additions & 0 deletions docs/changes/coordinates/14851.feature.rst
@@ -0,0 +1,2 @@
Add support for planetocentric latitudes, west positive longitudes and longitudes
spanning from 0 to 360 degrees, to the ``BaseGeodeticRepresentation'`.
4 changes: 2 additions & 2 deletions docs/whatsnew/6.0.rst
Expand Up @@ -44,8 +44,8 @@ bodies by subclassing `~astropy.coordinates.BaseGeodeticRepresentation` and defi
<CartesianRepresentation (x, y, z) in m
(2481112.60371134, 2554647.09482601, 5274064.55958489)>
>>> representation.represent_as(WGS84GeodeticRepresentation) # doctest: +FLOAT_CMP
<WGS84GeodeticRepresentation (lon, lat, height) in (rad, rad, m)
(0.79999959, 0.98000063, 370.01796023)>
<WGS84GeodeticRepresentation (lon, lat, height) in (deg, deg, m)
(45.8366, 56.14990022, 370.01796023)>

See :ref:`astropy-coordinates-create-geodetic` for more details.

Expand Down

0 comments on commit a95410d

Please sign in to comment.