def _build_worldpop_url(country, year, un_adj=True, constrained=True):
    """Build download URL.

    Parameters
    ----------
    country : str
        Country ISO A3 code.
    year : int, optional
        Year of interest (2000--2020).
    un_adj : bool, optional
        Use UN adjusted population counts.
    constrained : bool, optional
        Constrained or unconstrained dataset ?

    Returns
    -------
    url : str
        Download URL.
    """
    if constrained:
        base_url = (
            "https://data.worldpop.org/GIS/Population/Global_2000_2020_Constrained"
        )
        return (
            f"{base_url}/{year}/maxar_v1/{country.upper()}/"
            f"{country.lower()}_ppp_{year}{'_UNadj' if un_adj else ''}_constrained.tif"
        )
    else:
        base_url = "https://data.worldpop.org/GIS/Population/Global_2000_2020"
        return (
            f"{base_url}/{year}/{country.upper()}/"
            f"{country.lower()}_ppp_{year}{'_UNadj' if un_adj else ''}.tif"
        )