summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/getmap/getmap.dtx
blob: ecd02887aded77642917cd02d00a8ffe3b047cf9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
% \iffalse meta-comment
% !TEX program  = pdfLaTeX
%<*internal>
\iffalse
%</internal>
%<*readme>
The goal of this package is the simplest possible provision of
OpenStreetMap maps. In the simplest case, the specification of
the address is sufficient. The package loads the map using the
\write18 feature, which you must activate to use this package.
The image will be downloaded by an external Lua script. You can
use this script, as well as the attached bash script also from
the command line.

License: LPPL

Changes in v1.1:

- Bugfix: problem in URL with \usepackage[utf8]{inputenc}
  
  reported by: Ulrike Fischer

- added makefile and install.bat
  for easy manual installation


  INSTALL
===========

First of all, install the package with the package manager of
your TeX distribution, if possible.

Manual installation:

download getmap.dtx, osmimage.png and
makefile (Linux) or install.bat (Windows)

* Linux

  simply run  make  to extract the files and to create the
  documentation. Run  sudo make install  to copy the files 
  in $TEXMFLOCAL
  
  Moreover, there are the following usefull make targets:
  
  uninstall  deletes the package in $TEXMFOCAL  
  package    only extracts the files  
  clean      cleans all aux files  
  cleanall   cleans all files except the downloaded files
             and getmap.pdf


* Windows

  In MiKTeX scripts like osmimage.lua must be registered.
  This can not be done manually! Please use the package
  manager to install getmap.
  
  For TeXLive simply run install.bat! It assumes that you
  use a standard installation of TeXLive2014. Otherwise you 
  must adjust the variables in the first lines of install.bat!
  
%</readme>
%<*bibfile>
@misc{bib:devmapquest,
 author               = {{MapQuest, Inc}},
 note                 = {\href{http://developer.mapquest.com}{http://developer.mapquest.com}},
 title                = {Introducing the Data Manager API Web Service},
 year                 = {2014},
 }

@misc{bib:mapquestopen,
 author               = {{MapQuest, Inc}},
 note                 = {\href{http://open.mapquestapi.com/}{http://open.mapquestapi.com/}},
 title                = {MapQuest Open Platform Web Services},
 year                 = {2014},
 }

@misc{bib:mapquestopenzoomscale,
 author               = {{MapQuest, Inc}},
 note                 = {\href{http://open.mapquestapi.com/staticmap/zoomToScale.html}{http://open.mapquestapi.com/staticmap/zoomToScale.html}},
 title                = {Zoom To Scale Mapping},
 year                 = {2014},
 }

@misc{bib:mapquestopencolors,
 author               = {{MapQuest, Inc}},
 note                 = {\href{http://open.mapquestapi.com/staticmap/icons.html}{http://open.mapquestapi.com/staticmap/icons.html}},
 title                = {Static Map Service: Standard Icons},
 year                 = {2014},
 }

%</bibfile>
%<*bashfile>
#!/bin/bash
#
# osmimage [options]
#
# downloads an OpenStreetMap map specified by [options]
# by using http://developer.mapquest.com/ web service
#
# License: LPPL
#
pversion()
{
  echo "`basename $0` $VERSION"
  echo "(C) Josef Kleber   License: LPPL"
  exit 0;
}
#
function phelp()
{
  echo -e \
    "\n  `basename $0` [options]\n\n"\
    " downloads an OpenStreetMap map specified by [options]\n"\
    " by using http://developer.mapquest.com/ web service\n\n"\
    " Options:\n\n"\
    " -k  key registered at http://developer.mapquest.com/\n"\
    "     default (Example key from web site)!\n"\
    "     Please register and use your own key!\n\n"\
    " -l  specify a location\n"\
    "     e.g. 'Bergheimer Straße 110A, 69115 Heidelberg, Germany'\n\n"\
    " -x  specify a xsize (800)\n\n"\
    " -y  specify a ysize (400)\n\n"\
    " -S  short form to specify a size, e.g. 800,400\n\n"\
    " -s  specify a scale factor in the range 1692-221871572 (3385 = -z 17)\n"\
    "     see: http://open.mapquestapi.com/staticmap/zoomToScale.html\n\n"\
    " -z  specify a zoom in the range 1-18 (zoom overrides scale!)\n\n"\
    " -t  specify map type {map|sat|hyb} (map)\n\n"\
    " -i  specify image type {jpeg|jpg|gif|png} (png)\n\n"\
    " -c  specify icon color (yellow_1)\n"\
    "     see: http://open.mapquestapi.com/staticmap/icons.html\n\n"\
    " -n  specify the icon number (1)\n\n"\
    " -o  specify output basename without file extension (osmimage.IMAGETYPE)\n\n"\
    " -q  quiet; no output!\n\n"\
    " -v  prints version information\n\n"\
    " -h  prints help information\n\n"
  pversion
}
#
osmimage_error()
{
  local exitcode="$1"
  local errortext="$2"
  echo "Error ($exitcode): $errortext" >&2
  exit $exitcode
}
#
osmimage_warning()
{
  local warningtext="$1"
  echo -e "WARNING: $warningtext\n" >&2
}
#
check_prog()
{
  local prog="$1"
  hash $prog 2>/dev/null || osmimage_error 1 "$prog not installed! Aborting."
}
#
check_number()
{
  local var="$1"
  local varname="$2"
  local number='^[0-9]+$'
  if ! [[ $var =~ $number ]]
  then
     osmimage_error 2 "$varname can't be $var! Not a number!"
  fi
}
#
check_range()
{
  local var="$1"
  local min="$2"
  local max="$3"
  local exitcode="$4"
  local varname="$5"
  check_number $var $varname
  if [ $var -lt $min ]
  then
    osmimage_error $exitcode "$varname = $var; must be in the range of $min-$max"
  fi
  if [ $var -gt $max ]
  then
    osmimage_error $exitcode "$varname = $var; must be in the range of $min-$max"

  fi
}
#
check_prog wget
#
URL="http://open.mapquestapi.com/staticmap/v4/getplacemap"
KEY=""
LOCATION=""
XSIZE=""
YSIZE=""
SCALE=""
ZOOM=""
TYPE=""
IMAGETYPE=""
COLOR=""
NUMBER=""
OFILE="osmimage"
QUIET="false"
VERSION="v1.2 (23/05/2014)"
#
while getopts "k:l:x:y:S:s:z:t:i:c:n:o:qvh" flag
do
  case "$flag" in
    k) KEY="$OPTARG";;
    l) LOCATION="$OPTARG";;
    x) XSIZE="$OPTARG";;
    y) YSIZE="$OPTARG";;
    S) SIZE="$OPTARG";;
    s) SCALE="$OPTARG";;
    z) ZOOM="$OPTARG";;
    t) TYPE="$OPTARG";;
    i) IMAGETYPE="$OPTARG";;
    c) COLOR="$OPTARG";;
    n) NUMBER="$OPTARG";;
    o) OFILE="$OPTARG";;
    q) QUIET="true";;
    v) pversion;;
    h) phelp;;
  esac
done
#
if [ "$QUIET" = "true" ]
then
  exec 1>/dev/null
  exec 2>/dev/null
fi
#
if [ -z $KEY ]
then
  KEY="Kmjtd%7Cluu7n162n1%2C22%3Do5-h61wh"
  osmimage_warning "KEY not specified; using mapquest example key as default!"
fi
#
if [ -z $LOCATION ]
then
  LOCATION="Bergheimer Straße 110A, 69115 Heidelberg, Germany"
  osmimage_warning "LOCATION not specified; using Dante e.V. Office as default!"
fi
#
if [ -z $XSIZE ]
then
  XSIZE=800
  osmimage_warning "XSIZE not specified; using XSIZE=800 as default!"
fi
check_range $XSIZE 1 3840 11 XSIZE
#
if [ -z $YSIZE ]
then
  YSIZE=400
  osmimage_warning "YSIZE not specified; using YSIZE=400 as default!"
fi
check_range $YSIZE 1 3840 12 YSIZE
#
if [ -z $SIZE ]
then
  SIZE="$XSIZE,$YSIZE"
fi
#
if [ -z $SCALE ]
then
  if [ -z $ZOOM ]
  then
    SCALE=3385
    osmimage_warning "SCALE not specified, using SCALE=3385 as default!"
  fi
else
  check_range $SCALE 1692 221871572 13 SCALE
fi
#
if [ -z $TYPE ]
then
  TYPE="map"
  osmimage_warning "TYPE not specified; using map as default!"
fi
#
if [ -z $IMAGETYPE ]
then
  IMAGETYPE="png"
  osmimage_warning "IMAGETYPE not specified; using png as default!"
fi
#
if [ -z $COLOR ]
then
  COLOR="yellow_1"
  osmimage_warning "COLOR not specified; using yellow_1 as default!"
fi
if [ -z $NUMBER ]
then
  NUMBER=1
  osmimage_warning "NUMBER not specified; using 1 as default!"
fi
check_number $NUMBER NUMBER
#
ULOCATION="&location=$LOCATION"
USIZE="&size=$SIZE"
if [ -z $ZOOM ]
then
  USCALEZOOM="&scale=$SCALE"
else
  check_range $ZOOM 1 18 14 ZOOM
  USCALEZOOM="&zoom=$ZOOM"
fi
UTYPE="&type=$TYPE"
UIMAGETYPE="&imagetype=$IMAGETYPE"
USHOWICON="&showicon=${COLOR}-${NUMBER}"
UOFILE="${OFILE}.${IMAGETYPE}"
#
IMGURL="${URL}?key=${KEY}${ULOCATION}${USIZE}${USCALEZOOM}${UTYPE}${UIMAGETYPE}${USHOWICON}"
#
wget "$IMGURL" -O "$UOFILE"
exit 0
%</bashfile>
%<*luafile>
#!/usr/bin/env texlua
--
-- osmimage [options]
--
-- downloads an OpenStreetMap map specified by [options]
-- by using http://developer.mapquest.com/ web service
--
-- recoding the osmimage bash script to lua was mostly done
-- by Norbert Preining with valuable inputs from
-- Taco Hoekwater, Reinhard Kotucha and Heiko Oberdiek
-- Message-ID: <537A098C.8000902@gmx.de> ff
--
-- License: LPPL
--
local http = require("socket.http");
local ltn12 = require("ltn12")
local url = require("socket.url")

local URL = "http://open.mapquestapi.com/staticmap/v4/getplacemap"
local KEY = ""
local LOCATION = ""
local XSIZE = ""
local YSIZE = ""
local SIZE = ""
local SCALE = ""
local ZOOM = ""
local TYPE = ""
local IMAGETYPE = ""
local COLOR = ""
local NUMBER = ""
local OFILE = "osmimage"
local QUIET = "false"
local VERSION = "v1.2 (23/05/2014)"


function pversion()
  print("osmimage.lua " .. VERSION)
  print("(C) Josef Kleber   License: LPPL")
  os.exit(0)
end

function phelp()
  print([[
osmimage.lua [options]

 downloads an OpenStreetMap map specified by [options]
 by using http://developer.mapquest.com/ web service

 Options:

 -k  key registered at http://developer.mapquest.com/
     default (Example key from web site)!
     Please register and use your own key!

 -l  specify a location
     e.g. 'Bergheimer Straße 110A, 69115 Heidelberg, Germany'

 -x  specify a xsize (800)

 -y  specify a ysize (400)

 -S  short form to specify a size, e.g. 800,400

 -s  specify a scale factor in the range 1692-221871572 (3385 = -z 17)
     see: http://open.mapquestapi.com/staticmap/zoomToScale.html

 -z  specify a zoom in the range 1-18 (zoom overrides scale!)

 -t  specify map type {map|sat|hyb} (map)

 -i  specify image type {jpeg|jpg|gif|png} (png)

 -c  specify icon color (yellow_1)
     see: http://open.mapquestapi.com/staticmap/icons.html

 -n  specify the icon number (1)

 -o  specify output basename without file extension (osmimage.IMAGETYPE)

 -q  quiet; no output!

 -v  prints version information

 -h  prints help information

]])
  pversion()
end

function osmimage_error(exitcode, errortext)
  io.stderr:write ("Error (" .. exitcode .. "): " .. errortext .. "\n")
  os.exit(exitcode)
end

function osmimage_warning(warningtext)
  io.stderr:write("WARNING: " .. warningtext .. "\n")
end


function check_number(var, varname)
  local number='^[0-9]+$'
  if not(string.match(var, '^[0-9]+$')) then
    osmimage_error(2, varname .. " can't be " .. var .. "! Not a number!")
  end
end

function check_range(var,min,max,exitcode,varname)
  check_number(var,varname)
  if (tonumber(var) < tonumber(min) or tonumber(var) > tonumber(max)) then
    osmimage_error(exitcode, varname .. " = " .. var .. "; must be in the range of " .. min .. "-" .. max)
  end
end

do
  local newarg = {}
  local i, limit = 1, #arg
  while (i <= limit) do
    if arg[i] == "-k" then
      KEY = arg[i+1]
      i = i + 1
    elseif arg[i] == "-l" then
      LOCATION = arg[i+1]
      i = i + 1
    elseif arg[i] == "-x" then
      XSIZE = arg[i+1]
      i = i + 1
    elseif arg[i] == "-y" then
      YSIZE = arg[i+1]
      i = i + 1
    elseif arg[i] == "-S" then
      SIZE = arg[i+1]
      i = i + 1
    elseif arg[i] == "-s" then
      SCALE = arg[i+1]
      i = i + 1
    elseif arg[i] == "-z" then
      ZOOM = arg[i+1]
      i = i + 1
    elseif arg[i] == "-t" then
      TYPE = arg[i+1]
      i = i + 1
    elseif arg[i] == "-i" then
      IMAGETYPE = arg[i+1]
      i = i + 1
    elseif arg[i] == "-c" then
      COLOR = arg[i+1]
      i = i + 1
    elseif arg[i] == "-n" then
      NUMBER = arg[i+1]
      i = i + 1
    elseif arg[i] == "-o" then
      OFILE = arg[i+1]
      i = i + 1
    elseif arg[i] == "-q" then
      QUIET = 1
    elseif arg[i] == "-v" then
      pversion()
    elseif arg[i] == "-h" then
      phelp()
    else
      newarg[#newarg+1] = arg[i]
    end
    i = i + 1
  end
  arg = newarg
end


if QUIET == 1 then
  osmimage_warning("-q option currently not supported!")
end

if KEY == "" then
  -- KEY="Kmjtd%7Cluu7n162n1%2C22%3Do5-h61wh"
  KEY="Kmjtd|luu7n162n1,22=o5-h61wh"
  osmimage_warning("KEY not specified; using mapquest example key as default!")
end

if LOCATION == "" then
  LOCATION = "Bergheimer Straße 110A, 69115 Heidelberg, Germany"
  osmimage_warning("LOCATION not specified; using Dante e.V. Office as default!")
end

if XSIZE == "" then
  XSIZE=800
  osmimage_warning("XSIZE not specified; using XSIZE=800 as default!")
end

check_range(XSIZE,1,3840,11,"XSIZE")

if YSIZE == "" then
  YSIZE=400
  osmimage_warning("YSIZE not specified; using YSIZE=400 as default!")
end
check_range(YSIZE,1,3840,12,"YSIZE")

if SIZE == "" then
  SIZE = XSIZE .. "," .. YSIZE
end

if SCALE == "" then
  if ZOOM == "" then
    SCALE=3385
    osmimage_warning("SCALE not specified, using SCALE=3385 as default!")
  end
else
  check_range(SCALE,1692,221871572,13,"SCALE")
end

if TYPE == "" then
  TYPE = "map"
  osmimage_warning("TYPE not specified; using map as default!")
end

if IMAGETYPE == "" then
  IMAGETYPE="png"
  osmimage_warning("IMAGETYPE not specified; using png as default!")
end

if COLOR == "" then
  COLOR="yellow_1"
  osmimage_warning("COLOR not specified; using yellow_1 as default!")
end

if NUMBER == "" then
  NUMBER=1
  osmimage_warning("NUMBER not specified; using 1 as default!")
end
check_number(NUMBER,"NUMBER")

local UKEY = "?key=" .. url.escape(KEY)
local ULOCATION = "&location=" .. url.escape(LOCATION)
local USIZE = "&size=" .. url.escape(SIZE)
local USCALEZOOM
if ZOOM == "" then
  USCALEZOOM = "&scale=" .. url.escape(SCALE)
else
  check_range(ZOOM,1,18,14,"ZOOM")
  USCALEZOOM = "&zoom=" .. url.escape(ZOOM)
end
local UTYPE = "&type=" .. url.escape(TYPE)
local UIMAGETYPE = "&imagetype=" .. url.escape(IMAGETYPE)
local USHOWICON = "&showicon=" .. url.escape(COLOR) .. "-" .. url.escape(NUMBER)
local UOFILE = OFILE .. "." .. IMAGETYPE

local IMGURL = URL .. UKEY .. ULOCATION .. USIZE .. USCALEZOOM .. UTYPE .. UIMAGETYPE .. USHOWICON

local ret, msg
local ofile
ofile, msg = io.open(UOFILE, "wb")
if not ofile then
  osmimage_error(21, msg)
end
print("\n\nosmimage.lua:")
print("url = " .. IMGURL)
print("output = " .. UOFILE)
ret, msg = http.request{
  url = IMGURL,
  sink = ltn12.sink.file(ofile)
}
if not ret then
  osmimage_error(22, msg)
end

%</luafile>
%<*manifest>
This work consists of the following files:

getmap.pdf
getmap.dtx
osmimage.png
README
makefile
install.bat
%</manifest>
%<*internal>
\fi
\def\nameofplainTeX{plain}
\ifx\fmtname\nameofplainTeX\else
  \expandafter\begingroup
\fi
%</internal>
%<*install>
\input docstrip.tex
\keepsilent
\askforoverwritefalse
\preamble

Copyright (C) 2014 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.

\endpreamble

\usedir{tex/latex/getmap}
\generate{
  \file{\jobname.sty}{\from{\jobname.dtx}{package}}
}
%</install>
%<install>\endbatchfile
%<*internal>
\usedir{source/latex/getmap}
\generate{
  \file{\jobname.ins}{\from{\jobname.dtx}{install}}
}
\nopreamble\nopostamble
\usedir{doc/latex/getmap}
\generate{
  \file{README.txt}{\from{\jobname.dtx}{readme}}
}
\generate{
  \file{manifest.txt}{\from{\jobname.dtx}{manifest}}
}
\generate{
  \file{\jobname.bib}{\from{\jobname.dtx}{bibfile}}
}
\generate{
  \file{osmimage.sh}{\from{\jobname.dtx}{bashfile}}
}
\generate{
  \file{osmimage.lua}{\from{\jobname.dtx}{luafile}}
}
\ifx\fmtname\nameofplainTeX
  \expandafter\endbatchfile
\else
  \expandafter\endgroup
\fi
%</internal>
%<*driver>
\documentclass[a4paper]{ltxdoc}%
\usepackage[english]{babel}%
\usepackage[utf8]{inputenc}%
\usepackage[T1]{fontenc}%
\usepackage{textcomp}%
\usepackage{lmodern}%
\usepackage{bera}%
\usepackage[svgnames,rgb]{xcolor}%
\usepackage{makeidx}
\usepackage{ragged2e}
\usepackage{ccicons}
\usepackage{tabularx}
\usepackage{microtype}%
\usepackage{listings}
\usepackage{nicefrac}
\usepackage[numbered]{hypdoc}
\usepackage{marginnote}%
\usepackage[automark,nouppercase]{scrpage2}
\usepackage[tocgraduated]{tocstyle}
\usetocstyle{classic}
\usepackage{getmap}
\usepackage{tikz}
% turn off idiotic tikz error in doc generation
\makeatletter
\global\let\tikz@ensure@dollar@catcode=\relax
\makeatother
\usepackage{hyperref}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\makeatletter
\setlength{\headheight}{1.1\baselineskip}%
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
            {-2.5ex\@plus -1ex \@minus -.25ex}%
            {1.25ex \@plus .25ex}%
            {\normalfont\normalsize\bfseries}}
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}
\hypersetup{colorlinks=true,urlcolor=NavyBlue,linkcolor=NavyBlue,citecolor=CornflowerBlue}%
\lstset{literate=%
    {Ö}{{\"O}}1
    {Ä}{{\"A}}1
    {Ü}{{\"U}}1
    {ß}{{\ss}}1
    {ü}{{\"u}}1
    {ä}{{\"a}}1
    {ö}{{\"o}}1
    {~}{{\textasciitilde}}1
}
\lstset{language=[LaTeX]TeX,numbers=left,numberstyle=\tiny, basicstyle=\ttfamily, aboveskip=\baselineskip, frame=single, backgroundcolor=\color{LightGoldenrodYellow}, keywordstyle=\color{Blue},
emph={}}
\renewcommand{\maketitle}%
{%
  \thispagestyle{empty}%
  \pagecolor{Ivory}%
  \begin{titlepage}%
    \begin{tikzpicture}[remember picture,overlay]%
      \node[yshift=-2cm] at (current page.north west)%
      {%
        \begin{tikzpicture}[remember picture, overlay]%
          \draw[fill=CornflowerBlue,color=CornflowerBlue] (0,0) rectangle%
            (\paperwidth,2cm);%
          \draw[anchor=west,yshift=-4cm,xshift=3cm,color=NavyBlue] (0,0) node%
            {\parbox{15cm}{\RaggedRight\Huge\sffamily\textbf{\@title}}};%
          \draw[anchor=west,yshift=-6cm,xshift=3cm,color=NavyBlue] (0,0) node%
            {\parbox{15cm}{\huge\sffamily\textbf{\@fileversion}}};%
          \draw[anchor=west,yshift=-9cm,xshift=3cm,color=NavyBlue] (0,0) node%
            {\parbox{15cm}{\RaggedRight\huge\sffamily\textbf{\@subtitle}}};%
          \draw[anchor=west,yshift=-13cm,xshift=3cm,color=NavyBlue] (0,0) node%
            {\includegraphics[width=10cm]{osmimage}};%
          \draw[anchor=west,yshift=-17cm,xshift=3cm,color=NavyBlue] (0,0) node%
            {\parbox{15cm}{\huge\sffamily\textbf{\@date}}};%
          \draw[anchor=west,yshift=-20cm,xshift=3cm,color=NavyBlue] (0,0) node%
            {\parbox{15cm}{\Large\sffamily{\@authorline\\\textbf{\@author}}}};%
        \end{tikzpicture}%
      };%
      \node[yshift=0cm] at (current page.south west)%
      {%
        \begin{tikzpicture}[remember picture, overlay]%
          \draw[fill=NavyBlue,color=NavyBlue,yshift=6cm,xshift=2cm] (0,0) rectangle (0.2cm,19cm);%
          \draw[fill=CornflowerBlue,color=CornflowerBlue] (0,0) rectangle (\paperwidth,2cm);%
          \draw[anchor=west,yshift=1cm,xshift=3cm,color=NavyBlue] (0,0) node%
            {\parbox{15cm}{\large\sffamily{\@refline}}};%
        \end{tikzpicture}%
      };%
    \end{tikzpicture}%
  \end{titlepage}%
  \pagecolor{white}%
}%
%
\newcommand*{\@tikzhead}[1]%
{%
  \begin{tikzpicture}[remember picture,overlay]%
    \node[yshift=-2cm] at (current page.north west)%
    {%
      \begin{tikzpicture}[remember picture, overlay]%
        \draw[fill=CornflowerBlue] (0,0) rectangle (\paperwidth,2cm);%
        \draw[anchor=west,yshift=1cm,xshift=1.5cm,color=NavyBlue] (0,0) node%
          {\parbox{15cm}{\LARGE\sffamily\textbf{\@title}}};%
        \node[anchor=east,xshift=.9\paperwidth,rectangle,%
              rounded corners=15pt,inner sep=11pt,fill=NavyBlue]%
              {\color{white}\textsc{#1}};%
      \end{tikzpicture}%
    };%
  \end{tikzpicture}%
}%
\clearscrheadings%
\ihead{\@tikzhead{\headmark}}%
\cfoot{\upshape\thepage}%
\pagestyle{scrheadings}%
%
\newcommand*{\Headline}[1]{\@mkboth{#1}{#1}}%
%
\renewcommand{\headfont}{\normalfont\mdseries\scshape}
%
\gdef\@subtitle{}%
\providecommand*{\Subtitle}[1]{\gdef\@subtitle{#1}}%
\gdef\@fileversion{}%
\providecommand*{\Fileversion}[1]{\gdef\@fileversion{#1}}%
\gdef\@author{}%
\providecommand*{\Author}[1]{\gdef\@author{#1}}%
\gdef\@authorline{Package author:}%
\providecommand*{\Authorline}[1]{\gdef\@authorline{#1}}%
\gdef\@refline{}%
\providecommand*{\Refline}[1]{\gdef\@refline{#1}}%
\gdef\and{\unskip{}, }%
\newcommand\doubledash{-\kern0.5pt-}
\def\enoteformat{\rightskip\z@ \leftskip\z@ \parindent=1em\leavevmode\llap{\makeenmark}}
\def\filename{logicpuzzle.sty}%
\def\XeLaTeX{Xe\LaTeX}%
%
\newenvironment{optionlist}
{\begin{trivlist}\setlength\leftskip{2em}}
{\end{trivlist}}
\newcommand\optitem[3]{\item [\texttt{\textbf{\textcolor{DodgerBlue}{#1}} \lbrack\textcolor{Crimson}{#2}\rbrack}] #3}
\renewcommand\tableofcontents%
{%
  %\section*{\contentsname}%
  \@mkboth{%
  \MakeUppercase\contentsname}{\MakeUppercase\contentsname}%
  \@starttoc{toc}%
}%
%
\newcommand\env[1]{\texttt{#1}}%
\newcommand\layer[1]{\texttt{#1}\SortIndex{#1}{\texttt{#1} (PGF layer)}%
                     \SortIndex{PGF layer>#1}{\texttt{#1}}}%
\newcommand\styleoption[1]{\texttt{#1}\SortIndex{#1}{\texttt{#1} (Style option)}%
                     \SortIndex{Style option>#1}{\texttt{#1}}}%
\newcommand\envoption[1]{\texttt{#1}\SortIndex{#1}{\texttt{#1} (Puzzle option)}%
                     \SortIndex{Puzzle option>#1}{\texttt{#1}}}%
\newcommand\stylename[1]{\texttt{#1}\SortIndex{#1}{\texttt{#1} (Style file)}%
                     \SortIndex{Style file>#1}{\texttt{#1}}}%
\newcommand\package[1]{\texttt{#1}\SortIndex{#1}{\texttt{#1} (Package)}%
                     \SortIndex{Package>#1}{\texttt{#1}}}%
\newcommand*\margcs[1]{\marginnote{\hbadness=10000\RaggedLeft\scriptsize #1}}%
\def\PrintIndex{\clearpage\Headline{Index}\@input@{\jobname.ind}%
                \global\let\PrintIndex\@empty}
                \renewenvironment{theindex}
               {\if@twocolumn
                  \@restonecolfalse
                \else
                  \@restonecoltrue
                \fi
                \columnseprule \z@
                \columnsep 35\p@
\def\see##1##2{\textit{See} ##1}%
\def\seealso##1##2{\textit{See also} ##1}%
\long\def\cmd##1{\cs{\expandafter\cmd@to@cs\string##1}}%
\def\@url##1{\url@break\ttt{##1}\endgroup}%
\def\ttt{\begingroup\@sanitize\ttfamily\@ttt}%
\def\@ttt##1{##1\endgroup}%
\mathchardef\save@secnumdepth\c@secnumdepth
\c@secnumdepth\m@ne
                \phantomsection%
                \twocolumn%[\section{\indexname}]%
                \refstepcounter{section}
                \addcontentsline{toc}{section}{\protect\numberline{\thesection}Index}%
\c@secnumdepth\save@secnumdepth
                %\thispagestyle{plain}
                \parindent\z@
                \parskip\z@ \@plus .3\p@\relax
                \let\item\@idxitem}
               {\if@restonecol\onecolumn\else\clearpage\fi}
\setlength\parindent{0pt}%
\newcommand*\myref[1]{[see: \ref{#1} on page \pageref{#1}]}
\makeatother
\begin{document}
  \DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
%
%\GetFileInfo{\jobname.sty}
%\hypersetup{pdfauthor={Josef Kleber},pdftitle={A style file for downloading OpenStreetMap maps},pdfsubject={Documentation for LaTeX style \filename},pageanchor=true,hyperindex=true}%
%\lstset{language=[LaTeX]TeX,numbers=left,numberstyle=\tiny, basicstyle=\ttfamily, aboveskip=\baselineskip, frame=single, backgroundcolor=\color{LightGoldenrodYellow}, keywordstyle=\color{Blue},
%emph={},emphstyle=\color{Tomato}, 
%emph={[2]width},emphstyle={[2]\color{OliveDrab}},
%morekeywords={getmap,includegraphics}}
%\DoNotIndex{\,,\begingroup,\endgroup,\csname,\def,\else,\endcsname,\equal,\expandafter,
%\fi,\gdef,\ifnum,\ifthenelse,\immediate,\MessageBreak,\NeedsTeXFormat,\newcommand,\newif,
%\PackageInfo,\PackageError,\ProcessOptionsX,\ProvidesPackage,\relax,\RequirePackage,
%\space,\errmessage,\ExecuteOptionsX,}
%
% \bibliographystyle{plain}
% \title{\filename}%
% \Subtitle{A style file for downloading \mbox{OpenStreetMap} maps}%
% \author{Josef Kleber}
% \Fileversion{\fileversion}
% \date{\filedate}
% \Refline{\href{mailto:josef.kleber@gmx.de}{\texttt{josef.kleber@gmx.de}}\\\href{https://bitbucket.org/kleberj/getmap/}{\texttt{https://bitbucket.org/kleberj/getmap/}}}
% \maketitle
% \stepcounter{page}
% \tableofcontents
% \clearpage
% \setlength\parskip{6pt}%
%
%
%\StopEventually{^^A
% {
% \clearpage
% \raggedright
% \nocite{*}
% \bibliography{getmap}
% }
% \clearpage
%  \PrintChanges
%  \PrintIndex
%}
%
% \Headline{Abstract}
% \begin{abstract}
% The goal of this package is the simplest possible provision of OpenStreetMap maps.
% In the simplest case, the specification of the address is sufficient.
% The package loads the map using the \cmd\write18 feature, which you must activate to use this package.
% The image will be downloaded by an external Lua script.
% You can use this script, as well as the attached bash script also from the command line.
% \end{abstract}
% \vfill
% \renewcommand*{\abstractname}{Acknowledgment}
% \begin{abstract}
% I want to thank Norbert Preining, who did most of the recoding of \texttt{osmimage}
% (\texttt{Bash} $\rightarrow$ \texttt{Lua}). Moreover many thanks to Taco Hoekwater,
% Reinhard Kotucha and Heiko Oberdiek for their valuable contributions.
% \end{abstract}
% \clearpage
% \section{Options}
% The following options can be used as package options with global scope,
% as well as options for the \cmd\getmap\ command with local scope!
% \subsection[\texttt{key}]{\texttt{key (\underline{Kmjtd\textbar{}luu7n162n1,22=o5-h61wh}})}
% The download script requires a key in order to use the service of MapQuest.
% By default, it uses the example key of the web page.
% Maybe this will not work forever.
% If you use the service frequently, i strongly recommend to register with
% \href{http://developer.mapquest.com}{MapQuest} to use your own key.
% Be fair to the company that offers this free service!
% \subsection[\texttt{scale}]{\texttt{scale (\underline{3385}})}
% This option allows you to specify a display scale for the map image in the range of
% 1692 -- 221871572. You will not necessarily see a difference between 5000 and 5500.
% A scale value of 3385 corresponds to a zoom level of 17.
% \subsection[\texttt{zoom}]{\texttt{zoom}}
% This option allows you to specify a zoom level in the range of 1 -- 18.
% This option overwrites a possibly given scale.
% \subsection[\texttt{xsize}]{\texttt{xsize (\underline{800})}}
% This option specifies the width of the map in pixels.
% If you only want to slightly increase or decrease the map extract,
% you should adjust the size of the map. You still have full control over the size of
% the map in the document with the options of \cmd\includegraphics. (max: 3840)
% \subsection[\texttt{ysize}]{\texttt{ysize (\underline{400})}}
% This option specifies the height of the map in pixels. max: 3840)
% \subsection[\texttt{file}]{\texttt{file (\underline{osmimage})}}
% This option allows you to specify the name of the image (without extension).
% \subsection[\texttt{imagetype}]{\texttt{imagetype (\underline{png}\textbar{}jpeg\textbar{}jpg\textbar{}gif)}}
% This option allows you to specify the type of the image.
% \subsection[\texttt{type}]{\texttt{type (\underline{map}\textbar{}sat\textbar{}hyb)}}
% This option specifies the type of the map. It seems as if there were only a few regions of Mother Earth,
% for which satellite and hybrid images are available.
% \subsection[\texttt{color}]{\texttt{color (\underline{yellow\_1})}}
% This option specifies the color of the marker.
%
% Possible colors: \href{http://open.mapquestapi.com/staticmap/icons.html}{http://open.mapquestapi.com/staticmap/icons.html}
% \subsection[\texttt{number}]{\texttt{number (\underline{1})}}
% This option specifies the number of the marker.
% \subsection[\texttt{inputencoding}]{\texttt{inputencoding}}
% This option specifies the input encoding of your file.
% The download script requires the strings encoded in utf8.
% For the safe conversion the input encoding of the file is required.
% Normally, you don't have to specify an encoding.
% The package tries to evaluate the encoding given to \package{inputenc} or assumes utf8.
% Usually that should work.
% \subsection[\texttt{overwrite}]{\texttt{overwrite (\underline{false}\textbar{}true)}}
% With this option, you can specify whether the image should be downloaded in any case.
% By default, the option is set to \texttt{false} in order to save bandwidth and compilation time.
% Nevertheless a check is performed on the existence of the image and the
% image will be downloaded, if it is not present.
% In the case of \texttt{true}, the image will be downloaded anyway!
% BTW, \texttt{overwrite} is equivalent to \texttt{overwrite=true}.
% \section{Command(s)}
% \subsection{\cmd\getmap}
% With the \cmd\getmap\ command\margcs{\cmd\getmap\oarg{options}\marg{address}} you can download
% a map, if you enable \cmd\write18 (TeXLive: \texttt{-shell-escape}, MiKTeX: \texttt{-{}-enable-write18}).
% This is only necessary if you actually download an image.
% You can use the options described above to specify the properties of the downloaded image.
% After executing the command, the image is available in the current working directory!
%
% In the simplest case, you only need an address to download the map.
% By default, the image is saved under the name \texttt{osmimage.png}!
% If you need only one map (e.g. the office of Dante e.V.) in your document, it can be as simple as:
%
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\getmap{Bergheimer Straße 110A, 69115 Heidelberg, Germany}
\includegraphics[width=10cm]{osmimage}
\end{lstlisting}
% \iffalse
%</example>
% \fi
%
% \includegraphics[width=10cm]{osmimage}
%
% \clearpage
% \section{Implementation}
% \changes{v1.0}{2014/05/25}{CTAN upload}
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
% First, we provide the \LaTeX\ package \package{getmap}.
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}%
\ProvidesPackage{getmap}[2014/06/24 v1.1 getmap.sty - Josef Kleber (C) 2014]%
%    \end{macrocode}
% We need a few packages!
%    \begin{macrocode}
\RequirePackage{xkeyval}%
\RequirePackage{stringenc}%
\RequirePackage{ifthen}%
%    \end{macrocode}
% We provide a macro \cmd\GM@JK@define@key, which defines package options with global scope%
% and options for \cmd\getmap\ with local scope. It takes four arguments \marg{prefix},%
% \marg{package},\marg{option} and \marg{default}.
%    \begin{macrocode}
\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}%
  }%
}%
%    \end{macrocode}
% Now, we can use this macro to define our options.
%    \begin{macrocode}
\GM@JK@define@key{GM@JK}{getmap}{key}{Kmjtd|luu7n162n1,22=o5-h61wh}%
\GM@JK@define@key{GM@JK}{getmap}{xsize}{800}%
\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}{file}{osmimage}%
\GM@JK@define@key{GM@JK}{getmap}{inputencoding}{}%
\GM@JK@define@key{GM@JK}{getmap}{overwrite}{true}%
%    \end{macrocode}
% For options without default value, we define reasonable default values!
% We overwrite the default for \styleoption{overwrite}, because we don't want
% \styleoption{overwrite} to be \texttt{true} by default, but that \styleoption{overwrite}
% is equivalent to \styleoption{overwrite}=\texttt{true}!
%
% We try to use the input encoding specified for \package{inputenc} or \texttt{utf8} instead.
%    \begin{macrocode}
\gdef\GM@JK@overwrite{false}%
%
\@ifpackageloaded{inputenc}%
{%
  \gdef\GM@JK@inputencoding{\inputencodingname}%
}%
{%
  \gdef\GM@JK@inputencoding{utf8}%
}%
%
%    \end{macrocode}
% Later, we will need a switch, if \cmd\write18\ is enabled.
%    \begin{macrocode}
\newif\ifGM@JK@writexviii\GM@JK@writexviiifalse%
%
%    \end{macrocode}
% We execute the package options to define and set the option macros.
%    \begin{macrocode}
\ExecuteOptionsX{key,xsize,ysize,scale,zoom,type,imagetype,color,number,file}%
%
\ProcessOptionsX\relax%
%
%    \end{macrocode}
% We check if \cmd\pdf@shellescape\ is available to test if \cmd\write18
% is enabled.
%
% If \texttt{false}, we assume \cmd\write18\ is available and hope for the best.
%
% If \texttt{true}, we set the switch \cmd\GM@JK@writexviii\ accordingly!
%    \begin{macrocode}
\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%
}%
%    \end{macrocode}
% We define a macro that is executed as \cmd\write18\ call. First, we test if%
% \cmd\write18\ is enabled and issue a package error if not! Otherwise we execute%
% \cmd\write18\ depending on the existence of a \styleoption{zoom}%
% (\styleoption{zoom} overrides \styleoption{scale}).
%    \begin{macrocode}
\newcommand*\GM@JK@shellescape%
{%
  \ifGM@JK@writexviii%
    \ifthenelse{\equal{\GM@JK@zoom}{}}%
    {%
      \immediate\write18{osmimage \space-l\space "\GM@JK@location@string"%
                                  \space-k\space "\GM@JK@key@string"%
                                  \space-x\space \GM@JK@xsize%
                                  \space-y\space \GM@JK@ysize%
                                  \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}%
    }%
    {%
      \immediate\write18{osmimage \space-l\space "\GM@JK@location@string"%
                                  \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-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}%
    }%
  \else%
    \PackageError{getmap}{\write18 disabled}
                         {\write18 disabled\MessageBreak%
                          Use -shell-escape (TeXLive)\MessageBreak%
                          or\space\space--enable-write18 (MiKTeX)}%
  \fi%
}%
%    \end{macrocode}
% \begin{macro}{\getmap}
% Here, we define the user command to download the map.
%
% \cs{getmap}\oarg{options}\marg{address}
%    \begin{macrocode}
\newcommand*\getmap[2][]%
{%
%    \end{macrocode}
% \changes{v1.1}{2014/06/23}{Bugfix: problem in URL when using \cmd\usepackage[utf8]\{inputenc\}}
%  We start a group to keep the setting of options local.
%    \begin{macrocode}
  \begingroup%
    \setkeys{getmap}{#1}%
    \PackageInfo{getmap}{using \GM@JK@inputencoding\space encoding}%
    \def\GM@JK@location{#2}%
%    \end{macrocode}
% Both, the bash as well as the Lua script need their string arguments encoded in \texttt{utf8}!
%    \begin{macrocode}
    \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}%
    }%
%    \end{macrocode}
% We check, if \styleoption{overwrite} is \texttt{true} and download the map.
% If not, we check if the image is already in the working directory. If not, we
% download the image!
%    \begin{macrocode}
    \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%
}%
%    \end{macrocode}
%  \end{macro}
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%\Finale