예제 #1
0
def test_geodetic_geocentric(geodetic_lat, geocentric_lat):

    assert pm.geodetic2geocentric(geodetic_lat) == approx(geocentric_lat)
    assert pm.geodetic2geocentric(radians(geodetic_lat), deg=False) == approx(radians(geocentric_lat))

    assert pm.geocentric2geodetic(geocentric_lat) == approx(geodetic_lat)
    assert pm.geocentric2geodetic(radians(geocentric_lat), deg=False) == approx(radians(geodetic_lat))
예제 #2
0
def test_geodetic_alt_geocentric(geodetic_lat, alt_m, geocentric_lat):
    assert pm.geod2geoc(geodetic_lat, alt_m) == approx(geocentric_lat)

    r = pm.geocentric_radius(geodetic_lat)
    assert pm.geoc2geod(geocentric_lat, r) == approx(geodetic_lat)
    assert pm.geoc2geod(geocentric_lat, 1e5 + r) == approx(pm.geocentric2geodetic(geocentric_lat, 1e5 + alt_m))

    assert pm.geod2geoc(geodetic_lat, 1e5 + alt_m) == approx(pm.geodetic2geocentric(geodetic_lat, 1e5 + alt_m))
def test_badvals(lat):
    # geodetic_isometric is not included on purpose
    with pytest.raises(ValueError):
        pm.geodetic2geocentric(lat, 0)
    with pytest.raises(ValueError):
        pm.geocentric2geodetic(lat, 0)
    with pytest.raises(ValueError):
        pm.geodetic2conformal(lat)
    with pytest.raises(ValueError):
        pm.conformal2geodetic(lat)
    with pytest.raises(ValueError):
        pm.geodetic2rectifying(lat)
    with pytest.raises(ValueError):
        pm.rectifying2geodetic(lat)
    with pytest.raises(ValueError):
        pm.geodetic2authalic(lat)
    with pytest.raises(ValueError):
        pm.authalic2geodetic(lat)
    with pytest.raises(ValueError):
        pm.geodetic2parametric(lat)
    with pytest.raises(ValueError):
        pm.parametric2geodetic(lat)
def geo_carla2xyz_carla(lat, lon, alt):
    # transforms geodetic location from carla.GnssMeasurement to location in cartesian Carla map frame. However,
    # transformed location and ground truth deviate from each other (see above).

    # after this transformation of the latitude, GNSS projection and ego_vehicle.get_transform().location are "closer"
    lat = pm.geocentric2geodetic(lat, alt, pm.Ellipsoid('wgs84'), deg=True)

    x_enu, y_enu, z_enu = pm.geodetic2enu(lat,
                                          lon,
                                          alt,
                                          map_carla_origin_geo.latitude,
                                          map_carla_origin_geo.longitude,
                                          map_carla_origin_geo.altitude,
                                          pm.Ellipsoid('wgs84'),
                                          deg=True)

    # y-coordinate in Carla coordinate system is flipped (see https://github.com/carla-simulator/carla/issues/2737)
    return x_enu, -y_enu, z_enu
def test_numpy_geodetic_geocentric():
    pytest.importorskip("numpy")
    assert pm.geodetic2geocentric([45, 0], 0) == approx([44.80757678, 0])
    assert pm.geocentric2geodetic([44.80757678, 0], 0) == approx([45, 0])