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
|
% \iffalse meta-comment
% !TEX program = pdfLaTeX
%<*internal>
\iffalse
%</internal>
%<*readme>
The goal of this package is the simplest possible provision of
map images (OpenStreetMap and Google Maps 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, as well as
the attached bash script also from the command line.
License: LPPL
Changes in v1.2:
- added support for Google Maps
* new option mode
* renamed osmimage.lua -> getmapdl.lua
* changed defaults for xsize (600) and file (getmap)
* broader support of satellite and hybrid images
* new map type terrain
* much smaller files for maps
(less details like house numbers)
- added more examples to the documentation
- added getmap.cfg to store default key (osm)
feature request by: Ulrike Fischer
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 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},
}
@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},
}
%</bibfile>
%<*luafile>
#!/usr/bin/env texlua
--
-- getmapdl [options]
--
-- downloads an OpenStreetMap or Google Maps 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 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 MARKERS = ""
local OFILE = "getmap"
local QUIET = "false"
local VERSION = "v1.0 (15/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 (osmm) 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:
-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
]])
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)
local number='^[0-9]+$'
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
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] == "-M" then
MARKERS = 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] == "-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 == "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
IMAGETYPE="png"
getmap_warning("IMAGETYPE not specified; using png as default!")
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
NUMBER=1
getmap_warning("NUMBER not specified; using 1 as default!")
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 == "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 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
UOFILE = OFILE .. "." .. IMAGETYPE
IMGURL = GMURL .. "?" .. ULOCATION .. USIZE .. UZOOM .. UMARKERS .. UTYPE .. USCALE .. UIMAGETYPE .. UVISIBLE .. UIPATH .. "&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\ngetmap.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}
% \iffalse
%% use overwrite while optimizing the image
% \fi
\usepackage[overwrite,mode=gm]{getmap}
\begin{document}
\getmap[type=satellite,scale=2,zoom=16]{Estádio do Maracanã, Rio de Janeiro}
\includegraphics[width=10cm]{getmap}
\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>
%<*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{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=-13cm,xshift=3cm,color=NavyBlue] (0,0) node%
{\includegraphics[width=8cm]{getmap}};%
\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
%
% \getmap{Bergheimer Straße 110A, 69115 Heidelberg, Germany}
%\GetFileInfo{\jobname.sty}
%\hypersetup{pdfauthor={Josef Kleber},pdftitle={Downloading maps from OpenStreetMap or Google 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,xsize,ysize,zoom,scale,mode,file,type},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 or Google 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
% map images (OpenStreetMap and Google Maps 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, 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{mode}]{\texttt{mode (\underline{osm}\textbar{}gm})}
% This option sets the mode, that is the source of the images. OpenStreetMap or Google Maps!
% \subsection[\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}!
% \subsection[\texttt{scale}]{\texttt{scale (\underline{3385} (osm), \underline{1} (gm)})}
% \texttt{osm}: 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.
%
% \texttt{gm}: 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.
% \subsection[\texttt{zoom}]{\texttt{zoom}}
% This option allows you to specify a zoom level in the range of 1 -- 18
% ( osm - this option overwrites a possibly given scale) or 0 -- 21 (gm).
% \subsection[\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 (osm) or 640 (gm))
% \subsection[\texttt{ysize}]{\texttt{ysize (\underline{400})}}
% This option specifies the height of the map in pixels. max: 3840 (osm) or 640 (gm))
% \subsection[\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{imagetype}]{\texttt{imagetype (\underline{png})}}
% This option allows you to specify the type of the image.
%
% \texttt{osm}: \texttt{\underline{png}\textbar{}jpeg\textbar{}jpg\textbar{}gif}
%
% \texttt{gm}: \texttt{\underline{png}\textbar{}png8\textbar{}png32\textbar{}gif\textbar{}jpg} (progressive)\texttt{\textbar{}jpg-baseline} (flat)
% \subsection[\texttt{type}]{\texttt{type (\underline{map} (osm)\textbar{}\underline{roadmap} (gm))}}
% This option specifies the type of the map.
%
% \texttt{osm}: \texttt{\underline{map}\textbar{}sat\textbar{}hyb} \quad\quad\ It seems as if there would be only a few regions of Mother Earth,
% for which satellite and hybrid images are available.
%
% \texttt{gm}: \texttt{\underline{roadmap}\textbar{}satellite\textbar{}hybrid\textbar{}terrain}
% \subsection[\texttt{color}]{\texttt{color (\underline{yellow\_1}) (osm)\textbar{}\underline{blue} (gm))}}
% This option specifies the color of the marker. Possible colors:
%
% \texttt{osm} \href{http://open.mapquestapi.com/staticmap/icons.html}{http://open.mapquestapi.com/staticmap/icons.html}
%
% \texttt{gm}: black, brown, green, purple, yellow, blue, gray, orange, red, white or in hex format \texttt{0x3399FF}
% \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, 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
%
% \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
% \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}
% \begin{macrocode}
%<*package>
% \end{macrocode}
% First, we provide the \LaTeX\ package \package{getmap}.
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}%
\ProvidesPackage{getmap}[2014/07/15 v1.2 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.
% \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}{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}%
%
\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}%
}%
{%
\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-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.
% 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}%
\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}%
}%
% \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
|