def _autodetect_resolution()

in python-package/lets_plot/geo_data/geocodes.py [0:0]


def _autodetect_resolution(level: LevelKind, count: int) -> int:
    if level == LevelKind.country:
        if count < 3:
            return Resolution.world_high.value
        else:
            return Resolution.world_low.value

    if level == LevelKind.state:
        if count < 3:
            return Resolution.state_low.value
        if count < 10:
            return Resolution.country_low.value
        else:
            return Resolution.world_medium.value

    if level == LevelKind.county:
        if count < 5:
            return Resolution.county_low.value
        elif count < 20:
            return Resolution.state_medium.value
        else:
            return Resolution.world_high.value

    if level == LevelKind.city:
        if count < 5:
            return Resolution.city_low.value
        elif count < 50:
            return Resolution.country_low.value
        else:
            return Resolution.world_high.value