"""
Styles
======

The ``style`` parameter accepts a preset (``"classic"``, ``"modern"``)
or a dict of overrides. Below, the same basemap rendered with two
styles; both maps appear in the gallery.
"""

from mappyng import Map, BasemapLayer
from mappyng.data import load_france_regions, load_europe

europe = load_europe().to_crs(2154)
regions = load_france_regions().to_crs(2154)

bbox_metro = [90000, 6040000, 1280000, 7150000]
cartouches = {
    0: {"bbox": [-6890454, 1780151, -6799589, 1874186], "crs": 3857,
        "cartouche_title": "Guadeloupe", "cartouche_title_size": 6,
        "border_radius": 5},
    1: {"bbox": [-6826862, 1609607, -6759494, 1685367], "crs": 3857,
        "cartouche_title": "Martinique", "cartouche_title_size": 6,
        "border_radius": 5},
    2: {"bbox": [-6136680, 235261, -5707791, 671780], "crs": 3857,
        "cartouche_title": "French Guiana", "cartouche_title_size": 6,
        "border_radius": 5},
    3: {"bbox": [6136383, -2448160, 6226316, -2366992], "crs": 3857,
        "cartouche_title": "Reunion", "cartouche_title_size": 6,
        "border_radius": 5},
    4: {"bbox": [5006226, -1459183, 5050208, -1416184], "crs": 3857,
        "cartouche_title": "Mayotte", "cartouche_title_size": 6,
        "border_radius": 5},
}


def build(style, facecolor):
    m = Map(europe, bbox=bbox_metro, width=680, height=760, padding=20,
            style=style, facecolor=facecolor,
            cartouche_params=cartouches, cartouche_spacing=12)
    m.add(BasemapLayer())
    m.add_shadow(europe, {"query": "code_pays_iso3=='FRA'", "on_cartouches": True})
    return m


# Classic preset.
m_classic = build("classic", "#bcd2e8")
m_classic.title("Classic style")

# Targeted overrides on the classic base.
m_custom = build({"base": "classic", "title_color": "#1a1a2e",
                  "basemap_fill": "#f3ede2", "basemap_edge_color": "#b9a98f"},
                 "#e9e2d4")
m_custom.title("Custom style")
