Projet

Général

Profil

0001-misc-fix-normalize_geolocation-with-non-decimal-valu.patch

Lauréline Guérin, 26 novembre 2022 09:34

Télécharger (1,64 ko)

Voir les différences:

Subject: [PATCH] misc: fix normalize_geolocation with non decimal values
 (#71745)

 tests/test_misc.py | 2 ++
 wcs/qommon/misc.py | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)
tests/test_misc.py
427 427
    assert normalize_geolocation({'lat': 0.0, 'lon': -400.0}) == {'lat': 0.0, 'lon': -40.0}
428 428
    assert normalize_geolocation({'lat': math.nan, 'lon': -400.0}) is None
429 429
    assert normalize_geolocation({'lat': math.inf, 'lon': -400.0}) is None
430
    assert normalize_geolocation({'lat': 'foobar', 'lon': 0.0}) is None
431
    assert normalize_geolocation({'lat': 0.0, 'lon': 'foobar'}) is None
430 432

  
431 433

  
432 434
def test_dict_from_prefix():
wcs/qommon/misc.py
785 785
        diff = maxi - mini
786 786
        return ((x - mini) % diff + diff) % diff + mini
787 787

  
788
    lat = decimal.Decimal(lat_lon['lat'])
789
    lon = decimal.Decimal(lat_lon['lon'])
790 788
    try:
789
        lat = decimal.Decimal(lat_lon['lat'])
790
        lon = decimal.Decimal(lat_lon['lon'])
791 791
        lat = float(wrap(lat, decimal.Decimal('-90.0'), decimal.Decimal('90.0')))
792 792
        lon = float(wrap(lon, decimal.Decimal('-180.0'), decimal.Decimal('180.0')))
793 793
    except decimal.InvalidOperation:
794
-