%% The LaTeX package mercatormap - version 1.02 (2020/08/06)
%% mercatorsupplier.def: predefined map supplier list
%%
%% -------------------------------------------------------------------------------------------
%% Copyright (c) 2020 by Prof. Dr. Dr. Thomas F. Sturm <thomas dot sturm at unibw dot de>
%% -------------------------------------------------------------------------------------------
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%%
%% This work has the LPPL maintenance status `author-maintained'.
%%
%% This work consists of all files listed in README
%%

\NewDocumentCommand\mrcumlaut{m}{\"{#1}}

\cs_new:Npn \__mermap_new_supply_source:nn #1#2
  {
    \keys_define:nn { mermap/supply/_source }
      {
        #1 .meta:nn = {mermap/supply}{#2}
      }
  }

\NewDocumentCommand\mrcnewsupplysource {mm} {
  \__mermap_new_supply_source:nn {#1}{#2}
}

\__mermap_new_supply_source:nn { dummy }
  {
    url               = http://127.0.0.1/dummy/{z}/{x}/{y}.png,
    attribution       = {Dummy~tile~server},
    attribution~print = {Dummy~tile~server},
    basename          = tiles/dummy,
  }

\__mermap_new_supply_source:nn { opentopomap }
  {
    url = https://tile.opentopomap.org/{z}/{x}/{y}.png,
    attribution = {
      Kartendaten:~\textcopyright\nobreakspace\href{https://openstreetmap.org/copyright}{OpenStreetMap}
      \ Mitwirkende,~SRTM\nobreakspace\textbar\nobreakspace
      Kartendarstellung:~\textcopyright\nobreakspace\href{http://opentopomap.org/}{OpenTopoMap}
      \ (\href{https://creativecommons.org/licenses/by-sa/3.0/}{CC-BY-SA})
    },
    attribution~print = {
      Kartendaten:~\textcopyright\nobreakspace www.openstreetmap.org/copyright,
      \ SRTM\nobreakspace\textbar\nobreakspace
      Kartendarstellung:~\textcopyright\nobreakspace opentopomap.org~(CC-BY-SA)
    },
    basename = tiles/opentopomap,
  }

\keys_define:nn { mermap/supply }
  {
    __attribution_topplusopen .meta:nn = {mermap/supply} {
    attribution = {
      \textcopyright\nobreakspace\href{http://www.bkg.bund.de}{Bundesamt~f\mrcumlaut{u}r~Kartographie~und~Geod\mrcumlaut{a}sie}\nobreakspace\the\year,
      \ \href{http://sg.geodatenzentrum.de/web_public/Datenquellen_TopPlus_Open.pdf}{Datenquellen}
      },
    attribution~print = {
      \textcopyright\nobreakspace Bundesamt~f\mrcumlaut{u}r~Kartographie~und~Geod\mrcumlaut{a}sie\nobreakspace\the\year,
      \ Datenquellen:~\detokenize{http://sg.geodatenzentrum.de/web_public/Datenquellen_TopPlus_Open.pdf}
      }
    }
  }

\__mermap_new_supply_source:nn { topplusopen~web }
  {
    url = {https://sgx.geodatenzentrum.de/wmts_topplus_open/tile/1.0.0/web/default/WEBMERCATOR/{z}/{y}/{x}.png},
    __attribution_topplusopen,
    basename = tiles/tpo_web,
  }

\__mermap_new_supply_source:nn { topplusopen~web~grau }
  {
    url = {https://sgx.geodatenzentrum.de/wmts_topplus_open/tile/1.0.0/web_grau/default/WEBMERCATOR/{z}/{y}/{x}.png},
    __attribution_topplusopen,
    basename = tiles/tpo_web_grau,
  }

\cs_new:Npn \__mermap_new_supply_source_topplusopen:n #1
  {
    \keys_define:nn { mermap/supply/_source }
      {
        topplusopen~#1 .meta:nn = {mermap/supply}{
          url = {https://sgx.geodatenzentrum.de/wms_topplus_open?service=wms&version=1.3.0&request=GetMap&Layers=#1&STYLES=default&CRS=EPSG:3857&bbox={xmin},{ymin},{xmax},{ymax}&width={width}&height={height}&Format=image/png},
          __attribution_topplusopen,
          basename = tiles/tpo,
        },
        topplusopen~#1~grau .meta:nn = {mermap/supply}{
          url = {https://sgx.geodatenzentrum.de/wms_topplus_open?service=wms&version=1.3.0&request=GetMap&Layers=#1_grau&STYLES=default&CRS=EPSG:3857&bbox={xmin},{ymin},{xmax},{ymax}&width={width}&height={height}&Format=image/png},
          __attribution_topplusopen,
          basename = tiles/tpo,
        },
      }
  }
\__mermap_new_supply_source_topplusopen:n { p5 }
\__mermap_new_supply_source_topplusopen:n { p10 }
\__mermap_new_supply_source_topplusopen:n { p17.5 }
\__mermap_new_supply_source_topplusopen:n { p25 }
\__mermap_new_supply_source_topplusopen:n { p50 }
\__mermap_new_supply_source_topplusopen:n { p100 }
\__mermap_new_supply_source_topplusopen:n { p250 }

%% openrouteservice mapsurfer is DISCONTINUED after June 2020
%% Therefore, the following source is DEPRECATED and will be removed in future
\__mermap_new_supply_source:nn { openrouteservice~mapsurfer }
  {
    url~with~api~key = {https://api.openrouteservice.org/mapsurfer/{z}/{x}/{y}.png?api_key=}{openrouteservice}{},
    attribution = {
      Service~\textcopyright\nobreakspace\href{https://openrouteservice.org/}{openrouteservice.org}
      \nobreakspace\textbar\nobreakspace
      Map~data~\textcopyright\nobreakspace\href{https://openstreetmap.org/copyright}{OpenStreetMap}~contributors
    },
    attribution~print = {
      Service~\textcopyright\nobreakspace openrouteservice.org
      \nobreakspace\textbar\nobreakspace
      Map~data~\textcopyright\nobreakspace OpenStreetMap~contributors
    },
    basename = tiles/mapsurfer,
  }

\keys_define:nn { mermap/supply }
  {
    __attribution_stamen .meta:nn = {mermap/supply} {
    attribution = {
      Map~tiles~by~\href{http://stamen.com}{Stamen~Design},
      \ under~\href{http://creativecommons.org/licenses/by/3.0}{CC~BY~3.0}.
      \ Data~by~\href{http://openstreetmap.org}{OpenStreetMap},
      \ under~\href{http://www.openstreetmap.org/copyright}{ODbL}.
      },
    attribution~print = {
      Map~tiles~by~Stamen~Design~(stamen.com),
      \ under~CC~BY~3.0.
      \ Data~by~OpenStreetMap,
      \ under~ODbl~(www.openstreetmap.org/copyright).
      }
    }
  }
\__mermap_new_supply_source:nn { stamen~terrain }
  {
    url = {https://stamen-tiles-a.a.ssl.fastly.net/terrain/{z}/{x}/{y}.png},
    __attribution_stamen,
    basename = tiles/terrain,
  }
\__mermap_new_supply_source:nn { stamen~terrain-background }
  {
    url = {https://stamen-tiles-a.a.ssl.fastly.net/terrain-background/{z}/{x}/{y}.png},
    __attribution_stamen,
    basename = tiles/terrain-background,
  }
\__mermap_new_supply_source:nn { stamen~terrain-labels }
  {
    url = {https://stamen-tiles-a.a.ssl.fastly.net/terrain-labels/{z}/{x}/{y}.png},
    __attribution_stamen,
    basename = tiles/terrain-labels,
  }
\__mermap_new_supply_source:nn { stamen~terrain-lines }
  {
    url = {https://stamen-tiles-a.a.ssl.fastly.net/terrain-lines/{z}/{x}/{y}.png},
    __attribution_stamen,
    basename = tiles/terrain-lines,
  }
\__mermap_new_supply_source:nn { stamen~toner }
  {
    url = {https://stamen-tiles-a.a.ssl.fastly.net/toner/{z}/{x}/{y}.png},
    __attribution_stamen,
    basename = tiles/toner,
  }
\__mermap_new_supply_source:nn { stamen~toner-lite }
  {
    url = {https://stamen-tiles-a.a.ssl.fastly.net/toner-lite/{z}/{x}/{y}.png},
    __attribution_stamen,
    basename = tiles/toner-lite,
  }
\__mermap_new_supply_source:nn { stamen~toner-hybrid }
  {
    url = {https://stamen-tiles-a.a.ssl.fastly.net/toner-hybrid/{z}/{x}/{y}.png},
    __attribution_stamen,
    basename = tiles/toner-hybrid,
  }
\__mermap_new_supply_source:nn { stamen~toner-background }
  {
    url = {https://stamen-tiles-a.a.ssl.fastly.net/toner-background/{z}/{x}/{y}.png},
    __attribution_stamen,
    basename = tiles/toner-background,
  }
\__mermap_new_supply_source:nn { stamen~toner-labels }
  {
    url = {https://stamen-tiles-a.a.ssl.fastly.net/toner-labels/{z}/{x}/{y}.png},
    __attribution_stamen,
    basename = tiles/toner-labels,
  }
\__mermap_new_supply_source:nn { stamen~toner-lines }
  {
    url = {https://stamen-tiles-a.a.ssl.fastly.net/toner-lines/{z}/{x}/{y}.png},
    __attribution_stamen,
    basename = tiles/toner-lines,
  }
\__mermap_new_supply_source:nn { stamen~watercolor }
  {
    url = {https://stamen-tiles-a.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.png},
    attribution = {
      Map~tiles~by~\href{http://stamen.com}{Stamen~Design},
      \ under~\href{http://creativecommons.org/licenses/by/3.0}{CC~BY~3.0}.
      \ Data~by~\href{http://openstreetmap.org}{OpenStreetMap},
      \ under~\href{http://creativecommons.org/licenses/by-sa/3.0}{CC~BY~SA}.
      },
    attribution~print = {
      Map~tiles~by~Stamen~Design~(stamen.com),
      \ under~CC~BY~3.0.
      \ Data~by~OpenStreetMap,
      \ under~CC~BY~SA.
      },
    basename = tiles/watercolor,
  }

\keys_define:nn { mermap/supply }
  {
    __attribution_thunderforest .meta:nn = {mermap/supply} {
    attribution = {
        Maps~\textcopyright\nobreakspace\href{https://www.thunderforest.com/}{Thunderforest},
        \ Data~\textcopyright\nobreakspace\href{https://openstreetmap.org/copyright}{OpenStreetMap~contributors}
      },
    attribution~print = {
        Maps~\textcopyright\nobreakspace www.thunderforest.com,
        \ Data~\textcopyright\nobreakspace www.osm.org/copyright
      }
    }
  }
\__mermap_new_supply_source:nn { thunderforest~opencyclemap }
  {
    url~with~api~key = {https://tile.thunderforest.com/cycle/{z}/{x}/{y}.png?apikey=}{thunderforest}{},
    __attribution_thunderforest,
    basename = tiles/opencyclemap,
  }
\__mermap_new_supply_source:nn { thunderforest~transport }
  {
    url~with~api~key = {https://tile.thunderforest.com/transport/{z}/{x}/{y}.png?apikey=}{thunderforest}{},
    __attribution_thunderforest,
    basename = tiles/transport,
  }
\__mermap_new_supply_source:nn { thunderforest~landscape }
  {
    url~with~api~key = {https://tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey=}{thunderforest}{},
    __attribution_thunderforest,
    basename = tiles/landscape,
  }
\__mermap_new_supply_source:nn { thunderforest~outdoors }
  {
    url~with~api~key = {https://tile.thunderforest.com/outdoors/{z}/{x}/{y}.png?apikey=}{thunderforest}{},
    __attribution_thunderforest,
    basename = tiles/outdoors,
  }
\__mermap_new_supply_source:nn { thunderforest~transport-dark }
  {
    url~with~api~key = {https://tile.thunderforest.com/transport-dark/{z}/{x}/{y}.png?apikey=}{thunderforest}{},
    __attribution_thunderforest,
    basename = tiles/transport-dark,
  }
\__mermap_new_supply_source:nn { thunderforest~spinal-map }
  {
    url~with~api~key = {https://tile.thunderforest.com/spinal-map/{z}/{x}/{y}.png?apikey=}{thunderforest}{},
    __attribution_thunderforest,
    basename = tiles/spinal-map,
  }
\__mermap_new_supply_source:nn { thunderforest~pioneer }
  {
    url~with~api~key = {https://tile.thunderforest.com/pioneer/{z}/{x}/{y}.png?apikey=}{thunderforest}{},
    __attribution_thunderforest,
    basename = tiles/pioneer,
  }
\__mermap_new_supply_source:nn { thunderforest~mobile-atlas }
  {
    url~with~api~key = {https://tile.thunderforest.com/mobile-atlas/{z}/{x}/{y}.png?apikey=}{thunderforest}{},
    __attribution_thunderforest,
    basename = tiles/mobile-atlas,
  }
\__mermap_new_supply_source:nn { thunderforest~neighbourhood }
  {
    url~with~api~key = {https://tile.thunderforest.com/neighbourhood/{z}/{x}/{y}.png?apikey=}{thunderforest}{},
    __attribution_thunderforest,
    basename = tiles/neighbourhood,
  }

