summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/getmap/getmap.dtx
blob: 1ec2fec97153d22a298051c616c200fad64d287b (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
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
% \iffalse meta-comment
% !TEX program  = pdfLaTeX
%<*internal>
\iffalse
%</internal>
%<*readme>
The goal of this package is the simplest possible provision of
map images (OpenStreetMap, Google Maps and Google Street View 
are supported). In the simplest case, the specification of an
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 also from the command line.

License: LPPL

Changes in v1.4:

- added new options in gm mode

  * language (language of map labels)
  * markers (set marker on map)
  * visible (ensure locations to be on the map)
  * path (draw pathes and routes)
  * pathfile (load complicated encoded polylines (routes))

- added more examples to the documentation


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

First of all, install the package with the package manager of
your TeX distribution, if possible! A getmap package is
available for TeXLive2014+ and MiKTeX!

Manual installation:

download getmap.dtx 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 
  into $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

* Windows

  In MiKTeX scripts like getmapdl.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},
 }

@misc{bib:googlemapsapi,
 author               = {{Google, Inc.}},
 note                 = {\href{https://developers.google.com/maps/documentation/staticmaps/}{https://developers.google.com/maps/documentation/staticmaps/}},
 title                = {{Static Maps API V2 Developer Guide}},
 year                 = {2014},
 }

@misc{bib:googlesvapi,
 author               = {{Google, Inc.}},
 note                 = {\href{https://developers.google.com/maps/documentation/streetview/index}{https://developers.google.com/maps/documentation/streetview/index}},
 title                = {{Google Street View Image API}},
 year                 = {2014},
 }

@misc{bib:googlepla,
 author               = {{Google, Inc.}},
 note                 = {\href{https://developers.google.com/maps/documentation/utilities/polylinealgorithm}{https://developers.google.com/maps/documentation/utilities/polylinealgorithm}},
 title                = {{Encoded Polyline Algorithm Format}},
 year                 = {2014},
 }

@misc{bib:googleipeu,
 author               = {{Google, Inc.}},
 note                 = {\href{https://developers.google.com/maps/documentation/utilities/polylineutility}{https://developers.google.com/maps/documentation/utilities/polylineutility}},
 title                = {{Interactive Polyline Encoder Utility}},
 year                 = {2014},
 }
 
%</bibfile>
%<*luafile>
#!/usr/bin/env texlua
--
-- getmapdl [options]
--
-- downloads an OpenStreetMap, Google Maps or Google Street View map specified by [options]
--
-- License: LPPL
--
local http = require("socket.http");
local ltn12 = require("ltn12")
local url = require("socket.url")

local OSMURL = "http://open.mapquestapi.com/staticmap/v4/getplacemap"
local GMURL = "http://maps.googleapis.com/maps/api/staticmap"
local GSVURL = "http://maps.googleapis.com/maps/api/streetview"
local KEY = ""
local MODE = ""
local LOCATION = ""
local XSIZE = ""
local CENTER = ""
local YSIZE = ""
local SIZE = ""
local SCALE = ""
local ZOOM = ""
local TYPE = ""
local IMAGETYPE = ""
local COLOR = ""
local NUMBER = ""
local VISIBLE = ""
local IPATH = ""
local FPATH = ""
local MARKERS = ""
local HEADING = ""
local FOV = ""
local PITCH = ""
local LANGUAGE = ""
local OFILE = "getmap"
local QUIET = "false"
local VERSION = "v1.2 (25/07/2014)"

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

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

 downloads an OpenStreetMap or Google Maps map specified by [options]

 Options:

 -m specify the mode (osm|gm)
 
 -l  specify a location
     e.g. 'Bergheimer Straße 110A, 69115 Heidelberg, Germany'

 -x  specify a xsize (600)

 -y  specify a ysize (400)

 -S  short form to specify a size, e.g. 600,400 (osm) or 600x400 (gm)

 -s  specify a scale factor in the range 1692-221871572 (osm) or
     1-2 (osm)

 -z  specify a zoom in the range 1-18 (osm) or 0-21 (17) (gm)

 -t  specify map type {map|sathyb} (map) (osm) or
     {roadmap|satellite|hybrid|terrain} (roadmap) (gm)

 -i  specify image type {png|gif|jpg|jpeg} (png) (osm) or
     {png|png8|png32|gif|jpg|jpg-baseline} (png) (gm)

 -c  specify icon color (yelow_1) (osm) or (blue) (gm)
     see: http://open.mapquestapi.com/staticmap/icons.html
          https://developers.google.com/maps/documentation/staticmaps/#MarkerStyles

 -n  specify the icon number (1)

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

 -q  quiet; no output!

 -v  prints version information

 -h  prints help information

 gm mode only:
 
 -L  specify the language of map labels (xx language code (en,de,fr,...))
 
 -M  specify markers; see:
     https://developers.google.com/maps/documentation/staticmaps/index#Markers
     e.g.: &markers=size:mid|color:blue|label:1|address or more of these
     location and zoom will be ignored if used!

 -C  specify center of the map

 -V  specify a list of visible locations (loc1|loc2)

 -P  specify path from location to location
     e.g.: &path=weight:7|color:purple|loc1|loc2
     
 -p  specify a file holding the path specification
     (maybe needed for encoded polylines)

 gsv mode only:
 
 -H  specify heading (view) (0) (0 -- 360) (east: 90, ...)
 
 -T  specify the pitch (angle) (0) (-90 -- 90)
 
 -F  specify horizontal field of view (90) (0 -- 120)
     The field of view is expressed in degrees and a kind of zoom!
]])
  pversion()
end

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

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

function check_number(var, varname)
  if not(string.match(var, '^[-]?[0-9]+$')) then
    getmap_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
    getmap_error(exitcode, varname .. " = " .. var .. "; must be in the range of " .. min .. "-" .. max)
  end
end

print("\n")

do
  local newarg = {}
  local i, limit = 1, #arg
  while (i <= limit) do
    if arg[i] == "-l" then
      LOCATION = arg[i+1]
      i = i + 1
    elseif arg[i] == "-C" then
      CENTER = arg[i+1]
      i = i + 1
    elseif arg[i] == "-m" then
      MODE = arg[i+1]
      i = i + 1
    elseif arg[i] == "-k" then
      KEY = 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] == "-L" then
      LANGUAGE = arg[i+1]
      i = i + 1
    elseif arg[i] == "-M" then
      MARKERS = arg[i+1]
      i = i + 1
    elseif arg[i] == "-H" then
      HEADING = arg[i+1]
      i = i + 1
    elseif arg[i] == "-T" then
      PITCH = arg[i+1]
      i = i + 1
    elseif arg[i] == "-F" then
      FOV = arg[i+1]
      i = i + 1
    elseif arg[i] == "-V" then
      VISIBLE = arg[i+1]
      i = i + 1
    elseif arg[i] == "-P" then
      IPATH = arg[i+1]
      i = i + 1
    elseif arg[i] == "-p" then
      FPATH = 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
  getmap_warning("-q option currently not supported!")
end

if KEY == "" then
  if MODE == "osm" then
    KEY="Kmjtd|luu7n162n1,22=o5-h61wh"
    getmap_warning("KEY not specified; using mapquest example key as default!")
  end
end

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

if MODE == "gm" then
  if ZOOM == "" then
    ZOOM=17
    getmap_warning("ZOOM not specified; using ZOOM=17 as default!")
  end
end

if XSIZE == "" then
  XSIZE=600
  getmap_warning("XSIZE not specified; using XSIZE=600 as default!")
end

if YSIZE == "" then
  YSIZE=400
  getmap_warning("YSIZE not specified; using YSIZE=400 as default!")
end

if SIZE == "" then
  if MODE == "gm" then
    SIZE = XSIZE .. "x" .. YSIZE
  elseif MODE == "gsv" then
    SIZE = XSIZE .. "x" .. YSIZE
  elseif MODE == "osm" then
    SIZE = XSIZE .. "," .. YSIZE
  end
end

if SCALE == "" then
  if MODE == "gm" then
    SCALE=1
    getmap_warning("SCALE not specified, using SCALE=1 as default!")
  elseif MODE == "osm" then
    if ZOOM == "" then
      SCALE=3385
      getmap_warning("SCALE not specified, using SCALE=3385 as default!")
    end
  end
end

if TYPE == "" then
  if MODE == "gm" then
    TYPE = "roadmap"
    getmap_warning("TYPE not specified; using roadmap as default!")
  elseif MODE == "osm" then
    TYPE = "map"
    getmap_warning("TYPE not specified; using map as default!")
  end
end

if IMAGETYPE == "" then
  if MODE == "gsv" then
  else
    IMAGETYPE="png"
    getmap_warning("IMAGETYPE not specified; using png as default!")
  end
end

if COLOR == "" then
  if MODE == "gm" then
    COLOR="blue"
    getmap_warning("COLOR not specified; using blue as default!")
  elseif MODE == "osm" then
    COLOR="yellow_1"
    getmap_warning("COLOR not specified; using yellow_1 as default!")
  end
end

if NUMBER == "" then
  if MODE == "gsv" then
  else
    NUMBER=1
    getmap_warning("NUMBER not specified; using 1 as default!")
  end
end

if MODE == "gsv" then
  if HEADING == "" then
    HEADING=0
    getmap_warning("HEADING not specified; using 0 as default!")
  end

  if FOV == "" then
    FOV=90
    getmap_warning("FOV not specified; using 90 as default!")
  end

  if PITCH == "" then
    PITCH=0
    getmap_warning("PITCH not specified; using 0 as default!")
  end
end

if MODE == "gm" then
  if ZOOM == "" then
    ZOOM = 17
  else
    check_range(ZOOM,0,21,11,"ZOOM")
  end
  check_range(XSIZE,1,640,12,"XSIZE")
  check_range(YSIZE,1,640,13,"YSIZE")
  check_range(SCALE,1,2,14,"SCALE")
elseif MODE == "gsv" then
  check_range(XSIZE,1,640,12,"XSIZE")
  check_range(YSIZE,1,640,13,"YSIZE")
  check_range(HEADING,0,360,15,"HEADING")
  check_range(FOV,0,120,16,"FOV")
  check_range(PITCH,-90,90,17,"PITCH")
elseif MODE == "osm" then
  check_range(XSIZE,1,3840,11,"XSIZE")
  check_range(YSIZE,1,3840,12,"YSIZE")
  if ZOOM == "" then
    check_range(SCALE,1692,221871572,13,"SCALE")
  else
    check_range(ZOOM,1,18,14,"ZOOM")
  end
  check_number(NUMBER,"NUMBER")
end

local UKEY = ""
local ULOCATION = ""
local UZOOM = ""
local USCALEZOOM = ""
local UMARKERS = ""
local USIZE = ""
local USCALE = ""
local UTYPE = ""
local USHOWICON = ""
local UIMAGETYPE = ""
local UVISIBLE = ""
local UIPATH = ""
local UFPATH = ""
local EPLFILE = ""
local UHEADING = ""
local UFOV = ""
local UPITCH = ""
local ULANGUAGE = ""
local UOFILE = ""
local IMGURL = ""

if MODE == "gm" then
  ULOCATION = "center=" .. url.escape(LOCATION)
  if MARKERS == "" then
    UMARKERS = "&markers=size:mid|color:" .. COLOR .. "|label:" .. NUMBER .. "|" .. url.escape(LOCATION)
    UZOOM = "&zoom=" .. url.escape(ZOOM)
  else
    UMARKERS = "" .. url.escape(MARKERS)
    -- correct cruft escaping of "&markers="
    UMARKERS = UMARKERS:gsub("%%26markers%%3d","&markers=")
    UZOMM = ""
    if CENTER == "" then
      ULOCATION = ""
    else
      ULOCATION = "center=" .. url.escape(CENTER)
    end
  end
  USIZE = "&size=" .. url.escape(SIZE)
  USCALE = "&scale=" .. url.escape(SCALE)
  UTYPE = "&maptype=" .. url.escape(TYPE)
  UIMAGETYPE = "&format=" .. url.escape(IMAGETYPE)
  if IMAGETYPE == "jpg-baseline" then
    IMAGETYPE = "jpg"
  end
  if VISIBLE == "" then
    UVISIBLE = ""
  else
    UVISIBLE = "&visible=" .. url.escape(VISIBLE)
  end
  if IPATH == "" then
    UIPATH = ""
  else
    UIPATH = "" .. url.escape(IPATH)
    -- correct cruft escaping of "&path="
    UIPATH = UIPATH:gsub("%%26path%%3d","&path=")
  end
  if FPATH == "" then
    UFPATH = ""
  else
    EPLFILE = io.open(FPATH, "r")
    local contents = EPLFILE:read()
    EPLFILE:close()
    UFPATH = "" .. url.escape(contents)
    -- correct cruft escaping of "&path="
    UFPATH = UFPATH:gsub("%%26path%%3d","&path=")
  end
  if LANGUAGE == "" then
    ULANGUAGE=""
  else
    ULANGUAGE="&language=" .. LANGUAGE
  end
  UOFILE = OFILE .. "." .. IMAGETYPE
  IMGURL = GMURL .. "?" .. ULOCATION .. USIZE .. UZOOM .. UMARKERS .. UTYPE .. USCALE .. UIMAGETYPE .. UVISIBLE .. UIPATH .. UFPATH .. ULANGUAGE .. "&sensor=false"
elseif MODE == "gsv" then
  ULOCATION = "location=" .. url.escape(LOCATION)
  USIZE = "&size=" .. url.escape(SIZE)
  UHEADING = "&heading=" .. url.escape(HEADING)
  UFOV = "&fov=" .. url.escape(FOV)
  UPITCH = "&pitch=" .. url.escape(PITCH)
  UOFILE = OFILE .. ".jpg"
  IMGURL = GSVURL .. "?" .. ULOCATION .. USIZE .. UHEADING .. UFOV .. UPITCH .. "&sensor=false"
elseif MODE == "osm" then
  UKEY = "?key=" .. url.escape(KEY)
  ULOCATION = "&location=" .. url.escape(LOCATION)
  USIZE = "&size=" .. url.escape(SIZE)
  if ZOOM == "" then
    USCALEZOOM = "&scale=" .. url.escape(SCALE)
  else
    USCALEZOOM = "&zoom=" .. url.escape(ZOOM)
  end
  UTYPE = "&type=" .. url.escape(TYPE)
  UIMAGETYPE = "&imagetype=" .. url.escape(IMAGETYPE)
  USHOWICON = "&showicon=" .. url.escape(COLOR) .. "-" .. url.escape(NUMBER)
  UOFILE = OFILE .. "." .. IMAGETYPE
  IMGURL = OSMURL .. UKEY .. ULOCATION .. USIZE .. USCALEZOOM .. UTYPE .. UIMAGETYPE .. USHOWICON
end

local ret, msg
local ofile
ofile, msg = io.open(UOFILE, "wb")
if not ofile then
  getmap_error(21, msg)
end
print("\n\ngetmapdl.lua:")
print("url = " .. IMGURL)
print("output = " .. UOFILE)
ret, msg = http.request{
  url = IMGURL,
  sink = ltn12.sink.file(ofile)
}
if not ret then
  getmap_error(22, msg)
end
%</luafile>
%<*cfgfile>
% \iffalse
%%
%%
%% copy this file to your local or home tree
%% and put it under TEXMF/tex/latex/getmap
%% run texhash afterwards
%%
%%
% \fi
\gdef\GM@JK@key{Fmjtd|luur20u22d,75=o5-9aylh6}%
%</cfgfile>
%<*examplefile>
% \iffalse
%%
%%
%% compile with pdflatex -shell-escape getmap-example
%%
%%
% \fi
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{filecontents}
% \iffalse
%% use overwrite while optimizing the image
% \fi
\usepackage[overwrite,mode=gm]{getmap}
\begin{document}
\begin{filecontents*}{muc.epl}
&path=weight:5|color:orange|enc:okydHa}peAXOHi@jANv@A@kJJmFAiDJuAHmDXcBb@cC`@gC^_DV}CJaCF{APaBVkBdAyEf@qC`@{B\aDSwB
\end{filecontents*}
\getmap[file=muc,
        markers={&markers=size:mid|label:H|color:green|München, Hbf
                 &markers=label:S|color:yellow|Stachus, München
                 &markers=label:M|color:blue|Marienplatz, München},
        pathfile={muc.epl}]{}
\includegraphics[width=10cm]{muc}
\end{document}
%</examplefile>
%<*manifest>
This work consists of the following files:

getmap.pdf
getmap.dtx
README
makefile
install.bat

Files packaged in getmap.dtx:

getmap.sty
getmap.cfg
getmap-example.tex
getmapdl.lua
manifest.txt
%</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}}
}
\generate{
  \file{\jobname.cfg}{\from{\jobname.dtx}{cfgfile}}
}
\generate{
  \file{\jobname-example}{\from{\jobname.dtx}{examplefile}}
}
%</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{getmapdl.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{filecontents}
\usepackage{nicefrac}
\usepackage[numbered]{hypdoc}
\usepackage{marginnote}%
\usepackage[automark,nouppercase]{scrpage2}
\usepackage[tocgraduated]{tocstyle}
\usetocstyle{classic}
\usepackage[overwrite=false]{getmap}
\usepackage{attachfile}
\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=-14cm,xshift=3cm,color=NavyBlue] (0,0) node%
            {\includegraphics[width=8cm]{getmap}};%
          \draw[anchor=west,yshift=-18cm,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
%
%\getmap{Bergheimer Straße 110A, 69115 Heidelberg, Germany}
%\GetFileInfo{\jobname.sty}
%\hypersetup{pdfauthor={Josef Kleber},pdftitle={Downloading maps from OpenStreetMap, Google Maps or Google Street View},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,xsize,ysize,zoom,scale,mode,file,type,heading,pitch,fov,markers,visible,path,pathfile},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{Downloading maps from OpenStreetMap, Google Maps or Google Street View}%
% \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
% map images (OpenStreetMap, Google Maps and Google Street View 
% are supported). In the simplest case, the specification of an
% 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 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{General options}
% \subsubsection[\texttt{mode}]{\texttt{mode (\underline{osm}\textbar{}gm\textbar{}gsv})}
% This option sets the mode, that is the source of the images. OpenStreetMap, Google Maps or Google Street View!
% \subsubsection[\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.
% \subsubsection[\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}.
% \subsubsection[\texttt{file}]{\texttt{file (\underline{getmap})}}
% This \marginpar{\footnotesize\fbox{\parbox{3cm}{\raggedright{}changed default value to \texttt{getmap} in version 1.2!}}}
% option allows you to specify the name of the image (without extension).
% \subsection{\texttt{osm} mode}
% \subsubsection[\texttt{key}]{\texttt{key (\underline{Fmjtd\textbar{}luur20u22d,75=o5-9aylh6}})}
% In \texttt{osm} mode, the download script requires a key in order to use the service of MapQuest.
% By default, it uses a key, which is registered for \package{getmap}.
% But you can register and use your own key with this option.
% The default key is stored in \texttt{getmap.cfg}. You can copy this file to your local \TeX\ tree
% and store your own key there\footnote{Mapquest will deliver an url-encoded key, which must
% be decoded to ASCII, e.g. by \href{http://urldecode.org/}{Url decode}}!
% This file will be found after running \texttt{texhash}!
% \subsubsection[\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.
% \subsubsection[\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.
% \subsubsection[\texttt{xsize}]{\texttt{xsize (\underline{600})}}
% This option specifies the width of the map in pixels.
% If \marginpar{\footnotesize\fbox{\parbox{3cm}{\raggedright{}changed default value to \texttt{600} in version 1.2!}}}
% 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)
% \subsubsection[\texttt{ysize}]{\texttt{ysize (\underline{400})}}
% This option specifies the height of the map in pixels. (max: 3840)
% \subsubsection[\texttt{imagetype}]{\texttt{imagetype (\underline{png}\textbar{}jpeg\textbar{}jpg\textbar{}gif)}}
% This option allows you to specify the type of the image.
% \subsubsection[\texttt{type}]{\texttt{type (\underline{map}\textbar{}sat\textbar{}hyb)}}
% This option specifies the type of the map.
% It seems as if there would be only a few regions of Mother Earth,
% for which satellite and hybrid images are available.
% \subsubsection[\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}
% \subsubsection[\texttt{number}]{\texttt{number (\underline{1})}}
% This option specifies the number of the marker.
% \subsection{\texttt{gm} mode}
% \subsubsection[\texttt{scale}]{\texttt{scale (\underline{1})}}
% For the free version of Google Maps the image size is limited to 640x640.
% You can set \texttt{scale} to a value of 2, to get exactly the same map in doubled size in pixels.
% \subsubsection[\texttt{zoom}]{\texttt{zoom} (\underline{17})}
% This option allows you to specify a zoom level in the range of 0 -- 21.
% \subsubsection[\texttt{xsize}]{\texttt{xsize (\underline{600})}}
% 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: 640)
% \subsubsection[\texttt{ysize}]{\texttt{ysize (\underline{400})}}
% This option specifies the height of the map in pixels. (max: 640)
% \subsubsection[\texttt{imagetype}]{\texttt{imagetype (\underline{png}\textbar{}png8\textbar{}
% png32\textbar{}gif\textbar{}jpg} (progressive)\texttt{\textbar{}jpg-baseline} (flat))}
% This option allows you to specify the type of the image.
% \subsubsection[\texttt{type}]{\texttt{type (\underline{roadmap}\textbar{}satellite\textbar{}hybrid\textbar{}terrain)}}
% This option specifies the type of the map.
% \subsubsection[\texttt{color}]{\texttt{color (\underline{blue})}}
% This option specifies the color of the marker. Possible colors:
%
% black, brown, green, purple, yellow, blue, gray, orange, red, white or in hex format \texttt{0x3399FF}
% \subsubsection[\texttt{number}]{\texttt{number (\underline{1})}}
% This option specifies the number of the marker. Google Maps also allows uppercase letters: [A-Z]!
% \subsubsection[\texttt{language}]{\texttt{language} (\underline{en})}
% This option specifies the language of the map labels.
% Of course, not all languages are supported for all countries.
% At least, english and one of the national languages should be supported.
% Possible option values: en, de, fr, es, it, fi, ...
% \subsubsection{\texttt{markers}}
% This option allows you to set more than just the standard marker, which will no longer be used!
% You don't have to specify an address, as Google Maps will deliver an image with all markers on the map.
% Nevertheless, you can specify an address, which will define the center of the map.
% This option expects one or more URL parameters like:
%
% \texttt{\&markers=size:mid\textbar{}color:blue\textbar{}label:S\textbar{}loc1\textbar{}loc2\textbar{}...}
%
% \getmap[file=bmus1, mode=gm,
%         markers={&markers=size:mid|label:B|color:green|Bode Museum, Berlin%
%                  &markers=label:P|color:green|Pergamonmuseum, Berlin%
%                  &markers=label:N|color:blue|Neues Museum, Berlin}%
% ]{}
% \includegraphics[width=10cm]{bmus1}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\getmap[
file=bmus1, mode=gm,
markers={&markers=size:mid|label:B|color:green|Bode Museum, Berlin%
         &markers=label:P|color:green|Pergamonmuseum, Berlin%
         &markers=label:N|color:blue|Neues Museum, Berlin}%
]{}
\includegraphics[width=10cm]{bmus1}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% The parameters size, color and label are optional!
% \begin{description}
% \item[size] tiny, \underline{mid}, small
% \item[color] \underline{red}, black, brown, green, purple, yellow, blue, gray, orange, white, 0x1188FF
% \item[label] [0-9][A-Z] (only in mid size!)
% \end{description}
% The default is a mid-sized red bubble with a black point!
% \subsubsection{\texttt{visible}}
% With this option you can specify a list of locations (separated by a pipe), which must be on the map!
%
% \getmap[file=bmus2, mode=gm,
%        markers={&markers=size:mid|label:B|color:green|Bode Museum, Berlin
%                 &markers=label:P|color:green|Pergamonmuseum, Berlin
%                 &markers=label:N|color:blue|Neues Museum, Berlin},
%        visible={Brandenburger Tor, Berlin|Reichstagsufer 1, Berlin}]{}
% \includegraphics[width=10cm]{bmus2}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\getmap[
file=bmus2, mode=gm
markers={&markers=size:mid|label:B|color:green|Bode Museum, Berlin%
         &markers=label:P|color:green|Pergamonmuseum, Berlin%
         &markers=label:N|color:blue|Neues Museum, Berlin},%
visible={Brandenburger Tor, Berlin|Reichstagsufer 1, Berlin}]{}
\includegraphics[width=10cm]{bmus2}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \subsubsection{\texttt{path}}
% With this option you can define one or more pathes! It expects one or more URL parameters like:
%
% \texttt{\&path=weight:5\textbar{}color:orange\textbar{}loc1\textbar{}loc2\textbar{}...}
%
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\getmap[file=bmus3, mode=gm, language=de,
markers={&markers=size:mid|label:B|color:green|Bode Museum, Berlin%
         &markers=label:P|color:green|Pergamonmuseum, Berlin%
         &markers=label:N|color:blue|Neues Museum, Berlin},%
path={&path=weight:5|color:orange|Bode Museum, Berlin|%
      Pergamonmuseum, Berlin|Neues Museum, Berlin|%
      James-Simon-Park,Berlin|52.522649,13.402523%
      &path=weight:5|color:purple|James-Simon-Park, Berlin|%
      Weinmeisterstraße 6, Berlin}]{}
\includegraphics[width=10cm]{bmus3}
\end{lstlisting}
% \iffalse
%</example>
% \fi
%
% \getmap[file=bmus3, mode=gm, language=de,
%        markers={&markers=size:mid|label:B|color:green|Bode Museum, Berlin%
%                 &markers=label:P|color:green|Pergamonmuseum, Berlin%
%                 &markers=label:N|color:blue|Neues Museum, Berlin},%
%        path={&path=weight:5|color:orange|Bode Museum, Berlin|%
%              Pergamonmuseum, Berlin|Neues Museum, Berlin|%
%              James-Simon-Park,Berlin|52.522649,13.402523%
%              &path=weight:5|color:purple|James-Simon-Park, Berlin|%
%              Weinmeisterstraße 6, Berlin}]{}
% \includegraphics[width=10cm]{bmus3}
%
% You can also use \texttt{fillcolor} to mark areas! In pathes, you
% can also specify RGB32 colors, in which the last byte defines opacity,
% e.g. 55 (33\%).
%
% \getmap[file=cpny, mode=gm, zoom=13,
%        path={&path=weight:2|color:orange|fillcolor:0xff641A55|
%              40.764302, -73.973004|40.768044, -73.981903|%
%              40.800642, -73.958193|40.796887, -73.949226|%
%              40.764302, -73.973004}]{Central Park, New York}
% \includegraphics[width=10cm]{cpny}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\getmap[file=cpny, mode=gm, zoom=13,
       path={&path=weight:2|color:orange|fillcolor:0xff641A55|
             40.764302, -73.973004|40.768044, -73.981903|%
             40.800642, -73.958193|40.796887, -73.949226|%
             40.764302, -73.973004}]{Central Park, New York}
\includegraphics[width=10cm]{cpny}
\end{lstlisting}
% \iffalse
%</example>
% \fi
%
% With small enough spaces between way points you can also defines routes!
% The input of these would be very inconvenient. Therefore, Google Maps offers
% an online interactive map tool\footnote{\href{https://developers.google.com/maps/documentation/utilities/polylineutility}{https://developers.google.com/maps/documentation/utilities/polylineutility}}!
% Simply use \texttt{enc:polyline\_data} as location specifier.
% This string can contain all sorts of troublesome characters for \LaTeX{}.
% \cmd\getmap\ can deal with them, with the exception of curly braces!
% These will break your \LaTeX{} document. As a work-around, use the \texttt{pathfile} option.
% \subsubsection{\texttt{pathfile}}
% This option specifies the file holding the path specification. It will be loaded by the \texttt{Lua} script.
% You can use the \env{filecontents*} environment to keep the definition in your document.
% It should be a one line utf8-encoded file!
%
% \begin{filecontents*}{muc.epl}
% &path=weight:5|color:orange|enc:okydHa}peAXOHi@jANv@A@kJJmFAiDJuAHmDXcBb@cC`@gC^_DV}CJaCF{APaBVkBdAyEf@qC`@{B\aDSwB
% \end{filecontents*}
% \getmap[file=muc, mode=gm,
%         markers={&markers=size:mid|label:H|color:green|München, Hbf
%                  &markers=label:S|color:yellow|Stachus, München
%                  &markers=label:M|color:blue|Marienplatz, München},
%         pathfile={muc.epl}]{}
%\includegraphics[width=10cm]{muc}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\begin{filecontents*}{muc.epl}
&path=weight:5|color:orange|enc:okydHa}peAXOHi@jANv@A@kJJmFAi%
DJuAHmDXcBb@cC`@gC^_DV}CJaCF{APaBVkBdAyEf@qC`@{B\aDSwB
\end{filecontents*}
\getmap[file=muc, mode=gm,
markers={&markers=size:mid|label:H|color:green|München, Hbf
         &markers=label:S|color:yellow|Stachus, München
         &markers=label:M|color:blue|Marienplatz, München},
pathfile={muc.epl}]{}
\includegraphics[width=10cm]{muc}
\end{lstlisting}
% \iffalse
%</example>
% \fi
%
% \subsection{\texttt{gsv} mode}
% \subsubsection[\texttt{xsize}]{\texttt{xsize (\underline{600})}}
% This option specifies the width of the map in pixels. (max: 640)
% \subsubsection[\texttt{ysize}]{\texttt{ysize (\underline{400})}}
% This option specifies the height of the map in pixels. (max: 640)
% \subsubsection[\texttt{heading}]{\texttt{heading (\underline{0})}}
% This option specifies the heading (direction) in degrees in the range of 0 -- 360. (0: north, 90: east, ...)
% \subsubsection[\texttt{pitch}]{\texttt{pitch (\underline{0})}}
% This option specifies the pitch (angle) of the camera view in degrees in the range of -90 -- 90.
% \subsubsection[\texttt{fov}]{\texttt{fov (\underline{90})}}
% This option specifies the field of horizontal view (kind of zoom) in degrees in the range of 0 -- 120.
% \clearpage
% \section{Command(s)}
% \subsection[\textbackslash{}getmap]{\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, a POI or geographic coordinates
% (\texttt{latitude,longitude}) to download the map. \marg{address} must be fully expanded and must not contain macros!
% By default, the image is saved under the name \texttt{getmap.png}!
% If you need only one map (e.g. the office of Dante e.V.) in your document, it can be as simple as:
%
% \includegraphics[width=9cm]{getmap}
%
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\getmap{Bergheimer Straße 110A, 69115 Heidelberg, Germany}
\includegraphics[width=9cm]{getmap}
\end{lstlisting}
% \iffalse
%</example>
% \fi
%
% \clearpage
% \section{Examples}\marginnote{\attachfile[author={Josef Kleber},subject={getmap-example.tex},description={getmap-example.tex (source example)} ,mimetype={text/plain}, icon={Tag}]{getmap-example.tex}}
%
% The same map as before from Google Maps:
%
% \getmap[file=dantegm,mode=gm]{Bergheimer Straße 110A, 69115 Heidelberg, Germany}
% \includegraphics[width=9cm]{dantegm}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\getmap[file=dantegm,mode=gm]{Bergheimer Straße 110A,%
                              69115 Heidelberg, Germany}
\includegraphics[width=9cm]{dantegm}
\end{lstlisting}
% \iffalse
%</example>
% \fi
%
% The same map as satellite image:
%
% \getmap[file=dantegmsat,mode=gm,type=satellite]{Bergheimer Straße 110A, 69115 Heidelberg, Germany}
% \includegraphics[width=9cm]{dantegmsat}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\getmap[file=dantegmsat,mode=gm,type=satellite]
       {Bergheimer Straße 110A, 69115 Heidelberg, Germany}
\includegraphics[width=9cm]{dantegmsat}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \clearpage
% L'afrique, mon amour!
% 
% \getmap[file=africa,mode=gm,type=terrain,xsize=500,ysize=500,scale=2,zoom=3]{0,16}
% \includegraphics[width=9cm]{africa}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\getmap[file=africa,mode=gm,type=terrain,xsize=500,ysize=500,%
        scale=2,zoom=3]{0,16}
\includegraphics[width=9cm]{africa}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% L'amour, ...
% 
% \getmap[file=paris,mode=gm,type=hybrid,xsize=500,ysize=300,scale=2,zoom=16]{Tour Eiffel, Paris}
% \includegraphics[width=9cm]{paris}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
\getmap[file=paris,mode=gm,type=hybrid,xsize=500,ysize=300,%
        scale=2,zoom=16]{Tour Eiffel, Paris}
\includegraphics[width=9cm]{paris}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \clearpage
% Street View now:
% 
% \getmap[file=parisgsv,mode=gsv,heading=320,pitch=30,fov=40,xsize=300,ysize=600]{Avenue Piere-Loti, Paris}
% \includegraphics[width=4cm]{parisgsv}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
  \getmap[file=parisgsv,mode=gsv,heading=320,pitch=30,fov=40,%
          xsize=300,ysize=600]{Avenue Piere-Loti, Paris}
  \includegraphics[width=4cm]{parisgsv}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% and from the platform:
% 
% \getmap[file=parisgsvp,mode=gsv,heading=30,pitch=-25,fov=60]{Tour Eiffel, Paris}
% \includegraphics[width=8cm]{parisgsvp}
% \iffalse
%<*example>
% \fi
\begin{lstlisting}
  \getmap[file=parisgsvp,mode=gsv,heading=30,pitch=-25,fov=60]%
         {Tour Eiffel, Paris}
  \includegraphics[width=8cm]{parisgsvp}
\end{lstlisting}
% \iffalse
%</example>
% \fi
% \clearpage
% \section{Implementation}
% \changes{v1.0}{2014/05/25}{CTAN upload}
% \changes{v1.2}{2014/07/11}{added support for Google Maps}
% \changes{v1.2}{2014/07/11}{renamed osmimage.lua to getmapdl.lua}
% \changes{v1.3}{2014/07/19}{added support for Google Street View}
% \changes{v1.4}{2014/07/25}{added options language, markers, visible, path and pathfile in gm mode}
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
% First, we provide the \LaTeX\ package \package{getmap}.
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}%
\ProvidesPackage{getmap}[2014/07/25 v1.4 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}%
  }%
}%
\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}}%
  }%
}%
%    \end{macrocode}
% Now, we can use this macro to define our options.
% \changes{v1.2}{2014/07/11}{changed default values of \texttt{xsize }(600) and \texttt{file} (getmap)}
%    \begin{macrocode}
\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}%
%    \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}!
%
% \changes{v1.2}{2014/07/11}{added getmap.cfg to store default key (FR by Ulrike Fischer)}
% Moreover, we load \texttt{getmap.cfg} to set the default key. You can copy this file
% to your local \TeX\ tree and replace the key with your own!
%
% We try to use the input encoding specified for \package{inputenc} or \texttt{utf8} instead.
%    \begin{macrocode}
\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}%
}%
%
%    \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{mode,xsize,ysize,scale,zoom,type,imagetype,color,number,file,heading,fov,pitch,language}%
%
\ProcessOptionsX\relax%
%
%    \end{macrocode}
% We need to reset some defaults in \texttt{gm} mode.
%    \begin{macrocode}
%
\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}%
}%
{}%
%
%    \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 mode%
%    \begin{macrocode}
\newcommand*\GM@JK@shellescape%
{%
  \ifGM@JK@writexviii\relax%
    \ifthenelse{\equal{\GM@JK@mode}{osm}}%
    {%
      \immediate\write18{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}}%
      {%
        \immediate\write18{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}}%
        {%
          \immediate\write18{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%
}%
%    \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.
% Then we test, if we are in \texttt{gm} mode to reset some defaults!
% Finally, we set the local options again to override defaults if necessary!
%    \begin{macrocode}
  \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}%
    }%
    {}%
    \setkeys{getmap}{#1}%
%    \end{macrocode}
% In \texttt{gsv} mode, we have an implicit \texttt{imagetype=jpg}.
% Therefore, we have to set it to allow the later test on the existence
% of the image file!
%    \begin{macrocode}
    \ifthenelse{\equal{\GM@JK@mode}{gsv}}%
    {\def\GM@JK@imagetype{jpg}}{}%
    \PackageInfo{getmap}{using \GM@JK@inputencoding\space encoding}%
    \def\GM@JK@location{#2}%
%    \end{macrocode}
% \texttt{texlua} expects its 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}%
    }%
    \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}%
    }%
%    \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