# Path: lib/cartopy/tests/crs/helpers.py
# def check_proj_params(name, crs, other_args):
#     expected = other_args | {f'proj={name}', 'no_defs'}
#     proj_params = set(crs.proj4_init.lstrip('+').split(' +'))
#     assert expected == proj_params


from numpy.testing import assert_almost_equal
from .helpers import check_proj_params
import cartopy.crs as ccrs


class TestGeostationary:
    test_class = ccrs.Geostationary
    expected_proj_name = 'geos'

    def adjust_expected_params(self, expected):
        # Only for Geostationary do we expect the sweep parameter
        if self.expected_proj_name == 'geos':
            expected.add('sweep=y')

    def test_default(self):
        geos = self.test_class()
        other_args = {'ellps=WGS84', 'h=35785831', 'lat_0=0.0', 'lon_0=0.0',
                      'units=m', 'x_0=0', 'y_0=0'}
        self.adjust_expected_params(other_args)

        check_proj_params(self.expected_proj_name, geos, other_args)

        assert_almost_equal(geos.boundary.bounds,
                            (-5434177.81588539, -5412932.3767,
                             5434177.81588539, 5412932.3767),
                            decimal=4)

    def test_low_orbit(self):
        geos = self.test_class(satellite_height=700000)
        other_args = {'ellps=WGS84', 'h=700000', 'lat_0=0.0', 'lon_0=0.0',
                      'units=m', 'x_0=0', 'y_0=0'}
        self.adjust_expected_params(other_args)


# Path: lib/cartopy/tests/crs/helpers.py
# def check_proj_params(name, crs, other_args):
#     expected = other_args | {f'proj={name}', 'no_defs'}
#     proj_params = set(crs.proj4_init.lstrip('+').split(' +'))
#     assert expected == proj_params


# Path: lib/cartopy/tests/crs/test_geostationary.py
from numpy.testing import assert_almost_equal
from .helpers import check_proj_params
import cartopy.crs as ccrs



class TestGeostationary:
    test_class = ccrs.Geostationary
    expected_proj_name = 'geos'

    def adjust_expected_params(self, expected):
        # Only for Geostationary do we expect the sweep parameter
        if self.expected_proj_name == 'geos':
            expected.add('sweep=y')

    def test_default(self):
        geos = self.test_class()
        other_args = {'ellps=WGS84', 'h=35785831', 'lat_0=0.0', 'lon_0=0.0',
                      'units=m', 'x_0=0', 'y_0=0'}
        self.adjust_expected_params(other_args)

        check_proj_params(self.expected_proj_name, geos, other_args)

        assert_almost_equal(geos.boundary.bounds,
                            (-5434177.81588539, -5412932.3767,
                             5434177.81588539, 5412932.3767),
                            decimal=4)

    def test_low_orbit(self):
        geos = self.test_class(satellite_height=700000)
        other_args = {'ellps=WGS84', 'h=700000', 'lat_0=0.0', 'lon_0=0.0',
                      'units=m', 'x_0=0', 'y_0=0'}
        self.adjust_expected_params(other_args)


        check_proj_params(self.expected_proj_name, geos, other_args)