%%
%% This is file `getmap.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% getmap.dtx  (with options: `package')
%% 
%% Copyright (C) 2014,2016,2018 by:
%% Josef Kleber
%% <josef.kleber@gmx.de>
%% 
%% This file 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
%% 2003/12/01 or later.
%% 
%% This work has the LPPL maintenance status "author-maintained".
%% 
%% The Current Maintainer of this work is Josef Kleber.
%% 
%% This work consists of all files listed in manifest.txt.
%% 
\NeedsTeXFormat{LaTeX2e}%
\ProvidesPackage{getmap}[2018/07/18 v1.10 getmap.sty - Josef Kleber (C) 2014,2016,2018]%
\RequirePackage{xkeyval}%
\RequirePackage{stringenc}%
\RequirePackage{ifthen}%
\RequirePackage{shellesc}%
\RequirePackage{ifxetex}%
\ifxetex%
  \def\StringEncodingConvert#1#2#3#4%
  {%
    \def#1{#2}%
  }%
\fi%
\ifluatex%
  \def\StringEncodingConvert#1#2#3#4%
  {%
    \def#1{#2}%
  }%
\fi%
\newcommand*\GM@JK@define@key[4]%
{%
  \expandafter\gdef\csname#1@#3\endcsname{#4}%
  \define@key{#2.sty}{#3}[#4]%
  {%
    \expandafter\gdef\csname#1@#3\endcsname{##1}%
  }%
  \define@key{#2}{#3}%
  {%
    \expandafter\def\csname#1@#3\endcsname{##1}%
  }%
}%
\newcommand*\GM@JK@define@key@detok[4]%
{%
  \expandafter\gdef\csname#1@#3\endcsname{#4}%
  \define@key{#2.sty}{#3}[#4]%
  {%
    \expandafter\gdef\csname#1@#3\endcsname{\detokenize{##1}}%
  }%
  \define@key{#2}{#3}%
  {%
    \expandafter\def\csname#1@#3\endcsname{\detokenize{##1}}%
  }%
}%
\GM@JK@define@key{GM@JK}{getmap}{mode}{osm}%
\GM@JK@define@key{GM@JK}{getmap}{key}{}%
\GM@JK@define@key{GM@JK}{getmap}{xsize}{600}%
\GM@JK@define@key{GM@JK}{getmap}{ysize}{400}%
\GM@JK@define@key{GM@JK}{getmap}{scale}{3385}%
\GM@JK@define@key{GM@JK}{getmap}{zoom}{}%
\GM@JK@define@key{GM@JK}{getmap}{type}{map}%
\GM@JK@define@key{GM@JK}{getmap}{imagetype}{png}%
\GM@JK@define@key{GM@JK}{getmap}{color}{yellow_1}%
\GM@JK@define@key{GM@JK}{getmap}{number}{1}%
\GM@JK@define@key{GM@JK}{getmap}{heading}{0}%
\GM@JK@define@key{GM@JK}{getmap}{fov}{90}%
\GM@JK@define@key{GM@JK}{getmap}{pitch}{0}%
\GM@JK@define@key{GM@JK}{getmap}{language}{en}%
\GM@JK@define@key@detok{GM@JK}{getmap}{markers}{}%
\GM@JK@define@key@detok{GM@JK}{getmap}{path}{}%
\GM@JK@define@key@detok{GM@JK}{getmap}{visible}{}%
\GM@JK@define@key{GM@JK}{getmap}{pathfile}{}%
\GM@JK@define@key{GM@JK}{getmap}{file}{getmap}%
\GM@JK@define@key{GM@JK}{getmap}{inputencoding}{}%
\GM@JK@define@key{GM@JK}{getmap}{overwrite}{true}%
\gdef\GM@JK@overwrite{false}%
\gdef\GM@JK@key{}%
\IfFileExists{getmap.cfg}%
{%
  \input{getmap.cfg}%
}%
{%
  \gdef\GM@JK@key{Fmjtd|luur20u22d,75=o5-9aylh6}%
}%
\@ifpackageloaded{inputenc}%
{%
  \gdef\GM@JK@inputencoding{\inputencodingname}%
}%
{%
  \gdef\GM@JK@inputencoding{utf8}%
}%
\newif\ifGM@JK@writexviii\GM@JK@writexviiifalse%
\ExecuteOptionsX{mode,xsize,ysize,scale,zoom,type,imagetype,color,number,file,heading,fov,pitch,language}%
\ProcessOptionsX\relax%
\ifthenelse{\equal{\GM@JK@mode}{gm}}%
{%
  \gdef\GM@JK@scale{1}%
  \gdef\GM@JK@zoom{17}%
  \gdef\GM@JK@type{roadmap}%
  \gdef\GM@JK@color{blue}%
}%
{}%
\ltx@IfUndefined{pdf@shellescape}%
{%
  \PackageInfo{getmap}{\pdf@shellescape is undefined}%
  \PackageInfo{getmap}{can not test if \write18 is available}%
  \GM@JK@writexviiitrue%
}%
{%
  \PackageInfo{getmap}{\pdf@shellescape is available}%
  \ifnum\pdf@shellescape=1\relax%
    \PackageInfo{getmap}{\write18 enabled}%
    \GM@JK@writexviiitrue%
  \else%
    \GM@JK@writexviiifalse%
  \fi%
}%
\newcommand*\GM@JK@shellescape%
{%
  \ifGM@JK@writexviii\relax%
    \ifthenelse{\equal{\GM@JK@mode}{osm}}%
    {%
      \ifluatex\directlua{os.setlocale('','ctype')}\fi%
      \ShellEscape{getmapdl \space-l\space "\GM@JK@location@string"%
                            \space-m\space osm%
                            \space-k\space "\GM@JK@key@string"%
                            \space-x\space \GM@JK@xsize%
                            \space-y\space \GM@JK@ysize%
                            \space-z\space "\GM@JK@zoom"%
                            \space-s\space \GM@JK@scale%
                            \space-t\space \GM@JK@type%
                            \space-i\space \GM@JK@imagetype%
                            \space-c\space "\GM@JK@color"%
                            \space-n\space \GM@JK@number%
                            \space-o\space \GM@JK@file}%
    }%
    {%
      \ifthenelse{\equal{\GM@JK@mode}{gm}}%
      {%
        \ifluatex\directlua{os.setlocale('','ctype')}\fi%
        \ShellEscape{getmapdl \space-l\space "\GM@JK@location@string"%
                              \space-m\space gm%
                              \space-x\space \GM@JK@xsize%
                              \space-y\space \GM@JK@ysize%
                              \space-z\space \GM@JK@zoom%
                              \space-s\space \GM@JK@scale%
                              \space-t\space \GM@JK@type%
                              \space-i\space \GM@JK@imagetype%
                              \space-c\space "\GM@JK@color"%
                              \space-n\space \GM@JK@number%
                              \space-L\space "\GM@JK@language"%
                              \space-M\space "\GM@JK@markers@string"%
                              \space-C\space "\GM@JK@location@string"%
                              \space-P\space "\GM@JK@path@string"%
                              \space-p\space "\GM@JK@pathfile"%
                              \space-V\space "\GM@JK@visible@string"%
                              \space-o\space \GM@JK@file}%
      }%
      {%
        \ifthenelse{\equal{\GM@JK@mode}{gsv}}%
        {%
          \ifluatex\directlua{os.setlocale('','ctype')}\fi%
          \ShellEscape{getmapdl \space-l\space "\GM@JK@location@string"%
                                \space-m\space gsv%
                                \space-x\space \GM@JK@xsize%
                                \space-y\space \GM@JK@ysize%
                                \space-H\space \GM@JK@heading%
                                \space-F\space \GM@JK@fov%
                                \space-T\space \GM@JK@pitch%
                                \space-o\space \GM@JK@file}%
        }%
        {%
          \PackageError{getmap}{invalid mode}{invalid mode! Use osm, gm or gsv!}%
        }%
      }%
    }%
  \else%
    \PackageError{getmap}{\write18 disabled}%
                         {\write18 disabled\MessageBreak%
                          Use -shell-escape (TeXLive)\MessageBreak%
                          or\space\space--enable-write18 (MiKTeX)}%
  \fi%
}%
\newcommand*\getmap[2][]%
{%
  \begingroup%
    \setkeys{getmap}{#1}%
    \ifthenelse{\equal{\GM@JK@mode}{gm}}%
    {%
      \def\GM@JK@scale{1}%
      \def\GM@JK@zoom{17}%
      \def\GM@JK@type{roadmap}%
      \def\GM@JK@color{blue}%
    }%
    {}%
    \ifthenelse{\equal{\GM@JK@mode}{osm}}%
    {%
      \def\GM@JK@scale{3385}%
      \def\GM@JK@zoom{}%
      \def\GM@JK@type{map}%
      \def\GM@JK@color{yellow_1}%
    }%
    {}%
    \setkeys{getmap}{#1}%
    \ifthenelse{\equal{\GM@JK@mode}{gsv}}%
    {\def\GM@JK@imagetype{jpg}}{}%
    \PackageInfo{getmap}{using \GM@JK@inputencoding\space encoding}%
    \def\GM@JK@location{#2}%
    \StringEncodingConvert%
      {\GM@JK@location@string}%
      {\detokenize\expandafter{\GM@JK@location}}%
      {\GM@JK@inputencoding}{utf-8}%
    \StringEncodingSuccessFailure%
    {%
      %success
    }%
    {% failure
      \errmessage{Converting to UTF-8 failed}%
    }%
    \StringEncodingConvert%
      {\GM@JK@key@string}%
      {\detokenize\expandafter{\GM@JK@key}}%
      {\GM@JK@inputencoding}{utf-8}%
    \StringEncodingSuccessFailure%
    {%
      %success
    }%
    {% failure
      \errmessage{Converting to UTF-8 failed}%
    }%
    \StringEncodingConvert%
      {\GM@JK@markers@string}%
      {\GM@JK@markers}%
      {\GM@JK@inputencoding}{utf-8}%
    \StringEncodingSuccessFailure%
    {%
      %success
    }%
    {% failure
      \errmessage{Converting to UTF-8 failed}%
    }%
    \StringEncodingConvert%
      {\GM@JK@path@string}%
      {\GM@JK@path}%
      {\GM@JK@inputencoding}{utf-8}%
    \StringEncodingSuccessFailure%
    {%
      %success
    }%
    {% failure
      \errmessage{Converting to UTF-8 failed}%
    }%
    \StringEncodingConvert%
      {\GM@JK@visible@string}%
      {\GM@JK@visible}%
      {\GM@JK@inputencoding}{utf-8}%
    \StringEncodingSuccessFailure%
    {%
      %success
    }%
    {% failure
      \errmessage{Converting to UTF-8 failed}%
    }%
    \ifthenelse{\equal{\GM@JK@overwrite}{true}}%
    {%
      \GM@JK@shellescape%
    }%
    {%
      \IfFileExists{\GM@JK@file.\GM@JK@imagetype}%
      {%
        \PackageInfo{getmap}{overwrite=false; (\GM@JK@file.\GM@JK@imagetype)%
                             using existing file!}%
      }%
      {%
        \PackageInfo{getmap}{overwrite=false; (\GM@JK@file.\GM@JK@imagetype)%
                             file does not exist! downloading ...}%
        \GM@JK@shellescape%
      }%
    }%
  \endgroup%
}%
\endinput
%%
%% End of file `getmap.sty'.
