Debian Codegraph @

texmf-dist/doc/latex/getmap/getmap.dtx

raw
1 % \iffalse meta-comment
2 % !TEX program = pdfLaTeX
3 %<*internal>
4 \iffalse
5 %</internal>
6 %<*readme>
7 # README #
8
9 The goal of this package is the simplest possible provision of
10 map images (OpenStreetMap, Google Maps and Google Street View
11 are supported). In the simplest case, it is is sufficient to
12 specify an address.. The package loads the map using the
13 \write18 feature, which you must activate to use this package.
14 The image will be downloaded by an external Lua script. You
15 can use this script also from the command line.
16
17 License: LPPL
18
19 Changes in v1.11:
20
21 * Requests to Google Maps' Static Image API are no longer free
22
23 added an API key, which allows
24
25 2000req/day for Google Maps and
26 1000req/day for Google Street View
27
28 %</readme>
29 %<*bibfile>
30 @misc{bib:devmapquest,
31 author = {{MapQuest, Inc}},
32 note = {\href{http://developer.mapquest.com}{http://developer.mapquest.com}},
33 title = {{Introducing the Data Manager API Web Service}},
34 year = {2014},
35 }
36
37 @misc{bib:mapquestopen,
38 author = {{MapQuest, Inc}},
39 note = {\href{http://open.mapquestapi.com/}{http://open.mapquestapi.com/}},
40 title = {{MapQuest Open Platform Web Services}},
41 year = {2014},
42 }
43
44 @misc{bib:mapquestopenzoomscale,
45 author = {{MapQuest, Inc}},
46 note = {\href{http://open.mapquestapi.com/staticmap/zoomToScale.html}{http://open.mapquestapi.com/staticmap/zoomToScale.html}},
47 title = {{Zoom To Scale Mapping}},
48 year = {2014},
49 }
50
51 @misc{bib:mapquestopencolors,
52 author = {{MapQuest, Inc}},
53 note = {\href{http://open.mapquestapi.com/staticmap/icons.html}{http://open.mapquestapi.com/staticmap/icons.html}},
54 title = {{Static Map Service: Standard Icons}},
55 year = {2014},
56 }
57
58 @misc{bib:mapquestopenlatlngencdec,
59 author = {{MapQuest, Inc}},
60 note = {\href{http://open.mapquestapi.com/common/encodedecode.html}{http://open.mapquestapi.com/common/encodedecode.html}},
61 title = {{Compressed Lat/Lng Encoding/Decoding}},
62 year = {2014},
63 }
64
65 @misc{bib:googlemapsapi,
66 author = {{Google, Inc.}},
67 note = {\href{https://developers.google.com/maps/documentation/staticmaps/}{https://developers.google.com/maps/documentation/staticmaps/}},
68 title = {{Static Maps API V2 Developer Guide}},
69 year = {2014},
70 }
71
72 @misc{bib:googlesvapi,
73 author = {{Google, Inc.}},
74 note = {\href{https://developers.google.com/maps/documentation/streetview/index}{https://developers.google.com/maps/documentation/streetview/index}},
75 title = {{Google Street View Image API}},
76 year = {2014},
77 }
78
79 @misc{bib:googlepla,
80 author = {{Google, Inc.}},
81 note = {\href{https://developers.google.com/maps/documentation/utilities/polylinealgorithm}{https://developers.google.com/maps/documentation/utilities/polylinealgorithm}},
82 title = {{Encoded Polyline Algorithm Format}},
83 year = {2014},
84 }
85
86 @misc{bib:googleipeu,
87 author = {{Google, Inc.}},
88 note = {\href{https://developers.google.com/maps/documentation/utilities/polylineutility}{https://developers.google.com/maps/documentation/utilities/polylineutility}},
89 title = {{Interactive Polyline Encoder Utility}},
90 year = {2014},
91 }
92
93 @misc{bib:orsorg,
94 author = {{OpenRouteService.org}},
95 note = {\href{http://openrouteservice.org}{http://openrouteservice.org}},
96 title = {{Routing with user-generated, collaboratively collected free geodata.}},
97 year = {2014},
98 }
99
100 @misc{bib:berlinkml,
101 author = {Kleber, Josef},
102 note = {\href{https://bitbucket.org/kleberj/getmap/downloads/Berlin.kml}{https://bitbucket.org/kleberj/getmap/downloads/Berlin.kml}},
103 title = {{Berlin: Hbf Berlin - Brandenburger Tor (getmap Test)}},
104 year = {2014},
105 }
106
107 @misc{bib:mucberkml,
108 author = {Kleber, Josef},
109 note = {\href{https://bitbucket.org/kleberj/getmap/downloads/MucBer.kml}{https://bitbucket.org/kleberj/getmap/downloads/MucBer.kml}},
110 title = {{MucBer: München Stachus -> Berlin Brandenburger Tor}},
111 year = {2014},
112 }
113
114 @misc{bib:texsx,
115 author = {Kleber, Josef},
116 note = {\href{https://stackoverflow.com/questions/34653500/google-maps-implicit-positioning-of-the-map-broken}{https://stackoverflow.com/questions/34653500/google-maps-implicit-positioning-of-the-map-broken}},
117 title = {{Google Maps 'Implicit Positioning of the Map' broken?}},
118 year = {2016},
119 }
120 %</bibfile>
121 %<*luafile>
122 #!/usr/bin/env texlua
123 --
124 -- getmapdl [options]
125 --
126 -- downloads an OpenStreetMap, Google Maps or Google Street View map
127 -- specified by [options] or parses gpx, gps and kml files to create
128 -- encoded polylines
129 --
130 -- License: LPPL
131 --
132 local http = require("socket.http")
133 local ltn12 = require("ltn12")
134 -- local url = require("socket.url")
135 -- avoid bug in luatex v1.0.7
136 -- copied socket.url's escape function into local function url_escape
137 function url_escape(s)
138 return (string.gsub(s, "([^A-Za-z0-9_])", function(c)
139 return string.format("%%%02x", string.byte(c))
140 end))
141 end
142
143 local OSMURL = "http://open.mapquestapi.com/staticmap/v4/getplacemap"
144 local GMURL = "http://maps.googleapis.com/maps/api/staticmap"
145 local GSVURL = "http://maps.googleapis.com/maps/api/streetview"
146 local KEY = ""
147 local MODE = ""
148 local LOCATION = ""
149 local XSIZE = ""
150 local CENTER = ""
151 local YSIZE = ""
152 local SIZE = ""
153 local SCALE = ""
154 local ZOOM = ""
155 local TYPE = ""
156 local IMAGETYPE = ""
157 local COLOR = ""
158 local NUMBER = ""
159 local VISIBLE = ""
160 local IPATH = ""
161 local FPATH = ""
162 local MARKERS = ""
163 local HEADING = ""
164 local FOV = ""
165 local PITCH = ""
166 local LANGUAGE = ""
167 local GPFILE = ""
168 local KMLFILE = ""
169 local BOUND = 0.1
170 local OFILE = "getmap"
171 local QUIET = "false"
172 local VERSION = "v1.5a (2018/07/18)"
173
174 function pversion()
175 print("getmapdl.lua " .. VERSION)
176 print("(C) Josef Kleber License: LPPL")
177 os.exit(0)
178 end
179
180 function phelp()
181 print([[
182 getmapdl.lua [options]
183
184 downloads an OpenStreetMap, Google Maps or Google Street View map
185 specified by [options] or parses gpx, gps and kml files to create
186 encoded polylines
187
188 Options:
189
190 -m specify the mode (osm|gm|gsv|gpx2epl|gps2epl|gpx2gps|kml2epl|kml2gps)
191
192 -l specify a location
193 e.g. 'Bergheimer Straße 110A, 69115 Heidelberg, Germany'
194
195 -x specify a xsize (600)
196
197 -y specify a ysize (400)
198
199 -S short form to specify a size, e.g. 600,400 (osm) or 600x400 (gm)
200
201 -s specify a scale factor in the range 1692-221871572 (osm) or
202 1-2 (gm)
203
204 -z specify a zoom in the range 1-18 (osm) or 0-21 (17) (gm)
205
206 -t specify map type {map|sathyb} (map) (osm) or
207 {roadmap|satellite|hybrid|terrain} (roadmap) (gm)
208
209 -i specify image type {png|gif|jpg|jpeg} (png) (osm) or
210 {png|png8|png32|gif|jpg|jpg-baseline} (png) (gm)
211
212 -c specify icon color (yelow_1) (osm) or (blue) (gm)
213 see: http://open.mapquestapi.com/staticmap/icons.html
214 https://developers.google.com/maps/documentation/staticmaps/#MarkerStyles
215
216 -n specify the icon number (1)
217
218 -o specify output basename without file extension (getmap.IMAGETYPE)
219
220 -q quiet; no output!
221
222 -v prints version information
223
224 -h prints help information
225
226 gm mode only:
227
228 -L specify the language of map labels (xx language code (en,de,fr,...))
229
230 -M specify markers; see:
231 https://developers.google.com/maps/documentation/staticmaps/index#Markers
232 e.g.: &markers=size:mid|color:blue|label:1|address or more of these
233 location and zoom will be ignored if used!
234
235 -C specify center of the map
236
237 -V specify a list of visible locations (loc1|loc2)
238
239 -P specify path from location to location
240 e.g.: &path=weight:7|color:purple|loc1|loc2
241
242 -p specify a file holding the path specification
243 (maybe needed for encoded polylines)
244
245 gsv mode only:
246
247 -H specify heading (view) (0) (0 -- 360) (east: 90, ...)
248
249 -T specify the pitch (angle) (0) (-90 -- 90)
250
251 -F specify horizontal field of view (90) (0 -- 120)
252 The field of view is expressed in degrees and a kind of zoom!
253
254 gpx2epl, gps2epl and gpx2gps mode only:
255
256 -G specify the gpx or gps file
257
258 kml2epl and kml2gps mode only:
259
260 -K specify the kml file
261
262 gps2gps mode only:
263
264 -B specify the bound for reducing way points (default: 0.1)
265
266 ]])
267 pversion()
268 end
269
270 function getmap_error(exitcode, errortext)
271 io.stderr:write ("Error (" .. exitcode .. "): " .. errortext .. "\n")
272 os.exit(exitcode)
273 end
274
275 function getmap_warning(warningtext)
276 io.stderr:write("WARNING: " .. warningtext .. "\n")
277 end
278
279 function check_number(var, varname)
280 if not(string.match(var, '^[-]?[0-9]+$')) then
281 getmap_error(2, varname .. " can't be " .. var .. "! Not a number!")
282 end
283 end
284
285 function check_range(var,min,max,exitcode,varname)
286 check_number(var,varname)
287 if (tonumber(var) < tonumber(min) or tonumber(var) > tonumber(max)) then
288 getmap_error(exitcode, varname .. " = " .. var .. "; must be in the range of " .. min .. "-" .. max)
289 end
290 end
291
292 function round(number, precision)
293 return math.floor(number*math.pow(10,precision)+0.5) / math.pow(10,precision)
294 end
295
296 function encodeNumber(number)
297 local num = number
298 num = num * 2
299 if num < 0
300 then
301 num = (num * -1) - 1
302 end
303 local t = {}
304 while num >= 32
305 do
306 local num2 = 32 + (num % 32) + 63
307 table.insert(t,string.char(num2))
308 num = math.floor(num / 32) -- use floor to keep integer portion only
309 end
310 table.insert(t,string.char(num + 63))
311 return table.concat(t)
312 end
313
314 function printepl(epltable)
315 local string = table.concat(epltable)
316 -- sometimes the sting contains unwanted control characters
317 local stingwithoutcontrolcharacters = string:gsub("%c", "")
318 print(stingwithoutcontrolcharacters)
319 end
320
321 function isnotnumber(number)
322 if tonumber(number) == nil then
323 return true
324 else
325 return false
326 end
327 end
328
329 function dbtbound(Onum, num, bound)
330 local absdiff = math.abs(tonumber(Onum) - tonumber(num))
331 if absdiff >= tonumber(bound) then
332 return true
333 else
334 return false
335 end
336 end
337
338 do
339 local newarg = {}
340 local i, limit = 1, #arg
341 while (i <= limit) do
342 if arg[i] == "-l" then
343 LOCATION = arg[i+1]
344 i = i + 1
345 elseif arg[i] == "-C" then
346 CENTER = arg[i+1]
347 i = i + 1
348 elseif arg[i] == "-m" then
349 MODE = arg[i+1]
350 i = i + 1
351 elseif arg[i] == "-k" then
352 KEY = arg[i+1]
353 i = i + 1
354 elseif arg[i] == "-x" then
355 XSIZE = arg[i+1]
356 i = i + 1
357 elseif arg[i] == "-y" then
358 YSIZE = arg[i+1]
359 i = i + 1
360 elseif arg[i] == "-S" then
361 SIZE = arg[i+1]
362 i = i + 1
363 elseif arg[i] == "-s" then
364 SCALE = arg[i+1]
365 i = i + 1
366 elseif arg[i] == "-z" then
367 ZOOM = arg[i+1]
368 i = i + 1
369 elseif arg[i] == "-t" then
370 TYPE = arg[i+1]
371 i = i + 1
372 elseif arg[i] == "-i" then
373 IMAGETYPE = arg[i+1]
374 i = i + 1
375 elseif arg[i] == "-c" then
376 COLOR = arg[i+1]
377 i = i + 1
378 elseif arg[i] == "-n" then
379 NUMBER = arg[i+1]
380 i = i + 1
381 elseif arg[i] == "-L" then
382 LANGUAGE = arg[i+1]
383 i = i + 1
384 elseif arg[i] == "-M" then
385 MARKERS = arg[i+1]
386 i = i + 1
387 elseif arg[i] == "-H" then
388 HEADING = arg[i+1]
389 i = i + 1
390 elseif arg[i] == "-T" then
391 PITCH = arg[i+1]
392 i = i + 1
393 elseif arg[i] == "-F" then
394 FOV = arg[i+1]
395 i = i + 1
396 elseif arg[i] == "-V" then
397 VISIBLE = arg[i+1]
398 i = i + 1
399 elseif arg[i] == "-P" then
400 IPATH = arg[i+1]
401 i = i + 1
402 elseif arg[i] == "-p" then
403 FPATH = arg[i+1]
404 i = i + 1
405 elseif arg[i] == "-G" then
406 GPFILE = arg[i+1]
407 i = i + 1
408 elseif arg[i] == "-K" then
409 KMLFILE = arg[i+1]
410 i = i + 1
411 elseif arg[i] == "-B" then
412 BOUND = arg[i+1]
413 i = i + 1
414 elseif arg[i] == "-o" then
415 OFILE = arg[i+1]
416 i = i + 1
417 elseif arg[i] == "-q" then
418 QUIET = 1
419 elseif arg[i] == "-v" then
420 pversion()
421 elseif arg[i] == "-h" then
422 phelp()
423 else
424 newarg[#newarg+1] = arg[i]
425 end
426 i = i + 1
427 end
428 arg = newarg
429 end
430
431 if QUIET == 1 then
432 getmap_warning("-q option currently not supported!")
433 end
434
435 if MODE == "gpx2epl" then
436 local file = GPFILE
437 local name
438 local desc
439 local Olatitude = 0
440 local Olongitude = 0
441 local epl = {}
442
443 for line in io.lines(file)
444 do
445 local latitude
446 local longitude
447 local encnum
448
449 if string.match(line, "<trk>") then
450 Olatitude = 0
451 Olongitude = 0
452 name = ""
453 desc = ""
454 epl = {}
455 end
456 if string.match(line, "<name") then
457 name = string.match(line, '<name>(.-)</name>')
458 if name == nil then
459 name = "Name (E)"
460 end
461 end
462 if string.match(line, "<desc") then
463 desc = string.match(line, '<desc>(.-)</desc>')
464 if desc == nil then
465 desc = ""
466 end
467 end
468 if string.match(line, "<trkseg") then
469 print("Route: " .. name .. " [" .. desc .. "]")
470 end
471 if string.match(line, "<trkpt") then
472 latitude = string.match(line, 'lat="(.-)"')
473 longitude = string.match(line, 'lon="(.-)"')
474 latitude = round(latitude,5)*100000
475 longitude = round(longitude,5)*100000
476 encnum = encodeNumber(latitude - Olatitude)
477 table.insert(epl,encnum)
478 encnum = encodeNumber(longitude - Olongitude)
479 table.insert(epl,encnum)
480 Olatitude = latitude
481 Olongitude = longitude
482 end
483 if string.match(line, "</trk>") then
484 printepl(epl)
485 print("\n")
486 end
487 end
488 os.exit(0)
489 end
490
491 if MODE == "gpx2gps" then
492 local file = GPFILE
493 local name
494 local desc
495
496 for line in io.lines(file)
497 do
498 local latitude
499 local longitude
500 local encnum
501
502 if string.match(line, "<trk>") then
503 name = ""
504 desc = ""
505 end
506 if string.match(line, "<name") then
507 name = string.match(line, '<name>(.-)</name>')
508 if name == nil then
509 name = "Name (E)"
510 end
511 end
512 if string.match(line, "<desc") then
513 desc = string.match(line, '<desc>(.-)</desc>')
514 if desc == nil then
515 desc = ""
516 end
517 end
518 if string.match(line, "<trkseg") then
519 print("Route: " .. name .. " [" .. desc .. "]")
520 end
521 if string.match(line, "<trkpt") then
522 latitude = string.match(line, 'lat="(.-)"')
523 longitude = string.match(line, 'lon="(.-)"')
524 latitude = round(latitude,5)
525 longitude = round(longitude,5)
526 print(latitude .. "," .. longitude)
527 end
528 if string.match(line, "</trk>") then
529 print("\n")
530 end
531 end
532 os.exit(0)
533 end
534
535 if MODE == "gps2gps" then
536 local file = GPFILE
537 local bound = BOUND
538 local incount = 0
539 local outcount = 0
540 local routecount = 1
541 local latitude
542 local longitude
543 local Olatitude
544 local Olongitude
545 local Llatitude
546 local Llongitude
547 local ignorenextline = false
548 local firstroute = true
549
550 for line in io.lines(file)
551 do
552 latitude, longitude = line:match("([^,]+),([^,]+)")
553 if ignorenextline == true then
554 line = ""
555 ignorenextline = false
556 end
557 -- if line contains "Point:" then gps coordinates
558 -- in the next line must be ignored!
559 if line:match("Point:") then
560 ignorenextline = true
561 end
562 if line:match("Route:") then
563 if firstroute == true then
564 firstroute = false
565 routecount = 0
566 else
567 -- print last pair of coordinates
568 print(Llatitude .. "," .. Llongitude)
569 outcount = outcount + 1
570 io.stderr:write("\nRoute " .. routecount .. ": reduced gps coordinates (Bound = " .. bound .. "): " .. incount .. " -> " .. outcount)
571 end
572 incount = 0
573 outcount = 0
574 routecount = routecount + 1
575 print("\n" .. line .. "\n")
576 line = ""
577 end
578 if line == "" or isnotnumber(latitude) or isnotnumber(longitude)
579 then
580 -- empty line or no gps coordinates -> do nothing
581 else
582 latitude = round(latitude,5)
583 longitude = round(longitude,5)
584 Llatitude = latitude
585 Llongitude = longitude
586 incount = incount + 1
587 if incount == 1 then
588 Olatitude = latitude
589 Olongitude = longitude
590 print(Olatitude .. "," .. Olongitude)
591 outcount = outcount + 1
592 else
593 if dbtbound(Olatitude,latitude,bound) or dbtbound(Olongitude,longitude,bound) then
594 print(latitude .. "," .. longitude)
595 outcount = outcount + 1
596 Olatitude = latitude
597 Olongitude = longitude
598 end
599 end
600 end
601 end
602 -- print last pair of coordinates
603 print(Llatitude .. "," .. Llongitude)
604 outcount = outcount + 1
605 io.stderr:write("\nRoute " .. routecount .. ": reduced gps coordinates (Bound = " .. bound .. "): " .. incount .. " -> " .. outcount)
606 os.exit(0)
607 end
608
609 if MODE == "gps2epl" then
610 local file = GPFILE
611 local Olatitude = 0
612 local Olongitude = 0
613 local epl = {}
614 local firstroute = true
615
616 for line in io.lines(file)
617 do
618 local latitude
619 local longitude
620 local encnum
621
622 latitude, longitude = line:match("([^,]+),([^,]+)")
623 if ignorenextline == true then
624 line = ""
625 ignorenextline = false
626 end
627 -- if line contains "Point:" then gps coordinates
628 -- in the next line must be ignored!
629 if line:match("Point:") then
630 ignorenextline = true
631 end
632 if line:match("Route:") then
633 if firstroute == true then
634 firstroute = false
635 else
636 printepl(epl)
637 Olatitude = 0
638 Olongitude = 0
639 epl = {}
640 end
641 print("\n" .. line .. "\n")
642 line = ""
643 end
644 if line == "" or isnotnumber(latitude) or isnotnumber(longitude)
645 then
646 -- empty line or no gps coordinates -> do nothing
647 else
648 latitude = round(latitude,5)*100000
649 longitude = round(longitude,5)*100000
650 encnum = encodeNumber(latitude - Olatitude)
651 table.insert(epl,encnum)
652 encnum = encodeNumber(longitude - Olongitude)
653 table.insert(epl,encnum)
654 Olatitude = latitude
655 Olongitude = longitude
656 end
657 end
658 printepl(epl)
659 os.exit(0)
660 end
661
662 if MODE == "kml2gps" or MODE == "kml2epl" then
663 local file = KMLFILE
664 local name
665 local cdata
666 local cotype
667 local Olatitude = 0
668 local Olongitude = 0
669 local epl = {}
670
671 for line in io.lines(file)
672 do
673 local latitude
674 local longitide
675 local elevation
676
677 -- reset for new route
678 if string.match(line, "<Placemark>") then
679 Olatitude = 0
680 Olongitude = 0
681 cotype = nil
682 epl = {}
683 end
684 if string.match(line, "<name>") then
685 name = string.match(line, '<name>(.-)</name>')
686 if name == nil then
687 name = "Name (E)"
688 end
689 end
690 if string.match(line, "CDATA") then
691 cdata = string.match(line, 'CDATA%[(.-)%]')
692 if cdata == nil then
693 cdata = ""
694 end
695 end
696 if string.match(line, "<Point>") then
697 cotype = "point"
698 end
699 if string.match(line, "<LineString>") then
700 cotype = "route"
701 end
702 if cotype == "point" or cotype == "route" then
703 if string.match(line, "<coordinates>") then
704 local colist = string.match(line, '<coordinates>(.-)</coordinates>')
705 if cotype == "route" then
706 print("Route: " .. name)
707 else
708 print("Point: " .. name .. " [" .. cdata .. "]")
709 end
710 for cocsv in string.gmatch(colist, "%S+") do
711 longitude, latitude, altitude = cocsv:match("([^,]+),([^,]+),([^,]+)")
712 latitude = round(latitude,5)
713 longitude = round(longitude,5)
714 if MODE == "kml2epl" then
715 local encnum
716 if cotype == "route" then
717 latitude = latitude*100000
718 longitude = longitude*100000
719 encnum = encodeNumber(latitude - Olatitude)
720 table.insert(epl,encnum)
721 encnum = encodeNumber(longitude - Olongitude)
722 table.insert(epl,encnum)
723 Olatitude = latitude
724 Olongitude = longitude
725 else
726 print(latitude .. "," .. longitude)
727 end
728 else
729 print(latitude .. "," .. longitude)
730 end
731 end
732 if MODE == "kml2epl" and cotype == "route" then
733 printepl(epl)
734 end
735 print("\n")
736 end
737 end
738 end
739 os.exit(0)
740 end
741
742 print("\n")
743
744 if KEY == "" then
745 if MODE == "osm" then
746 KEY="Kmjtd|luu7n162n1,22=o5-h61wh"
747 getmap_warning("KEY not specified; using mapquest example key as default!")
748 end
749 end
750
751 if LOCATION == "" then
752 LOCATION = "Bergheimer Straße 110A, 69115 Heidelberg, Germany"
753 getmap_warning("LOCATION not specified; using Dante e.V. Office as default!")
754 end
755
756 if MODE == "gm" then
757 if ZOOM == "" then
758 ZOOM=17
759 getmap_warning("ZOOM not specified; using ZOOM=17 as default!")
760 end
761 end
762
763 if XSIZE == "" then
764 XSIZE=600
765 getmap_warning("XSIZE not specified; using XSIZE=600 as default!")
766 end
767
768 if YSIZE == "" then
769 YSIZE=400
770 getmap_warning("YSIZE not specified; using YSIZE=400 as default!")
771 end
772
773 if SIZE == "" then
774 if MODE == "gm" then
775 SIZE = XSIZE .. "x" .. YSIZE
776 elseif MODE == "gsv" then
777 SIZE = XSIZE .. "x" .. YSIZE
778 elseif MODE == "osm" then
779 SIZE = XSIZE .. "," .. YSIZE
780 end
781 end
782
783 if SCALE == "" then
784 if MODE == "gm" then
785 SCALE=1
786 getmap_warning("SCALE not specified, using SCALE=1 as default!")
787 elseif MODE == "osm" then
788 if ZOOM == "" then
789 SCALE=3385
790 getmap_warning("SCALE not specified, using SCALE=3385 as default!")
791 end
792 end
793 end
794
795 if TYPE == "" then
796 if MODE == "gm" then
797 TYPE = "roadmap"
798 getmap_warning("TYPE not specified; using roadmap as default!")
799 elseif MODE == "osm" then
800 TYPE = "map"
801 getmap_warning("TYPE not specified; using map as default!")
802 end
803 end
804
805 if IMAGETYPE == "" then
806 if MODE == "gsv" then
807 else
808 IMAGETYPE="png"
809 getmap_warning("IMAGETYPE not specified; using png as default!")
810 end
811 end
812
813 if COLOR == "" then
814 if MODE == "gm" then
815 COLOR="blue"
816 getmap_warning("COLOR not specified; using blue as default!")
817 elseif MODE == "osm" then
818 COLOR="yellow_1"
819 getmap_warning("COLOR not specified; using yellow_1 as default!")
820 end
821 end
822
823 if NUMBER == "" then
824 if MODE == "gsv" then
825 else
826 NUMBER=1
827 getmap_warning("NUMBER not specified; using 1 as default!")
828 end
829 end
830
831 if MODE == "gsv" then
832 if HEADING == "" then
833 HEADING=0
834 getmap_warning("HEADING not specified; using 0 as default!")
835 end
836
837 if FOV == "" then
838 FOV=90
839 getmap_warning("FOV not specified; using 90 as default!")
840 end
841
842 if PITCH == "" then
843 PITCH=0
844 getmap_warning("PITCH not specified; using 0 as default!")
845 end
846 end
847
848 if MODE == "gm" then
849 if ZOOM == "" then
850 ZOOM = 17
851 else
852 check_range(ZOOM,0,21,11,"ZOOM")
853 end
854 check_range(XSIZE,1,640,12,"XSIZE")
855 check_range(YSIZE,1,640,13,"YSIZE")
856 check_range(SCALE,1,2,14,"SCALE")
857 elseif MODE == "gsv" then
858 check_range(XSIZE,1,640,12,"XSIZE")
859 check_range(YSIZE,1,640,13,"YSIZE")
860 check_range(HEADING,0,360,15,"HEADING")
861 check_range(FOV,0,120,16,"FOV")
862 check_range(PITCH,-90,90,17,"PITCH")
863 elseif MODE == "osm" then
864 check_range(XSIZE,1,3840,11,"XSIZE")
865 check_range(YSIZE,1,3840,12,"YSIZE")
866 if ZOOM == "" then
867 check_range(SCALE,1692,221871572,13,"SCALE")
868 else
869 check_range(ZOOM,1,18,14,"ZOOM")
870 end
871 check_number(NUMBER,"NUMBER")
872 end
873
874 local UKEY = ""
875 local ULOCATION = ""
876 local UZOOM = ""
877 local USCALEZOOM = ""
878 local UMARKERS = ""
879 local USIZE = ""
880 local USCALE = ""
881 local UTYPE = ""
882 local USHOWICON = ""
883 local UIMAGETYPE = ""
884 local UVISIBLE = ""
885 local UIPATH = ""
886 local UFPATH = ""
887 local EPLFILE = ""
888 local UHEADING = ""
889 local UFOV = ""
890 local UPITCH = ""
891 local ULANGUAGE = ""
892 local UOFILE = ""
893 local IMGURL = ""
894
895 if MODE == "gm" then
896 ULOCATION = "center=" .. url_escape(LOCATION)
897 if MARKERS == "" then
898 UMARKERS = "&markers=size:mid|color:" .. COLOR .. "|label:" .. NUMBER .. "|" .. url_escape(LOCATION)
899 UZOOM = "&zoom=" .. url_escape(ZOOM)
900 else
901 UMARKERS = "" .. url_escape(MARKERS)
902 -- correct cruft escaping of "&markers="
903 UMARKERS = UMARKERS:gsub("%%26markers%%3d","&markers=")
904 UZOMM = ""
905 if CENTER == "" then
906 ULOCATION = ""
907 else
908 ULOCATION = "center=" .. url_escape(CENTER)
909 end
910 end
911 USIZE = "&size=" .. url_escape(SIZE)
912 USCALE = "&scale=" .. url_escape(SCALE)
913 UTYPE = "&maptype=" .. url_escape(TYPE)
914 UIMAGETYPE = "&format=" .. url_escape(IMAGETYPE)
915 if IMAGETYPE == "jpg-baseline" then
916 IMAGETYPE = "jpg"
917 end
918 if VISIBLE == "" then
919 UVISIBLE = ""
920 else
921 UVISIBLE = "&visible=" .. url_escape(VISIBLE)
922 end
923 if IPATH == "" then
924 UIPATH = ""
925 else
926 UIPATH = "" .. url_escape(IPATH)
927 -- correct cruft escaping of "&path="
928 UIPATH = UIPATH:gsub("%%26path%%3d","&path=")
929 end
930 if FPATH == "" then
931 UFPATH = ""
932 else
933 EPLFILE = io.open(FPATH, "r")
934 local contents = EPLFILE:read()
935 EPLFILE:close()
936 UFPATH = "" .. url_escape(contents)
937 -- correct cruft escaping of "&path="
938 UFPATH = UFPATH:gsub("%%26path%%3d","&path=")
939 end
940 if LANGUAGE == "" then
941 ULANGUAGE=""
942 else
943 ULANGUAGE="&language=" .. LANGUAGE
944 end
945 UOFILE = OFILE .. "." .. IMAGETYPE
946 IMGURL = GMURL .. "?" .. ULOCATION .. USIZE .. UZOOM .. UMARKERS .. UTYPE .. USCALE .. UIMAGETYPE .. UVISIBLE .. UIPATH .. UFPATH .. ULANGUAGE .. "&sensor=false&key=AIzaSyDXlmAP7TENopGqgCkW9Ec3Wymno3a2cBg"
947 elseif MODE == "gsv" then
948 ULOCATION = "location=" .. url_escape(LOCATION)
949 USIZE = "&size=" .. url_escape(SIZE)
950 UHEADING = "&heading=" .. url_escape(HEADING)
951 UFOV = "&fov=" .. url_escape(FOV)
952 UPITCH = "&pitch=" .. url_escape(PITCH)
953 UOFILE = OFILE .. ".jpg"
954 IMGURL = GSVURL .. "?" .. ULOCATION .. USIZE .. UHEADING .. UFOV .. UPITCH .. "&sensor=false&key=AIzaSyDXlmAP7TENopGqgCkW9Ec3Wymno3a2cBg"
955 elseif MODE == "osm" then
956 UKEY = "?key=" .. url_escape(KEY)
957 ULOCATION = "&location=" .. url_escape(LOCATION)
958 USIZE = "&size=" .. url_escape(SIZE)
959 if ZOOM == "" then
960 USCALEZOOM = "&scale=" .. url_escape(SCALE)
961 else
962 USCALEZOOM = "&zoom=" .. url_escape(ZOOM)
963 end
964 UTYPE = "&type=" .. url_escape(TYPE)
965 UIMAGETYPE = "&imagetype=" .. url_escape(IMAGETYPE)
966 USHOWICON = "&showicon=" .. url_escape(COLOR) .. "-" .. url_escape(NUMBER)
967 UOFILE = OFILE .. "." .. IMAGETYPE
968 IMGURL = OSMURL .. UKEY .. ULOCATION .. USIZE .. USCALEZOOM .. UTYPE .. UIMAGETYPE .. USHOWICON
969 end
970
971 local ret, msg
972 local ofile
973 ofile, msg = io.open(UOFILE, "wb")
974 if not ofile then
975 getmap_error(21, msg)
976 end
977 print("\n\ngetmapdl.lua:")
978 print("url = " .. IMGURL)
979 print("url length = " .. string.len(IMGURL) .. " bytes")
980 print("output = " .. UOFILE)
981 if string.len(IMGURL) > 2048 then
982 getmap_error(23, "URL exceeds length limit of 2048 bytes!")
983 end
984 ret, msg = http.request{
985 url = IMGURL,
986 sink = ltn12.sink.file(ofile)
987 }
988 if not ret then
989 getmap_error(22, msg)
990 end
991 os.exit(0)
992 %</luafile>
993 %<*cfgfile>
994 % \iffalse
995 %%
996 %%
997 %% copy this file to your local or home tree
998 %% and put it under TEXMF/tex/latex/getmap
999 %% run texhash afterwards
1000 %%
1001 %%
1002 % \fi
1003 \gdef\GM@JK@key{Fmjtd|luur20u22d,75=o5-9aylh6}%
1004 %</cfgfile>
1005 %<*examplefile>
1006 % \iffalse
1007 %%
1008 %%
1009 %% compile with pdflatex -shell-escape getmap-example
1010 %%
1011 %%
1012 % \fi
1013 \documentclass{article}
1014 \usepackage{graphicx}
1015 \usepackage{filecontents}
1016 % \iffalse
1017 %% use overwrite while optimizing the image
1018 % \fi
1019 \usepackage[overwrite,mode=gm]{getmap}
1020 \begin{document}
1021 \begin{filecontents*}{muc.epl}
1022 &path=weight:5|color:orange|enc:okydHa}peAXOHi@jANv@A@kJJmFAiDJuAHmDXcBb@cC`@gC^_DV}CJaCF{APaBVkBdAyEf@qC`@{B\aDSwB
1023 \end{filecontents*}
1024 \getmap[file=muc,
1025 markers={&markers=size:mid|label:H|color:green|München, Hbf
1026 &markers=label:S|color:yellow|Stachus, München
1027 &markers=label:M|color:blue|Marienplatz, München},
1028 pathfile={muc.epl}]{}
1029 \includegraphics[width=10cm]{muc}
1030 \end{document}
1031 %</examplefile>
1032 %<*manifest>
1033 This work consists of the following files:
1034
1035 getmap.pdf
1036 getmap.dtx
1037 README
1038 makefile
1039 install.bat
1040
1041 Files packaged in getmap.dtx:
1042
1043 getmap.sty
1044 getmap.cfg
1045 getmap-example.tex
1046 getmapdl.lua
1047 manifest.txt
1048 %</manifest>
1049 %<*internal>
1050 \fi
1051 \def\nameofplainTeX{plain}
1052 \ifx\fmtname\nameofplainTeX\else
1053 \expandafter\begingroup
1054 \fi
1055 %</internal>
1056 %<*install>
1057 \input docstrip.tex
1058 \keepsilent
1059 \askforoverwritefalse
1060 \preamble
1061
1062 Copyright (C) 2014,2016,2018 by:
1063 Josef Kleber
1064 <[email protected]>
1065
1066 This file may be distributed and/or modified under the conditions of
1067 the LaTeX Project Public License, either version 1.3 of this license
1068 or (at your option) any later version. The latest version of this
1069 license is in:
1070
1071 http://www.latex-project.org/lppl.txt
1072
1073 and version 1.3 or later is part of all distributions of LaTeX version
1074 2003/12/01 or later.
1075
1076 This work has the LPPL maintenance status "author-maintained".
1077
1078 The Current Maintainer of this work is Josef Kleber.
1079
1080 This work consists of all files listed in manifest.txt.
1081
1082 \endpreamble
1083
1084 \usedir{tex/latex/getmap}
1085 \generate{
1086 \file{\jobname.sty}{\from{\jobname.dtx}{package}}
1087 }
1088 \generate{
1089 \file{\jobname.cfg}{\from{\jobname.dtx}{cfgfile}}
1090 }
1091 \generate{
1092 \file{\jobname-example}{\from{\jobname.dtx}{examplefile}}
1093 }
1094 %</install>
1095 %<install>\endbatchfile
1096 %<*internal>
1097 \usedir{source/latex/getmap}
1098 \generate{
1099 \file{\jobname.ins}{\from{\jobname.dtx}{install}}
1100 }
1101 \nopreamble\nopostamble
1102 \usedir{doc/latex/getmap}
1103 \generate{
1104 \file{README.md}{\from{\jobname.dtx}{readme}}
1105 }
1106 \generate{
1107 \file{manifest.txt}{\from{\jobname.dtx}{manifest}}
1108 }
1109 \generate{
1110 \file{\jobname.bib}{\from{\jobname.dtx}{bibfile}}
1111 }
1112 \generate{
1113 \file{getmapdl.lua}{\from{\jobname.dtx}{luafile}}
1114 }
1115 \ifx\fmtname\nameofplainTeX
1116 \expandafter\endbatchfile
1117 \else
1118 \expandafter\endgroup
1119 \fi
1120 %</internal>
1121 %<*driver>
1122 \documentclass[a4paper]{ltxdoc}%
1123 \usepackage[english]{babel}%
1124 \usepackage[utf8]{inputenc}%
1125 \usepackage[T1]{fontenc}%
1126 \usepackage{textcomp}%
1127 \usepackage{lmodern}%
1128 \usepackage{bera}%
1129 \usepackage[svgnames,rgb]{xcolor}%
1130 \usepackage{makeidx}
1131 \usepackage{ragged2e}
1132 \usepackage{ccicons}
1133 \usepackage{csquotes}
1134 \usepackage{tabularx}
1135 \usepackage{microtype}%
1136 \usepackage{listings}
1137 \usepackage{filecontents}
1138 \usepackage{nicefrac}
1139 \usepackage{tcolorbox}
1140 \usepackage[numbered]{hypdoc}
1141 \usepackage{marginnote}%
1142 \usepackage[automark,nouppercase]{scrpage2}
1143 \usepackage[tocgraduated]{tocstyle}
1144 \usetocstyle{classic}
1145 \usepackage[overwrite=true]{getmap}
1146 \usepackage{attachfile}
1147 \usepackage{metalogo}
1148 \usepackage{tikz}
1149 % turn off idiotic tikz error in doc generation
1150 \makeatletter
1151 \global\let\tikz@ensure@dollar@catcode=\relax
1152 \makeatother
1153 \usepackage{hyperref}
1154 \EnableCrossrefs
1155 \CodelineIndex
1156 \RecordChanges
1157 \makeatletter
1158 \setlength{\headheight}{1.1\baselineskip}%
1159 \renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
1160 {-2.5ex\@plus -1ex \@minus -.25ex}%
1161 {1.25ex \@plus .25ex}%
1162 {\normalfont\normalsize\bfseries}}
1163 \setcounter{secnumdepth}{5}
1164 \setcounter{tocdepth}{5}
1165 \hypersetup{colorlinks=true,urlcolor=NavyBlue,linkcolor=NavyBlue,citecolor=CornflowerBlue}%
1166 \lstset{literate=%
1167 {Ö}{{\"O}}1
1168 {Ä}{{\"A}}1
1169 {Ü}{{\"U}}1
1170 {ß}{{\ss}}1
1171 {ü}{{\"u}}1
1172 {ä}{{\"a}}1
1173 {ö}{{\"o}}1
1174 {~}{{\textasciitilde}}1
1175 }
1176 \lstset{language=[LaTeX]TeX,numbers=left,numberstyle=\tiny, basicstyle=\ttfamily, aboveskip=\baselineskip, frame=single, backgroundcolor=\color{LightGoldenrodYellow}, keywordstyle=\color{Blue},
1177 emph={}}
1178 \renewcommand{\maketitle}%
1179 {%
1180 \thispagestyle{empty}%
1181 \pagecolor{Ivory}%
1182 \begin{titlepage}%
1183 \begin{tikzpicture}[remember picture,overlay]%
1184 \node[yshift=-2cm] at (current page.north west)%
1185 {%
1186 \begin{tikzpicture}[remember picture, overlay]%
1187 \draw[fill=CornflowerBlue,color=CornflowerBlue] (0,0) rectangle%
1188 (\paperwidth,2cm);%
1189 \draw[anchor=west,yshift=-4cm,xshift=3cm,color=NavyBlue] (0,0) node%
1190 {\parbox{15cm}{\RaggedRight\Huge\sffamily\textbf{\@title}}};%
1191 \draw[anchor=west,yshift=-6cm,xshift=3cm,color=NavyBlue] (0,0) node%
1192 {\parbox{15cm}{\huge\sffamily\textbf{\@fileversion}}};%
1193 \draw[anchor=west,yshift=-9cm,xshift=3cm,color=NavyBlue] (0,0) node%
1194 {\parbox{15cm}{\RaggedRight\huge\sffamily\textbf{\@subtitle}}};%
1195 \draw[anchor=west,yshift=-14cm,xshift=3cm,color=NavyBlue] (0,0) node%
1196 {\includegraphics[width=8cm]{getmap.png}};%
1197 \draw[anchor=west,yshift=-18cm,xshift=3cm,color=NavyBlue] (0,0) node%
1198 {\parbox{15cm}{\huge\sffamily\textbf{\@date}}};%
1199 \draw[anchor=west,yshift=-20cm,xshift=3cm,color=NavyBlue] (0,0) node%
1200 {\parbox{15cm}{\Large\sffamily{\@authorline\\\textbf{\@author}}}};%
1201 \end{tikzpicture}%
1202 };%
1203 \node[yshift=0cm] at (current page.south west)%
1204 {%
1205 \begin{tikzpicture}[remember picture, overlay]%
1206 \draw[fill=NavyBlue,color=NavyBlue,yshift=6cm,xshift=2cm] (0,0) rectangle (0.2cm,19cm);%
1207 \draw[fill=CornflowerBlue,color=CornflowerBlue] (0,0) rectangle (\paperwidth,2cm);%
1208 \draw[anchor=west,yshift=1cm,xshift=3cm,color=NavyBlue] (0,0) node%
1209 {\parbox{15cm}{\large\sffamily{\@refline}}};%
1210 \end{tikzpicture}%
1211 };%
1212 \end{tikzpicture}%
1213 \end{titlepage}%
1214 \pagecolor{white}%
1215 }%
1216 %
1217 \newcommand*{\@tikzhead}[1]%
1218 {%
1219 \begin{tikzpicture}[remember picture,overlay]%
1220 \node[yshift=-2cm] at (current page.north west)%
1221 {%
1222 \begin{tikzpicture}[remember picture, overlay]%
1223 \draw[fill=CornflowerBlue] (0,0) rectangle (\paperwidth,2cm);%
1224 \draw[anchor=west,yshift=1cm,xshift=1.5cm,color=NavyBlue] (0,0) node%
1225 {\parbox{15cm}{\LARGE\sffamily\textbf{\@title}}};%
1226 \node[anchor=east,xshift=.9\paperwidth,rectangle,%
1227 rounded corners=15pt,inner sep=11pt,fill=NavyBlue]%
1228 {\color{white}\textsc{#1}};%
1229 \end{tikzpicture}%
1230 };%
1231 \end{tikzpicture}%
1232 }%
1233 \clearscrheadings%
1234 \ihead{\@tikzhead{\headmark}}%
1235 \cfoot{\upshape\thepage}%
1236 \pagestyle{scrheadings}%
1237 %
1238 \newcommand*{\Headline}[1]{\@mkboth{#1}{#1}}%
1239 %
1240 \renewcommand{\headfont}{\normalfont\mdseries\scshape}
1241 %
1242 \gdef\@subtitle{}%
1243 \providecommand*{\Subtitle}[1]{\gdef\@subtitle{#1}}%
1244 \gdef\@fileversion{}%
1245 \providecommand*{\Fileversion}[1]{\gdef\@fileversion{#1}}%
1246 \gdef\@author{}%
1247 \providecommand*{\Author}[1]{\gdef\@author{#1}}%
1248 \gdef\@authorline{Package author:}%
1249 \providecommand*{\Authorline}[1]{\gdef\@authorline{#1}}%
1250 \gdef\@refline{}%
1251 \providecommand*{\Refline}[1]{\gdef\@refline{#1}}%
1252 \gdef\and{\unskip{}, }%
1253 \newcommand\doubledash{-\kern0.5pt-}
1254 \def\enoteformat{\rightskip\z@ \leftskip\z@ \parindent=1em\leavevmode\llap{\makeenmark}}
1255 \def\XeLaTeX{Xe\LaTeX}%
1256 %
1257 \newenvironment{optionlist}
1258 {\begin{trivlist}\setlength\leftskip{2em}}
1259 {\end{trivlist}}
1260 \newcommand\optitem[3]{\item [\texttt{\textbf{\textcolor{DodgerBlue}{#1}} \lbrack\textcolor{Crimson}{#2}\rbrack}] #3}
1261 \renewcommand\tableofcontents%
1262 {%
1263 %\section*{\contentsname}%
1264 \@mkboth{%
1265 \MakeUppercase\contentsname}{\MakeUppercase\contentsname}%
1266 \@starttoc{toc}%
1267 }%
1268 %
1269 \newcommand\env[1]{\texttt{#1}}%
1270 \newcommand\layer[1]{\texttt{#1}\SortIndex{#1}{\texttt{#1} (PGF layer)}%
1271 \SortIndex{PGF layer>#1}{\texttt{#1}}}%
1272 \newcommand\styleoption[1]{\texttt{#1}\SortIndex{#1}{\texttt{#1} (Style option)}%
1273 \SortIndex{Style option>#1}{\texttt{#1}}}%
1274 \newcommand\envoption[1]{\texttt{#1}\SortIndex{#1}{\texttt{#1} (Puzzle option)}%
1275 \SortIndex{Puzzle option>#1}{\texttt{#1}}}%
1276 \newcommand\stylename[1]{\texttt{#1}\SortIndex{#1}{\texttt{#1} (Style file)}%
1277 \SortIndex{Style file>#1}{\texttt{#1}}}%
1278 \newcommand\package[1]{\texttt{#1}\SortIndex{#1}{\texttt{#1} (Package)}%
1279 \SortIndex{Package>#1}{\texttt{#1}}}%
1280 \newcommand*\margcs[1]{\marginnote{\hbadness=10000\RaggedLeft\scriptsize #1}}%
1281 \def\PrintIndex{\clearpage\Headline{Index}\@input@{\jobname.ind}%
1282 \global\let\PrintIndex\@empty}
1283 \renewenvironment{theindex}
1284 {\if@twocolumn
1285 \@restonecolfalse
1286 \else
1287 \@restonecoltrue
1288 \fi
1289 \columnseprule \z@
1290 \columnsep 35\p@
1291 \def\see##1##2{\textit{See} ##1}%
1292 \def\seealso##1##2{\textit{See also} ##1}%
1293 \long\def\cmd##1{\cs{\expandafter\cmd@to@cs\string##1}}%
1294 \def\@url##1{\url@break\ttt{##1}\endgroup}%
1295 \def\ttt{\begingroup\@sanitize\ttfamily\@ttt}%
1296 \def\@ttt##1{##1\endgroup}%
1297 \mathchardef\save@secnumdepth\c@secnumdepth
1298 \c@secnumdepth\m@ne
1299 \phantomsection%
1300 \twocolumn%[\section{\indexname}]%
1301 \refstepcounter{section}
1302 \addcontentsline{toc}{section}{\protect\numberline{\thesection}Index}%
1303 \c@secnumdepth\save@secnumdepth
1304 %\thispagestyle{plain}
1305 \parindent\z@
1306 \parskip\z@ \@plus .3\p@\relax
1307 \let\item\@idxitem}
1308 {\if@restonecol\onecolumn\else\clearpage\fi}
1309 \setlength\parindent{0pt}%
1310 \newcommand*\myref[1]{[see: \ref{#1} on page \pageref{#1}]}
1311 \tcbuselibrary{hooks}
1312 \newtcolorbox{gmbox}{colback=yellow,colframe=red!75!black,fonttitle=\bfseries,colbacktitle=red!85!black,title=Note,halign=left,box align=center}
1313 \makeatother
1314 \begin{document}
1315 \DocInput{\jobname.dtx}
1316 \end{document}
1317 %</driver>
1318 % \fi
1319 %
1320 %\getmap{Bergheimer Straße 110A, 69115 Heidelberg, Germany}
1321 %\GetFileInfo{\jobname.sty}
1322 %\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}%
1323 %\lstset{language=[LaTeX]TeX,numbers=left,numberstyle=\tiny, basicstyle=\ttfamily, aboveskip=\baselineskip, frame=single, backgroundcolor=\color{LightGoldenrodYellow}, keywordstyle=\color{Blue},
1324 %emph={},emphstyle=\color{Tomato},
1325 %emph={[2]width,xsize,ysize,zoom,scale,mode,file,type,heading,pitch,fov,markers,visible,path,pathfile},emphstyle={[2]\color{OliveDrab}},
1326 %morekeywords={getmap,includegraphics}}
1327 %\DoNotIndex{\,,\begingroup,\endgroup,\csname,\def,\else,\endcsname,\equal,\expandafter,\write,
1328 %\fi,\gdef,\ifnum,\ifthenelse,\immediate,\MessageBreak,\NeedsTeXFormat,\newcommand,\newif,
1329 %\PackageInfo,\PackageError,\ProcessOptionsX,\ProvidesPackage,\relax,\RequirePackage,
1330 %\space,\errmessage,\ExecuteOptionsX,}
1331 %
1332 % \bibliographystyle{plain}
1333 % \title{\filename}%
1334 % \Subtitle{Downloading maps from OpenStreetMap, Google Maps or Google Street View}%
1335 % \author{Josef Kleber}
1336 % \Fileversion{\fileversion}
1337 % \date{\filedate}
1338 % \Refline{\href{mailto:[email protected]}{\texttt{[email protected]}}\\\href{http://getmap.jklatex.de/}{\texttt{http://getmap.jklatex.de/}}}
1339 % \maketitle
1340 % \stepcounter{page}
1341 % \tableofcontents
1342 % \clearpage
1343 % \setlength\parskip{6pt}%
1344 %
1345 %
1346 %\StopEventually{^^A
1347 % {
1348 % \clearpage
1349 % \raggedright
1350 % \nocite{*}
1351 % \bibliography{getmap}
1352 % }
1353 % \clearpage
1354 % \PrintChanges
1355 % \PrintIndex
1356 %}
1357 %
1358 % \Headline{Abstract}
1359 % \begin{abstract}
1360 % The goal of this package is the simplest possible provision of
1361 % map images (OpenStreetMap, Google Maps and Google Street View
1362 % are supported). In the simplest case, it is is sufficient
1363 % to specify an address. The package loads the map using the
1364 % \cmd\write18 feature, which you must activate to use this package.
1365 % The image will be downloaded by an external Lua script. You can
1366 % use this script also from the command line.
1367 % \end{abstract}
1368 % \vfill
1369 % \renewcommand*{\abstractname}{Acknowledgment}
1370 % \begin{abstract}
1371 % I want to thank Norbert Preining, who did most of the recoding of \texttt{osmimage}
1372 % (\texttt{Bash} $\rightarrow$ \texttt{Lua}). Moreover many thanks to Taco Hoekwater, Akira Kakuto,
1373 % Reinhard Kotucha and Heiko Oberdiek for their valuable contributions.
1374 % Finally, I want to thank Doug Currie for helping me to implement the algorithm
1375 % for encoded polylines in Lua.
1376 % \end{abstract}
1377 % \clearpage
1378 % \section{Options}
1379 % The following options can be used as package options with global scope,
1380 % as well as options for the \cmd\getmap\ command with local scope!
1381 % \subsection{General options}
1382 % \subsubsection[\texttt{mode}]{\texttt{mode (\underline{osm}\textbar{}gm\textbar{}gsv})}
1383 % This option sets the mode, that is the source of the images. OpenStreetMap, Google Maps or Google Street View!
1384 % Please note that -- if used as local option (mixed modes) -- the default values of the \texttt{scale}, \texttt{zoom}, \texttt{type} and \texttt{color}
1385 % options for the respective mode are reset to guarantee correct download URLs!
1386 % \subsubsection[\texttt{inputencoding}]{\texttt{inputencoding}}
1387 % This option specifies the input encoding of your file.
1388 % The download script requires the strings encoded in utf8.
1389 % For the safe conversion the input encoding of the file is required.
1390 % Normally, you don't have to specify an encoding.
1391 % The package tries to evaluate the encoding given to \package{inputenc} or assumes utf8.
1392 % Usually that should work.
1393 % \subsubsection[\texttt{overwrite}]{\texttt{overwrite (\underline{false}\textbar{}true)}}
1394 % With this option, you can specify whether the image should be downloaded in any case.
1395 % By default, the option is set to \texttt{false} in order to save bandwidth and compilation time.
1396 % Nevertheless a check is performed on the existence of the image and the
1397 % image will be downloaded, if it is not present.
1398 % In the case of \texttt{true}, the image will be downloaded anyway!
1399 % BTW, \texttt{overwrite} is equivalent to \texttt{overwrite=true}.
1400 % \subsubsection[\texttt{file}]{\texttt{file (\underline{getmap})}}
1401 % This \marginpar{\begin{gmbox}changed default value to \texttt{getmap} in version 1.2!\end{gmbox}}
1402 % option allows you to specify the name of the image (without extension).
1403 % \subsection{\texttt{osm} mode}
1404 % \subsubsection[\texttt{key}]{\texttt{key (\underline{Fmjtd\textbar{}luur20u22d,75=o5-9aylh6}})}
1405 % In \texttt{osm} mode, the download script requires a key in order to use the service of MapQuest.
1406 % By default, it uses a key, which is registered for \package{getmap}.
1407 % But you can register and use your own key with this option.
1408 % The default key is stored in \texttt{getmap.cfg}. You can copy this file to your local \TeX\ tree
1409 % and store your own key there\footnote{Mapquest will deliver an url-encoded key, which must
1410 % be decoded to ASCII, e.g. by \href{http://urldecode.org/}{Url decode}}!
1411 % This file will be found after running \texttt{texhash}!
1412 % \subsubsection[\texttt{scale}]{\texttt{scale (\underline{3385}})}
1413 % This option allows you to specify a display scale for the map image in the range of
1414 % 1692 -- 221871572. You will not necessarily see a difference between 5000 and 5500.
1415 % A scale value of 3385 corresponds to a zoom level of 17.
1416 % \subsubsection[\texttt{zoom}]{\texttt{zoom}}
1417 % This option allows you to specify a zoom level in the range of 1 -- 18.
1418 % This option overwrites a possibly given scale.
1419 % \subsubsection[\texttt{xsize}]{\texttt{xsize (\underline{600})}}
1420 % This option specifies the width of the map in pixels.
1421 % If \marginpar{\begin{gmbox}changed default value to \texttt{600} in version 1.2!\end{gmbox}}
1422 % you only want to slightly increase or decrease the map extract,
1423 % you should adjust the size of the map. You still have full control over the size of
1424 % the map in the document with the options of \cmd\includegraphics. (max: 3840)
1425 % \subsubsection[\texttt{ysize}]{\texttt{ysize (\underline{400})}}
1426 % This option specifies the height of the map in pixels. (max: 3840)
1427 % \subsubsection[\texttt{imagetype}]{\texttt{imagetype (\underline{png}\textbar{}jpeg\textbar{}jpg\textbar{}gif)}}
1428 % This option allows you to specify the type of the image.
1429 % \subsubsection[\texttt{type}]{\texttt{type (\underline{map}\textbar{}sat\textbar{}hyb)}}
1430 % This option specifies the type of the map.
1431 % It seems as if there would be only a few regions of Mother Earth,
1432 % for which satellite and hybrid images are available.
1433 % \subsubsection[\texttt{color}]{\texttt{color (\underline{yellow\_1})}}
1434 % This option specifies the color of the marker. Possible colors:
1435 %
1436 % \href{http://open.mapquestapi.com/staticmap/icons.html}{http://open.mapquestapi.com/staticmap/icons.html}
1437 % \subsubsection[\texttt{number}]{\texttt{number (\underline{1})}}
1438 % This option specifies the number of the marker.
1439 % \subsection{\texttt{gm} mode}
1440 % From 2018 on, Google Maps APIs are no longer accessible without a key.
1441 % Since \texttt{getmap.sty} is an open source project, it is impossible to finance an infinite number of requests, but Google allows a limited number of requests for \enquote{free}.
1442 % As a consequence, the following restrictions arise:
1443 %
1444 % \begin{tabular}{rl}
1445 % Google Maps & 2000 requests per day \\
1446 % Google Street View & 1000 requests per day
1447 % \end{tabular}
1448 % \subsubsection[\texttt{scale}]{\texttt{scale (\underline{1})}}
1449 % For the free version of Google Maps the image size is limited to 640x640.
1450 % You can set \texttt{scale} to a value of 2, to get exactly the same map in doubled size in pixels.
1451 % \subsubsection[\texttt{zoom}]{\texttt{zoom} (\underline{17})}
1452 % This option allows you to specify a zoom level in the range of 0 -- 21.
1453 % \subsubsection[\texttt{xsize}]{\texttt{xsize (\underline{600})}}
1454 % This option specifies the width of the map in pixels.
1455 % If you only want to slightly increase or decrease the map extract,
1456 % you should adjust the size of the map. You still have full control over the size of
1457 % the map in the document with the options of \cmd\includegraphics. (max: 640)
1458 % \subsubsection[\texttt{ysize}]{\texttt{ysize (\underline{400})}}
1459 % This option specifies the height of the map in pixels. (max: 640)
1460 % \subsubsection[\texttt{imagetype}]{\texttt{imagetype (\underline{png}\textbar{}png8\textbar{}
1461 % png32\textbar{}gif\textbar{}jpg} (progressive)\texttt{\textbar{}jpg-baseline} (flat))}
1462 % This option allows you to specify the type of the image.
1463 % \subsubsection[\texttt{type}]{\texttt{type (\underline{roadmap}\textbar{}satellite\textbar{}hybrid\textbar{}terrain)}}
1464 % This option specifies the type of the map.
1465 % \subsubsection[\texttt{color}]{\texttt{color (\underline{blue})}}
1466 % This option specifies the color of the marker. Possible colors:
1467 %
1468 % black, brown, green, purple, yellow, blue, gray, orange, red, white or in hex format \texttt{0x3399FF}
1469 % \subsubsection[\texttt{number}]{\texttt{number (\underline{1})}}
1470 % This option specifies the number of the marker. Google Maps also allows uppercase letters: [A-Z]!
1471 % \subsubsection[\texttt{language}]{\texttt{language} (\underline{en})}
1472 % This option specifies the language of the map labels.
1473 % Of course, not all languages are supported for all countries.
1474 % At least, english and one of the national languages should be supported.
1475 % Possible option values: en, de, fr, es, it, fi, ...
1476 % \subsubsection{\texttt{markers}}
1477 % This option allows you to set more than just the standard marker, which will no longer be used!
1478 % You don't have to specify an address, as Google Maps will deliver an image with all markers on the map.
1479 % Nevertheless, you can specify an address, which will define the center of the map.
1480 % This option expects one or more URL parameters like:
1481 %
1482 % \texttt{\&markers=size:mid\textbar{}color:blue\textbar{}label:S\textbar{}loc1\textbar{}loc2\textbar{}...}
1483 %
1484 % \getmap[file=bmus1, mode=gm,
1485 % markers={&markers=size:mid|label:B|color:green|52.521847,13.394398%
1486 % &markers=label:P|color:green|Pergamonmuseum, Berlin%
1487 % &markers=label:N|color:blue|52.520063,13.397525}%
1488 % ]{}
1489 % \begin{center}\includegraphics[width=10cm]{bmus1}\end{center}
1490 % \clearpage
1491 % \iffalse
1492 %<*example>
1493 % \fi
1494 \begin{lstlisting}
1495 \getmap[
1496 file=bmus1, mode=gm,
1497 markers={&markers=size:mid|label:B|color:green|52.521847,13.394398%
1498 &markers=label:P|color:green|Pergamonmuseum, Berlin%
1499 &markers=label:N|color:blue|52.520063,13.397525}%
1500 ]{}
1501 \includegraphics[width=10cm]{bmus1}
1502 \end{lstlisting}
1503 % \iffalse
1504 %</example>
1505 % \fi
1506 % Earlier versions of this document used POIs for all museums.
1507 % After an update from Google Maps, the quality of the geo codings deteriorated, at least in this example from Berlin.
1508 % Using addresses or geographical coordinates usually solves this problem.
1509 % See \cite{bib:texsx} for more information.
1510 %
1511 % The parameters size, color and label are optional!
1512 % \begin{description}
1513 % \item[size] tiny, \underline{mid}, small
1514 % \item[color] \underline{red}, black, brown, green, purple, yellow, blue, gray, orange, white, 0x1188FF
1515 % \item[label] [0-9][A-Z] (only in mid size!)
1516 % \end{description}
1517 % The default is a mid-sized red bubble with a black point!
1518 % \subsubsection{\texttt{visible}}
1519 % With this option you can specify a list of locations (separated by a pipe), which must be on the map!
1520 %
1521 % \getmap[file=bmus2, mode=gm,
1522 % markers={&markers=size:mid|label:B|color:green|52.521847,13.394398
1523 % &markers=label:P|color:green|Pergamonmuseum, Berlin
1524 % &markers=label:N|color:blue|52.520063,13.397525},
1525 % visible={Brandenburger Tor, Berlin|Reichstagsufer 1, Berlin}]{}
1526 % \begin{center}\includegraphics[width=10cm]{bmus2}\end{center}
1527 % \clearpage
1528 % \iffalse
1529 %<*example>
1530 % \fi
1531 \begin{lstlisting}
1532 \getmap[
1533 file=bmus2, mode=gm
1534 markers={&markers=size:mid|label:B|color:green|52.521847,13.394398%
1535 &markers=label:P|color:green|Pergamonmuseum, Berlin%
1536 &markers=label:N|color:blue|52.520063,13.397525},%
1537 visible={Brandenburger Tor, Berlin|Reichstagsufer 1, Berlin}]{}
1538 \includegraphics[width=10cm]{bmus2}
1539 \end{lstlisting}
1540 % \iffalse
1541 %</example>
1542 % \fi
1543 % \subsubsection{\texttt{path}}
1544 % With this option you can define one or more paths! It expects one or more URL parameters like:
1545 %
1546 % \texttt{\&path=weight:5\textbar{}color:orange\textbar{}loc1\textbar{}loc2\textbar{}...}
1547 %
1548 % \iffalse
1549 %<*example>
1550 % \fi
1551 \begin{lstlisting}
1552 \getmap[file=bmus3, mode=gm, language=de,
1553 markers={&markers=size:mid|label:B|color:green|52.521847,13.394398%
1554 &markers=label:P|color:green|Pergamonmuseum, Berlin%
1555 &markers=label:N|color:blue|52.520063,13.397525},%
1556 path={&path=weight:5|color:orange|52.521847,13.394398|%
1557 Pergamonmuseum, Berlin|52.520063,13.397525|%
1558 James-Simon-Park,Berlin|52.522649,13.402523%
1559 &path=weight:5|color:purple|James-Simon-Park, Berlin|%
1560 Weinmeisterstraße 6, Berlin}]{}
1561 \includegraphics[width=10cm]{bmus3}
1562 \end{lstlisting}
1563 % \iffalse
1564 %</example>
1565 % \fi
1566 %
1567 % \getmap[file=bmus3, mode=gm, language=de,
1568 % markers={&markers=size:mid|label:B|color:green|52.521847,13.394398%
1569 % &markers=label:P|color:green|Pergamonmuseum, Berlin%
1570 % &markers=label:N|color:blue|52.520063,13.397525},%
1571 % path={&path=weight:5|color:orange|52.521847,13.394398|%
1572 % Pergamonmuseum, Berlin|52.520063,13.397525|%
1573 % James-Simon-Park,Berlin|52.522649,13.402523%
1574 % &path=weight:5|color:purple|James-Simon-Park, Berlin|%
1575 % Weinmeisterstraße 6, Berlin}]{}
1576 % \begin{center}\includegraphics[width=10cm]{bmus3}\end{center}
1577 %
1578 % You can also use \texttt{fillcolor} to mark areas! In paths, you
1579 % can also specify RGB32 colors, in which the last byte defines opacity,
1580 % e.g. 55 (33\%).
1581 % \iffalse
1582 %<*example>
1583 % \fi
1584 \begin{lstlisting}
1585 \getmap[file=cpny, mode=gm, zoom=13,
1586 path={&path=weight:2|color:orange|fillcolor:0xff641A55|
1587 40.764302, -73.973004|40.768044, -73.981903|%
1588 40.800642, -73.958193|40.796887, -73.949226|%
1589 40.764302, -73.973004}]{Central Park, New York}
1590 \includegraphics[width=10cm]{cpny}
1591 \end{lstlisting}
1592 % \iffalse
1593 %</example>
1594 % \fi
1595 %
1596 % \getmap[file=cpny, mode=gm, zoom=13,
1597 % path={&path=weight:2|color:orange|fillcolor:0xff641A55|
1598 % 40.764302, -73.973004|40.768044, -73.981903|%
1599 % 40.800642, -73.958193|40.796887, -73.949226|%
1600 % 40.764302, -73.973004}]{Central Park, New York}
1601 % \begin{center}\includegraphics[width=10cm]{cpny}\end{center}
1602 %
1603 % With small enough spaces between way points you can also defines routes!
1604 % \subsubsection{\texttt{pathfile}}
1605 % This option specifies the file holding the path specification. It will be loaded by the \texttt{Lua} script.
1606 % You can use the \env{filecontents*} environment to keep the definition in your document.
1607 % It should be a one line utf8-encoded file!
1608 % \subsection{\texttt{gsv} mode}
1609 % \subsubsection[\texttt{xsize}]{\texttt{xsize (\underline{600})}}
1610 % This option specifies the width of the map in pixels. (max: 640)
1611 % \subsubsection[\texttt{ysize}]{\texttt{ysize (\underline{400})}}
1612 % This option specifies the height of the map in pixels. (max: 640)
1613 % \subsubsection[\texttt{heading}]{\texttt{heading (\underline{0})}}
1614 % This option specifies the heading (direction) in degrees in the range of 0 -- 360. (0: north, 90: east, ...)
1615 % \subsubsection[\texttt{pitch}]{\texttt{pitch (\underline{0})}}
1616 % This option specifies the pitch (angle) of the camera view in degrees in the range of -90 -- 90.
1617 % \subsubsection[\texttt{fov}]{\texttt{fov (\underline{90})}}
1618 % This option specifies the field of horizontal view (kind of zoom) in degrees in the range of 0 -- 120.
1619 % \section{Command(s)}
1620 % \subsection[\textbackslash{}getmap]{\cmd\getmap}
1621 % With the \cmd\getmap\ command\margcs{\cmd\getmap\oarg{options}\marg{address}} you can download
1622 % a map, if you enable \cmd\write18 (TeXLive: \texttt{-shell-escape}, MiKTeX: \texttt{-{}-enable-write18}).
1623 % This is only necessary if you actually download an image.
1624 % You can use the options described above to specify the properties of the downloaded image.
1625 % After executing the command, the image is available in the current working directory!
1626 %
1627 % In the simplest case, you only need an address, a POI or geographic coordinates
1628 % (\texttt{latitude,longitude}) to download the map. \marg{address} must be fully expanded and must not contain macros!
1629 % By default, the image is saved under the name \texttt{getmap.png}!
1630 % If you need only one map (e.g. the office of Dante e.V.) in your document, it can be as simple as:
1631 %
1632 % \begin{center}\includegraphics[width=9cm]{getmap.png}\end{center}
1633 %
1634 % \iffalse
1635 %<*example>
1636 % \fi
1637 \begin{lstlisting}
1638 \getmap{Bergheimer Straße 110A, 69115 Heidelberg, Germany}
1639 \includegraphics[width=9cm]{getmap}
1640 \end{lstlisting}
1641 % \iffalse
1642 %</example>
1643 % \fi
1644 %
1645 % \clearpage
1646 % \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}}
1647 %
1648 % The same map as before from Google Maps:
1649 %
1650 % \getmap[file=dantegm,mode=gm]{Bergheimer Straße 110A, 69115 Heidelberg, Germany}
1651 % \begin{center}\includegraphics[width=9cm]{dantegm}\end{center}
1652 % \iffalse
1653 %<*example>
1654 % \fi
1655 \begin{lstlisting}
1656 \getmap[file=dantegm,mode=gm]{Bergheimer Straße 110A,%
1657 69115 Heidelberg, Germany}
1658 \includegraphics[width=9cm]{dantegm}
1659 \end{lstlisting}
1660 % \iffalse
1661 %</example>
1662 % \fi
1663 %
1664 % The same map as satellite image:
1665 %
1666 % \getmap[file=dantegmsat,mode=gm,type=satellite]{Bergheimer Straße 110A, 69115 Heidelberg, Germany}
1667 % \begin{center}\includegraphics[width=9cm]{dantegmsat}\end{center}
1668 % \iffalse
1669 %<*example>
1670 % \fi
1671 \begin{lstlisting}
1672 \getmap[file=dantegmsat,mode=gm,type=satellite]
1673 {Bergheimer Straße 110A, 69115 Heidelberg, Germany}
1674 \includegraphics[width=9cm]{dantegmsat}
1675 \end{lstlisting}
1676 % \iffalse
1677 %</example>
1678 % \fi
1679 % \clearpage
1680 % L'afrique, mon amour!
1681 %
1682 % \getmap[file=africa,mode=gm,type=terrain,xsize=500,ysize=500,scale=2,zoom=3]{0,16}
1683 % \begin{center}\includegraphics[width=9cm]{africa}\end{center}
1684 % \iffalse
1685 %<*example>
1686 % \fi
1687 \begin{lstlisting}
1688 \getmap[file=africa,mode=gm,type=terrain,xsize=500,ysize=500,%
1689 scale=2,zoom=3]{0,16}
1690 \includegraphics[width=9cm]{africa}
1691 \end{lstlisting}
1692 % \iffalse
1693 %</example>
1694 % \fi
1695 % L'amour, ...
1696 %
1697 % \getmap[file=paris,mode=gm,type=hybrid,xsize=500,ysize=300,scale=2,zoom=16]{Tour Eiffel, Paris}
1698 % \begin{center}\includegraphics[width=9cm]{paris}\end{center}
1699 % \iffalse
1700 %<*example>
1701 % \fi
1702 \begin{lstlisting}
1703 \getmap[file=paris,mode=gm,type=hybrid,xsize=500,ysize=300,%
1704 scale=2,zoom=16]{Tour Eiffel, Paris}
1705 \includegraphics[width=9cm]{paris}
1706 \end{lstlisting}
1707 % \iffalse
1708 %</example>
1709 % \fi
1710 % \clearpage
1711 % Street View now:
1712 %
1713 % \getmap[file=parisgsv,mode=gsv,heading=320,pitch=30,fov=40,xsize=300,ysize=600]{Avenue Piere-Loti, Paris}
1714 % \begin{center}\includegraphics[width=4cm]{parisgsv}\end{center}
1715 % \iffalse
1716 %<*example>
1717 % \fi
1718 \begin{lstlisting}
1719 \getmap[file=parisgsv,mode=gsv,heading=320,pitch=30,fov=40,%
1720 xsize=300,ysize=600]{Avenue Piere-Loti, Paris}
1721 \includegraphics[width=4cm]{parisgsv}
1722 \end{lstlisting}
1723 % \iffalse
1724 %</example>
1725 % \fi
1726 %
1727 % View from Olympic Tower Munich (Olympic Stadium and Park):
1728 %
1729 % \getmap[file=mucoly,mode=gsv,heading=260,pitch=-40,fov=90]{Olympiaturm}
1730 % \begin{center}\includegraphics[width=8cm]{mucoly}\end{center}
1731 % \iffalse
1732 %<*example>
1733 % \fi
1734 \begin{lstlisting}
1735 \getmap[file=mucoly,mode=gsv,heading=260,pitch=-40,fov=90]%
1736 {Olympiaturm}
1737 \includegraphics[width=8cm]{mucoly}
1738 \end{lstlisting}
1739 % \iffalse
1740 %</example>
1741 % \fi
1742 % \section{The \texttt{getmapdl} Lua script}
1743 % Basically, the \texttt{getmapdl} Lua script downloads static map images
1744 % depending on command line options and allows to parse \texttt{kml}, \texttt{gpx} and
1745 % \texttt{gps} (a plain list of geographical coordinate pairs \texttt{(latitude,longitude)}
1746 % on each line) files and outputs \texttt{gps} or encoded polylines (epl).
1747 % The script offers the following modes (\texttt{-m}):
1748 % \begin{description}
1749 % \item[osm] downloads a static map image based on OpenStreetMap data
1750 % \item[gm] downloads a static map image based on Google Maps data
1751 % \item[gsv] downloads an image based on Google Street View data
1752 % \item[kml2epl] parses a \texttt{kml} file and outputs geographical coordinates of places and
1753 % encoded polylines (\texttt{epl}) for routes and lines to \texttt{STDOUT}
1754 % \item[kml2gps] parses a \texttt{kml} file and outputs geographical coordinates
1755 % \item[gpx2epl] parses a \texttt{gpx} file and outputs encoded polylines
1756 % \item[gpx2gps] parses a \texttt{gpx} file and outputs a list of geographic coordinate pairs (\texttt{gps})
1757 % \item[gps2epl] parses a \texttt{gps} file and outputs \texttt{epl}
1758 % \item[gps2gps] parses a \texttt{gps} file and outputs -- based on a given bound -- a reduced list of \texttt{gps} coordinates
1759 % \end{description}
1760 % The first three modes are used by \cmd\getmap. You may use the script also from the command line!
1761 % \texttt{getmapdl -h} will give you a list of available commad line options.
1762 %
1763 % The other modes are usefull for creating encoded polylines (\texttt{epl}), which is
1764 % the route format of Google Maps. You can parse the following example from Google Maps in \texttt{gpx} format
1765 % \iffalse
1766 %<*example>
1767 % \fi
1768 \begin{lstlisting}
1769 <trkseg>
1770 <trkpt lon="-120.2" lat="38.5"/>
1771 <trkpt lon="-120.95" lat="40.7"/>
1772 <trkpt lon="-126.453" lat="43.252"/>
1773 </trkseg>
1774 \end{lstlisting}
1775 % \iffalse
1776 %</example>
1777 % \fi
1778 % with
1779 % \iffalse
1780 %<*example>
1781 % \fi
1782 \begin{lstlisting}
1783 $ getmapdl -m gpx2epl -G test.gpx
1784 _p~iF~ps|U_ulLnnqClqNvxq`@
1785
1786 \end{lstlisting}
1787 % \iffalse
1788 %</example>
1789 % \fi
1790 % This encoded polyline can be used for the \texttt{path} or \texttt{pathfile}
1791 % option of \cmd\getmap.
1792 % \section{How to define routes}
1793 % Routes are described by so called encoded polylines and can be used with
1794 % \texttt{enc:polyline\_data} as location specifier in a \texttt{path}.
1795 % This string can contain all sorts of troublesome characters for \LaTeX{}.
1796 % \cmd\getmap\ can deal with them, with the exception of curly braces!
1797 % These will break your \LaTeX{} document. As a work-around, use the \texttt{pathfile} option.
1798 % Please note that the length of the URL is limited to 2048 bytes. So, there's
1799 % no way to support extreme long paths!
1800 % \subsection{OpenStreetMap}
1801 % OpenStreetMap does not offer routing service directly, but you can
1802 % use an OpenStreetMap based route service\footnote{\href{http://maps.openrouteservice.org}{http://maps.openrouteservice.org}}
1803 % to create your route and export it to a \texttt{gpx} file\footnote{This also means that you can visualize your own routes tracked with hardware or a software app!}.
1804 % It's basically a xml-packaged list of geographical coordinates.
1805 % You can use the \texttt{getmapdl} script to convert a route to encoded polylines, e.g.
1806 % a pedestrian route from Berlin Central Station to Brandenburg Gate:
1807 %
1808 % \begin{filecontents*}{berlin.epl}
1809 % &path=weight:5|color:purple|enc:_xq_IcgrpA?AFE@?^BFE@A^U@CLQXEZU?gCR?B?DBF@@?vA?D?D?BAHE@JBN@JLGFCG[DC~C?@?F?R?vA?p@iB@i@Fe@JWRSTOf@Gh@C^A?e@?gE?w@r@?lB@hA?`@??M?aA?]dI??O?O?Cn@cBfBeF|AeEHNVNBc@H@H_AEwA?OAMNA@N
1810 % \end{filecontents*}
1811 % \getmap[file=berlin, mode=gm, language=de, scale=2,
1812 % xsize=400, ysize=600,
1813 % markers={&markers=size:mid|label:H|color:green|Berlin, Hbf
1814 % &markers=label:B|color:blue|Brandenburger Tor, Berlin},
1815 % pathfile={berlin.epl}]{}
1816 % \begin{center}\includegraphics[width=6cm]{berlin}\end{center}
1817 %
1818 % \iffalse
1819 %<*example>
1820 % \fi
1821 \begin{lstlisting}
1822 \begin{filecontents*}{berlin.epl}
1823 &path=weight:5|color:purple|enc:_xq_IcgrpA?AFE@?^BFE@A^U@CLQXEZU?
1824 gCR?B?DBF@@?vA?D?D?BAHE@JBN@JLGFCG[DC~C?@?F?R?vA?p@iB@i@Fe@JWRSTO
1825 f@Gh@C^A?e@?gE?w@r@?lB@hA?`@??M?aA?]dI??O?O?Cn@cBfBeF|AeEHNVNBc@H
1826 @H_AEwA?OAMNA@N
1827 \end{filecontents*}
1828 \getmap[file=berlin, mode=gm, language=de, scale=2,
1829 xsize=400, ysize=600,
1830 markers={&markers=size:mid|label:H|color:green|Berlin, Hbf
1831 &markers=label:B|color:blue|Brandenburger Tor, Berlin},
1832 pathfile={berlin.epl}]{}
1833 \includegraphics[width=6cm]{berlin}
1834 \end{lstlisting}
1835 % \iffalse
1836 %</example>
1837 % \fi
1838 %
1839 % \subsection{Google Maps}
1840 % One possible way is to use Google Maps'
1841 % online interactive map tool\footnote{\href{https://developers.google.com/maps/documentation/utilities/polylineutility}{https://developers.google.com/maps/documentation/utilities/polylineutility}}!
1842 %
1843 % \begin{filecontents*}{muc.epl}
1844 % &path=weight:5|color:orange|enc:okydHa}peAXOHi@jANv@A@kJJmFAiDJuAHmDXcBb@cC`@gC^_DV}CJaCF{APaBVkBdAyEf@qC`@{B\aDSwB
1845 % \end{filecontents*}
1846 % \getmap[file=muc, mode=gm,
1847 % markers={&markers=size:mid|label:H|color:green|München, Hbf
1848 % &markers=label:S|color:yellow|Stachus, München
1849 % &markers=label:M|color:blue|Marienplatz, München},
1850 % pathfile={muc.epl}]{}
1851 % \begin{center}\includegraphics[width=10cm]{muc}\end{center}
1852 %
1853 % \iffalse
1854 %<*example>
1855 % \fi
1856 \begin{lstlisting}
1857 \begin{filecontents*}{muc.epl}
1858 &path=weight:5|color:orange|enc:okydHa}peAXOHi@jANv@A@kJJmFAiDJuA
1859 HmDXcBb@cC`@gC^_DV}CJaCF{APaBVkBdAyEf@qC`@{B\aDSwB
1860 \end{filecontents*}
1861 \getmap[file=muc, mode=gm,
1862 markers={&markers=size:mid|label:H|color:green|München, Hbf
1863 &markers=label:S|color:yellow|Stachus, München
1864 &markers=label:M|color:blue|Marienplatz, München},
1865 pathfile={muc.epl}]{}
1866 \includegraphics[width=10cm]{muc}
1867 \end{lstlisting}
1868 % \iffalse
1869 %</example>
1870 % \fi
1871 %
1872 % You can also use the \textbf{new} version of \textit{My Maps}.
1873 % It allows you to define markers, routes and arbitrary lines on
1874 % different layers and to export these into a \texttt{kml} file,
1875 % e.g \href{https://bitbucket.org/kleberj/getmap/downloads/Berlin.kml}{berlin.kml}\footnote{\href{https://bitbucket.org/kleberj/getmap/downloads/Berlin.kml}{https://bitbucket.org/kleberj/getmap/downloads/Berlin.kml}}:
1876 %
1877 % \iffalse
1878 %<*example>
1879 % \fi
1880 \begin{lstlisting}
1881 $ getmapdl -m kml2epl -K Berlin.kml
1882 Route: Route von Berlin Hbf, Moabit nach Brandenburger Tor, Paris
1883 er Platz, Berlin
1884 k}q_IufrpA?iFQ?gCDQBMHSm@Wq@GQIK]{AUaA}AaICIMm@Kg@EUiByIi@cDSqA_@
1885 uBIa@a@gBpB[fAMhCS|@Gd@Ev@Ep@GfAIpC[bAMr@IbAMp@G\GtBUdCSp@MrAK~AQ
1886 pAMhAKx@IjDc@VAB?D@@?B?dCU`AKjAMRCPlGNtEBhABh@BVF`@D`@D\rB{@ZKDAH
1887 CLAHAHBHBFHFFDNHRHJHHDDHDHBF?F?VCJCJILQJUJg@HQJMJKHAFAJ?X?bCRH@R?
1888 AWQ?K@iBKq@GYAK@EBIFEFEFEFCFAD
1889
1890
1891 Point: Berlin Hbf, Moabit [Europaplatz 1, 10557 Berlin, Deutschl
1892 and]
1893 52.52581820000001,13.3695451
1894
1895
1896 Point: Brandenburger Tor, Pariser Platz, Berlin [Ebertstraße 21,
1897 10117 Berlin, Deutschland]
1898 52.5159099,13.3773202
1899
1900
1901 Point: Berlin Hbf [arrive with train]
1902 52.5249948,13.368988
1903
1904
1905 Point: Reichstag [nice view from the roof]
1906 52.5185973,13.3758974
1907
1908
1909 Point: Brandenburger Tor [once behind the wall]
1910 52.5163514,13.3789873
1911
1912
1913 Route: Route von Berlin Hbf, Moabit nach Pariser Platz, Berlin
1914 k}q_IufrpA?iFQ?@hH@H@F@B@B@?DB?\?|B@F@DB@B@~FCB?X@V??O?O?O?wF@W?o
1915 @?k@?Y?eAvAD`@?`@ARCFAP?hAAZ?B?D?J?B?DAJB^@T?~B?MsAAIAEAM?S@OBM?A
1916 @IDKBKDKFKFIJEFCJAJATAL?XAN?P?VAlBCbB?L@RB?kH@}Gp@]|@ObA?BAz@JTF^
1917 LZN?wF@aCE]~Am@\KREJCNANAH@HBJHHFLPP\DBFFDB@@@?D@F?JAJCKiEAQ?K@I?
1918 KBSXC
1919
1920
1921 Point: Berlin Hbf, Moabit [Europaplatz 1, 10557 Berlin, Deutschl
1922 and]
1923 52.52581820000001,13.3695451
1924
1925
1926 Point: Deutscher Bundestag Redaktion Das Parlament, Berlin [Plat
1927 z der Republik 1, 10557 Berlin, Deutschland]
1928 52.518502000000005,13.3751849
1929
1930
1931 Point: Pariser Platz, Berlin [Pariser Platz 1, 10117 Berlin, Deu
1932 tschland]
1933 52.5160749,13.3783013
1934
1935 \end{lstlisting}
1936 % \iffalse
1937 %</example>
1938 % \fi
1939 %
1940 % Now, you can take these data for your map:
1941 %
1942 % \begin{filecontents*}{berlin2.epl}
1943 % &path=weight:5|color:orange|enc:k}q_IufrpA?iFQ?@hH@H@F@B@B@?DB?\?|B@F@DB@B@~FCB?X@V??O?O?O?wF@W?o@?k@?Y?eAvAD`@?`@ARCFAP?hAAZ?B?D?J?B?DAJB^@T?~B?MsAAIAEAM?S@OBM?A@IDKBKDKFKFIJEFCJAJATAL?XAN?P?VAlBCbB?L@RB?kH@}Gp@]|@ObA?BAz@JTF^LZN?wF@aCE]~Am@\KREJCNANAH@HBJHHFLPP\DBFFDB@@@?D@F?JAJCKiEAQ?K@I?KBSXC&path=weight:5|color:purple|enc:k}q_IufrpA?iFQ?gCDQBMHSm@Wq@GQIK]{AUaA}AaICIMm@Kg@EUiByIi@cDSqA_@uBIa@a@gBpB[fAMhCS|@Gd@Ev@Ep@GfAIpC[bAMr@IbAMp@G\GtBUdCSp@MrAK~AQpAMhAKx@IjDc@VAB?D@@?B?dCU`AKjAMRCPlGNtEBhABh@BVF`@D`@D\rB{@ZKDAHCLAHAHBHBFHFFDNHRHJHHDDHDHBF?F?VCJCJILQJUJg@HQJMJKHAFAJ?X?bCRH@R?AWQ?K@iBKq@GYAK@EBIFEFEFEFCFAD
1944 % \end{filecontents*}
1945 % \getmap[file=berlin2, language=de, xsize=400, ysize=600, scale=2, mode=gm,
1946 % markers={&markers=size:mid|label:H|color:green|52.5249948,13.368988
1947 % &markers=size:mid|label:R|color:yellow|52.5185973,13.3758974
1948 % &markers=label:B|color:blue|52.5163514,13.3789873},
1949 % pathfile={berlin2.epl}]{}
1950 % \begin{center}\includegraphics[width=6cm]{berlin2}\end{center}
1951 %
1952 % \iffalse
1953 %<*example>
1954 % \fi
1955 \begin{lstlisting}
1956 \begin{filecontents*}{berlin2.epl}
1957 &path=weight:5|color:orange|enc:k}q_IufrpA?iFQ?@hH@H@F@B@B@?DB?\?
1958 |B@F@DB@B@~FCB?X@V??O?O?O?wF@W?o@?k@?Y?eAvAD`@?`@ARCFAP?hAAZ?B?D?
1959 J?B?DAJB^@T?~B?MsAAIAEAM?S@OBM?A@IDKBKDKFKFIJEFCJAJATAL?XAN?P?VAl
1960 BCbB?L@RB?kH@}Gp@]|@ObA?BAz@JTF^LZN?wF@aCE]~Am@\KREJCNANAH@HBJHHF
1961 LPP\DBFFDB@@@?D@F?JAJCKiEAQ?K@I?KBSXC&path=weight:5|color:purple|
1962 enc:k}q_IufrpA?iFQ?gCDQBMHSm@Wq@GQIK]{AUaA}AaICIMm@Kg@EUiByIi@cDS
1963 qA_@uBIa@a@gBpB[fAMhCS|@Gd@Ev@Ep@GfAIpC[bAMr@IbAMp@G\GtBUdCSp@MrA
1964 K~AQpAMhAKx@IjDc@VAB?D@@?B?dCU`AKjAMRCPlGNtEBhABh@BVF`@D`@D\rB{@Z
1965 KDAHCLAHAHBHBFHFFDNHRHJHHDDHDHBF?F?VCJCJILQJUJg@HQJMJKHAFAJ?X?bCR
1966 H@R?AWQ?K@iBKq@GYAK@EBIFEFEFEFCFAD
1967 \end{filecontents*}
1968 \getmap[file=berlin2, language=de, xsize=400, ysize=600,
1969 scale=2, mode=gm,
1970 markers={&markers=size:mid|label:H|color:green|52.5249948,13.3689
1971 88
1972 &markers=size:mid|label:R|color:yellow|52.5185973,13.375
1973 8974
1974 &markers=label:B|color:blue|52.5163514,13.3789873},
1975 pathfile={berlin2.epl}]{}%
1976 \includegraphics[width=6cm]{berlin2}%
1977 \end{lstlisting}
1978 % \iffalse
1979 %</example>
1980 % \fi
1981 %
1982 % \subsubsection{Long routes}
1983 %
1984 % Long routes are defined by a huge number of way points, but the URL length
1985 % is limited to 2048 bytes. The following \href{https://bitbucket.org/kleberj/getmap/downloads/MucBer.kml}{example}\footnote{https://bitbucket.org/kleberj/getmap/downloads/MucBer.kml}
1986 % (Stachus, Munich $\rightarrow$ Brandenburg Gate, Berlin) consists of more
1987 % than 6000 way points. A created polyline would hugely exceed the URL length limit!
1988 %
1989 % After transfering the \texttt{kml} file into a \texttt{gps} file, you can use
1990 % the \texttt{gps2gps} mode of \texttt{getmapdl} to reduce the number of
1991 % way points by a given bound. It takes a new pair of \texttt{gps} coordinates
1992 % only if the difference of latitude or longitude is larger than the given bound!
1993 % Finally, you can use the new \texttt{gps} file to create an encoded polyline.
1994 %
1995 % \iffalse
1996 %<*example>
1997 % \fi
1998 \begin{filecontents*}{mucber.epl}
1999 &path=weight:5|color:orange|enc:}cydHw{qeAc|CmbCcoCq{CswDk`Be~C_oAqcDe_@wdD~eAs_Dt~AsbDn{A{aEhk@maD`i@kcDhAk}CoHcnD|Hg}CvVk{Cmx@i|Cpe@c|Cp|@kaClxDk~CzxCqnDzkAk`DftAc}CrrAonDtqBu|C~m@e~CoGc}Csd@wnD{EyjDr@s}C`@}iDoBskCn|CgbCp_D_pB~aD_cB~aDc}CgOssBr}Ci`Cj{CwzAl_Dc|Cnp@w{C~dAagDnk@o{Cnu@o{ChcCclEhdBalDni@u{CpUagFfRa}CfLq|CxQu{Cr\m{C{sBwqC}|Cm}CucDuhD}jDa}GiuD{|CkuBm~CeqCkoAwdDkyAkmDc`CkiDmaEm`Ck|CeCakBwfD}_D{gBo|CbUw}C~yAw|Cqc@{}C}`BumC_|Cqr@kvDmSk}Cu{CiaAkbDbGi_DoGw_DyLk`DxH{_Dmb@q}Cyr@{cAkaDcs@{_DarAy{C_|By_Dy~Ck`Ci}CeMm|CqiCi|CmzAmgDkUm`D_wBg}CiVu~C|aBg|Cva@i{Cc\}zBv~Cw`DyyBq_D_gB{|CoEu{ChLacDfSy|CeBk{CjsC}~Ca~@_}Cil@w|Coz@e_DidCecDivBe|Cqc@{{CemAa_DcyBq|C}|A_|CtuAsfE|dDwzDrz@e~CvXo~C|c@s{CicCirB}jDkq@q}C{dDiuBkcDsnAm}CsnAk}DuI{|CkMmvFmsEy|CmuBc~Cw{C_`Do~CqhEujHekBc|CkvCmaDufDqgC_}Csh@e|Cnq@kuDemAm}CczA{bEgg@cvDlyAiaDbUi{Cjw@i}CsLy}F}I_cDc{@gjDi_@o_Ds]{|D_c@o|Cy}A}qBubDo}CowCoyBe|Cy_Du_CotAg}C}}@obD{sCu{CkrB_jDqoFcmCsmBq_D_l@w}Caz@mdD}eBa`DmuBonE_nA_|Cw`BaaDalDqfCu_CwyDenBqwDqzA{~C}mDkgEcdAmcDsi@{`DabBq{Ccx@s{CsfDwsDueDvR_hD_WcuAu_Dsj@g~DkF{kFf_@waDcOa`DkDc|C}_DceCiu@{aDu|Ckv@m{CcpAiz@k|CmeD}eBeaEedCg`CeaDe`Cy{CwdBipEgJ_gDwOy{Fq@at@
2000 \end{filecontents*}
2001 \getmap[file=mucber, mode=gm, language=de, xsize=400, ysize=600, scale=2,%
2002 markers={&markers=size:mid|label:M|color:green|48.139030000000005,11.56556%
2003 &markers=label:B|color:blue|52.51591,13.37732},%
2004 pathfile={mucber.epl}]{}%
2005 \begin{center}
2006 \includegraphics[height=11cm]{mucber}%
2007 \end{center}
2008 % \iffalse
2009 %</example>
2010 % \fi
2011 %
2012 % \iffalse
2013 %<*example>
2014 % \fi
2015 \begin{lstlisting}
2016 $ getmapdl -m kml2gps -K MucBer.kml >MucBer.gps
2017
2018 $ cat MucBer.gps
2019 Route: Route von Stachus, München nach Brandenburger Tor, Pariser
2020 Platz, Berlin
2021 48.13903,11.56556
2022 48.1392,11.56562
2023 [ ... many, many way points ...]
2024 52.5159,13.37735
2025 52.51591,13.37732
2026
2027
2028 Point: Stachus, München [Karlsplatz 10, 80335 München, Deutschla
2029 nd]
2030 48.13903,11.56556
2031
2032
2033 Point: Brandenburger Tor, Pariser Platz, Berlin [Ebertstraße 21,
2034 10117 Berlin, Deutschland]
2035 52.51591,13.37732
2036
2037 $ getmapdl -m gps2gps -G MucBer.gps -B 0.025 >MucBerR.gps
2038
2039 Route 1: reduced gps coordinates (Bound = 0.025): 6119 -> 193
2040
2041 $ getmapdl -m gps2epl -G MucBerR.gps
2042
2043 Route: Route von Stachus, München nach Brandenburger Tor, Pariser
2044 Platz, Berlin
2045
2046 }cydHw{qeAc|CmbCcoCq{CswDk`Be~C_oAqcDe_@wdD~eAs_Dt~AsbDn{A{aEhk@m
2047 aD`i@kcDhAk}CoHcnD|Hg}CvVk{Cmx@i|Cpe@c|Cp|@kaClxDk~CzxCqnDzkAk`Df
2048 tAc}CrrAonDtqBu|C~m@e~CoGc}Csd@wnD{EyjDr@s}C`@}iDoBskCn|CgbCp_D_p
2049 B~aD_cB~aDc}CgOssBr}Ci`Cj{CwzAl_Dc|Cnp@w{C~dAagDnk@o{Cnu@o{ChcCcl
2050 EhdBalDni@u{CpUagFfRa}CfLq|CxQu{Cr\m{C{sBwqC}|Cm}CucDuhD}jDa}GiuD
2051 {|CkuBm~CeqCkoAwdDkyAkmDc`CkiDmaEm`Ck|CeCakBwfD}_D{gBo|CbUw}C~yAw
2052 |Cqc@{}C}`BumC_|Cqr@kvDmSk}Cu{CiaAkbDbGi_DoGw_DyLk`DxH{_Dmb@q}Cyr
2053 @{cAkaDcs@{_DarAy{C_|By_Dy~Ck`Ci}CeMm|CqiCi|CmzAmgDkUm`D_wBg}CiVu
2054 ~C|aBg|Cva@i{Cc\}zBv~Cw`DyyBq_D_gB{|CoEu{ChLacDfSy|CeBk{CjsC}~Ca~
2055 @_}Cil@w|Coz@e_DidCecDivBe|Cqc@{{CemAa_DcyBq|C}|A_|CtuAsfE|dDwzDr
2056 z@e~CvXo~C|c@s{CicCirB}jDkq@q}C{dDiuBkcDsnAm}CsnAk}DuI{|CkMmvFmsE
2057 y|CmuBc~Cw{C_`Do~CqhEujHekBc|CkvCmaDufDqgC_}Csh@e|Cnq@kuDemAm}Ccz
2058 A{bEgg@cvDlyAiaDbUi{Cjw@i}CsLy}F}I_cDc{@gjDi_@o_Ds]{|D_c@o|Cy}A}q
2059 BubDo}CowCoyBe|Cy_Du_CotAg}C}}@obD{sCu{CkrB_jDqoFcmCsmBq_D_l@w}Ca
2060 z@mdD}eBa`DmuBonE_nA_|Cw`BaaDalDqfCu_CwyDenBqwDqzA{~C}mDkgEcdAmcD
2061 si@{`DabBq{Ccx@s{CsfDwsDueDvR_hD_WcuAu_Dsj@g~DkF{kFf_@waDcOa`DkDc
2062 |C}_DceCiu@{aDu|Ckv@m{CcpAiz@k|CmeD}eBeaEedCg`CeaDe`Cy{CwdBipEgJ_
2063 gDwOy{Fq@at@
2064 \end{lstlisting}
2065 % \iffalse
2066 %</example>
2067 % \fi
2068 %
2069 % Taking a look into the log file, we find:
2070 %
2071 % \iffalse
2072 %<*example>
2073 % \fi
2074 \begin{lstlisting}
2075 getmapdl.lua:
2076 url = http://maps.googleapis.com/maps/api/staticmap? ...
2077 url length = 1866 bytes
2078 output = mucber.png
2079 \end{lstlisting}
2080 % \iffalse
2081 %</example>
2082 % \fi
2083 %
2084 % With 193 way points we almost reached the URL length limit
2085 % of 2048 bytes. The accuracy of the encoded polyline is obviously
2086 % good enough. So, about 200 way points seem to be a good choice. But
2087 % the length of an encoded pair of \texttt{gps} coordinates depends on the
2088 % space between two points and may vary between 2 and 8 bytes!
2089 %
2090 % \section{Implementation}
2091 % \changes{v1.0}{2014/05/25}{CTAN upload}
2092 % \changes{v1.2}{2014/07/11}{added support for Google Maps}
2093 % \changes{v1.2}{2014/07/11}{renamed osmimage.lua to getmapdl.lua}
2094 % \changes{v1.3}{2014/07/19}{added support for Google Street View}
2095 % \changes{v1.4}{2014/07/25}{\texttt{getmapdl.lua}: added options language, markers, visible, path and pathfile in gm mode}
2096 % \changes{v1.5}{2014/08/12}{added \texttt{gpx2gps} \texttt{bash} script}
2097 % \changes{v1.6}{2014/08/16}{removed \texttt{gpx2gps} \texttt{bash} script}
2098 % \changes{v1.6}{2014/08/16}{\texttt{getmapdl.lua}: added \texttt{gpx2epl}, \texttt{gps2epl} and \texttt{gpx2gps} modes}
2099 % \changes{v1.7}{2014/09/18}{\texttt{getmapdl.lua}: added \texttt{kml2gps} and \texttt{kml2epl} modes}
2100 % \changes{v1.7}{2014/09/18}{\texttt{getmapdl.lua}: added multi track support for \texttt{gpx2gps} and \texttt{gpx2epl} mode}
2101 % \changes{v1.7}{2014/09/18}{\texttt{getmapdl.lua}: revised \texttt{gps2epl} mode}
2102 % \changes{v1.8}{2014/10/06}{\texttt{getmapdl.lua}: added check of URL length and output to log}
2103 % \changes{v1.8}{2014/10/07}{\texttt{getmapdl.lua}: added \texttt{gps2gps} mode to reduce way points with a given bound (default: 0.1)}
2104 % \changes{v1.8}{2014/10/07}{\texttt{getmapdl.lua}: added multi route support for \texttt{gps2epl} mode}
2105 % \changes{v1.8}{2014/10/07}{\texttt{getmapdl.lua}: added rounding of gps coordinates to \texttt{kml2gps} and \texttt{gpx2gps} modes}
2106 % \changes{v1.10}{2018/07/18}{\texttt{getmapdl.lua}: fix problem (unable to load socket.url module) caused by bug in luatex v1.0.7 (TeXLive2018)}
2107 % \changes{v1.11}{2019/03/25}{\texttt{getmapdl.lua}: added API key for Google Maps API, which is no longer accessible without key}
2108 % \begin{macrocode}
2109 %<*package>
2110 % \end{macrocode}
2111 % First, we provide the \LaTeX\ package \package{getmap}.
2112 % \begin{macrocode}
2113 \NeedsTeXFormat{LaTeX2e}%
2114 \ProvidesPackage{getmap}[2019/03/25 v1.11 getmap.sty - Josef Kleber (C) 2014,2016,2018,2019]%
2115 % \end{macrocode}
2116 % We need a few packages!
2117 % \begin{macrocode}
2118 \RequirePackage{xkeyval}%
2119 \RequirePackage{stringenc}%
2120 \RequirePackage{ifthen}%
2121 % \end{macrocode}
2122 % Newer versions of \LuaTeX\ v0.85+ no longer supports \cmd\write18! Therefore, we use \package{shellesc} instead.
2123 % \begin{macrocode}
2124 \RequirePackage{shellesc}%
2125 % \end{macrocode}
2126 % Fix a bug with problematic url encodings coming up with \texttt{luatex} v1.0.7 (TeXLive 2018)
2127 % fixed by Akira Kakuto (see: \href{https://tug.org/pipermail/tex-live/2018-June/041997.html}{TeXLive mailing list})
2128 % \begin{macrocode}
2129 \RequirePackage{ifxetex}%
2130 \ifxetex%
2131 \def\StringEncodingConvert#1#2#3#4%
2132 {%
2133 \def#1{#2}%
2134 }%
2135 \fi%
2136 \ifluatex%
2137 \def\StringEncodingConvert#1#2#3#4%
2138 {%
2139 \def#1{#2}%
2140 }%
2141 \fi%
2142 % \end{macrocode}
2143 % We provide a macro \cmd\GM@JK@define@key, which defines package options with global scope%
2144 % and options for \cmd\getmap\ with local scope. It takes four arguments \marg{prefix},%
2145 % \marg{package},\marg{option} and \marg{default}.
2146 % \begin{macrocode}
2147 \newcommand*\GM@JK@define@key[4]%
2148 {%
2149 \expandafter\gdef\csname#1@#3\endcsname{#4}%
2150 \define@key{#2.sty}{#3}[#4]%
2151 {%
2152 \expandafter\gdef\csname#1@#3\endcsname{##1}%
2153 }%
2154 \define@key{#2}{#3}%
2155 {%
2156 \expandafter\def\csname#1@#3\endcsname{##1}%
2157 }%
2158 }%
2159 \newcommand*\GM@JK@define@key@detok[4]%
2160 {%
2161 \expandafter\gdef\csname#1@#3\endcsname{#4}%
2162 \define@key{#2.sty}{#3}[#4]%
2163 {%
2164 \expandafter\gdef\csname#1@#3\endcsname{\detokenize{##1}}%
2165 }%
2166 \define@key{#2}{#3}%
2167 {%
2168 \expandafter\def\csname#1@#3\endcsname{\detokenize{##1}}%
2169 }%
2170 }%
2171 % \end{macrocode}
2172 % Now, we can use this macro to define our options.
2173 % \changes{v1.2}{2014/07/11}{changed default values of \texttt{xsize }(600) and \texttt{file} (getmap)}
2174 % \begin{macrocode}
2175 \GM@JK@define@key{GM@JK}{getmap}{mode}{osm}%
2176 \GM@JK@define@key{GM@JK}{getmap}{key}{}%
2177 \GM@JK@define@key{GM@JK}{getmap}{xsize}{600}%
2178 \GM@JK@define@key{GM@JK}{getmap}{ysize}{400}%
2179 \GM@JK@define@key{GM@JK}{getmap}{scale}{3385}%
2180 \GM@JK@define@key{GM@JK}{getmap}{zoom}{}%
2181 \GM@JK@define@key{GM@JK}{getmap}{type}{map}%
2182 \GM@JK@define@key{GM@JK}{getmap}{imagetype}{png}%
2183 \GM@JK@define@key{GM@JK}{getmap}{color}{yellow_1}%
2184 \GM@JK@define@key{GM@JK}{getmap}{number}{1}%
2185 \GM@JK@define@key{GM@JK}{getmap}{heading}{0}%
2186 \GM@JK@define@key{GM@JK}{getmap}{fov}{90}%
2187 \GM@JK@define@key{GM@JK}{getmap}{pitch}{0}%
2188 \GM@JK@define@key{GM@JK}{getmap}{language}{en}%
2189 \GM@JK@define@key@detok{GM@JK}{getmap}{markers}{}%
2190 \GM@JK@define@key@detok{GM@JK}{getmap}{path}{}%
2191 \GM@JK@define@key@detok{GM@JK}{getmap}{visible}{}%
2192 \GM@JK@define@key{GM@JK}{getmap}{pathfile}{}%
2193 \GM@JK@define@key{GM@JK}{getmap}{file}{getmap}%
2194 \GM@JK@define@key{GM@JK}{getmap}{inputencoding}{}%
2195 \GM@JK@define@key{GM@JK}{getmap}{overwrite}{true}%
2196 % \end{macrocode}
2197 % For options without default value, we define reasonable default values!
2198 % We overwrite the default for \styleoption{overwrite}, because we don't want
2199 % \styleoption{overwrite} to be \texttt{true} by default, but that \styleoption{overwrite}
2200 % is equivalent to \styleoption{overwrite}=\texttt{true}!
2201 %
2202 % \changes{v1.2}{2014/07/11}{added getmap.cfg to store default key (FR by Ulrike Fischer)}
2203 % Moreover, we load \texttt{getmap.cfg} to set the default key. You can copy this file
2204 % to your local \TeX\ tree and replace the key with your own!
2205 %
2206 % We try to use the input encoding specified for \package{inputenc} or \texttt{utf8} instead.
2207 % \begin{macrocode}
2208 \gdef\GM@JK@overwrite{false}%
2209 \gdef\GM@JK@key{}%
2210 %
2211 \IfFileExists{getmap.cfg}%
2212 {%
2213 \input{getmap.cfg}%
2214 }%
2215 {%
2216 \gdef\GM@JK@key{Fmjtd|luur20u22d,75=o5-9aylh6}%
2217 }%
2218 %
2219 \@ifpackageloaded{inputenc}%
2220 {%
2221 \gdef\GM@JK@inputencoding{\inputencodingname}%
2222 }%
2223 {%
2224 \gdef\GM@JK@inputencoding{utf8}%
2225 }%
2226 %
2227 % \end{macrocode}
2228 % Later, we will need a switch, if \cmd\write18\ is enabled.
2229 % \begin{macrocode}
2230 \newif\ifGM@JK@writexviii\GM@JK@writexviiifalse%
2231 %
2232 % \end{macrocode}
2233 % We execute the package options to define and set the option macros.
2234 % \begin{macrocode}
2235 \ExecuteOptionsX{mode,xsize,ysize,scale,zoom,type,imagetype,color,number,file,heading,fov,pitch,language}%
2236 %
2237 \ProcessOptionsX\relax%
2238 %
2239 % \end{macrocode}
2240 % We need to reset some defaults in \texttt{gm} mode.
2241 % \begin{macrocode}
2242 %
2243 \ifthenelse{\equal{\GM@JK@mode}{gm}}%
2244 {%
2245 \gdef\GM@JK@scale{1}%
2246 \gdef\GM@JK@zoom{17}%
2247 \gdef\GM@JK@type{roadmap}%
2248 \gdef\GM@JK@color{blue}%
2249 }%
2250 {}%
2251 %
2252 % \end{macrocode}
2253 % We check if \cmd\pdf@shellescape\ is available to test if \cmd\write18
2254 % is enabled.
2255 %
2256 % If \texttt{false}, we assume \cmd\write18\ is available and hope for the best.
2257 %
2258 % If \texttt{true}, we set the switch \cmd\GM@JK@writexviii\ accordingly!
2259 % \begin{macrocode}
2260 %
2261 \ltx@IfUndefined{pdf@shellescape}%
2262 {%
2263 \PackageInfo{getmap}{\pdf@shellescape is undefined}%
2264 \PackageInfo{getmap}{can not test if \write18 is available}%
2265 \GM@JK@writexviiitrue%
2266 }%
2267 {%
2268 \PackageInfo{getmap}{\pdf@shellescape is available}%
2269 \ifnum\pdf@shellescape=1\relax%
2270 \PackageInfo{getmap}{\write18 enabled}%
2271 \GM@JK@writexviiitrue%
2272 \else%
2273 \GM@JK@writexviiifalse%
2274 \fi%
2275 }%
2276 %
2277 % \end{macrocode}
2278 % We define a macro that is executed as \cmd\ShellEscape\ call. First, we test if%
2279 % \cmd\write18\ is enabled and issue a package error if not! Otherwise we execute%
2280 % \cmd\ShellEscape\ depending on the mode%
2281 % \changes{v1.9}{2016/06/16}{\LuaTeX\ v0.85+ fix: use \texttt{shellesc}'s \texttt{\textbackslash ShellEscape} instead of \texttt{\textbackslash write18}}
2282 % \changes{v1.10}{2018/07/18}{Bugfix: fixes encoding problems with luatex v1.0.7 (TeXLive2018)}
2283 % \begin{macrocode}
2284 \newcommand*\GM@JK@shellescape%
2285 {%
2286 \ifGM@JK@writexviii\relax%
2287 \ifthenelse{\equal{\GM@JK@mode}{osm}}%
2288 {%
2289 \ifluatex\directlua{os.setlocale('','ctype')}\fi%
2290 \ShellEscape{getmapdl \space-l\space "\GM@JK@location@string"%
2291 \space-m\space osm%
2292 \space-k\space "\GM@JK@key@string"%
2293 \space-x\space \GM@JK@xsize%
2294 \space-y\space \GM@JK@ysize%
2295 \space-z\space "\GM@JK@zoom"%
2296 \space-s\space \GM@JK@scale%
2297 \space-t\space \GM@JK@type%
2298 \space-i\space \GM@JK@imagetype%
2299 \space-c\space "\GM@JK@color"%
2300 \space-n\space \GM@JK@number%
2301 \space-o\space \GM@JK@file}%
2302 }%
2303 {%
2304 \ifthenelse{\equal{\GM@JK@mode}{gm}}%
2305 {%
2306 \ifluatex\directlua{os.setlocale('','ctype')}\fi%
2307 \ShellEscape{getmapdl \space-l\space "\GM@JK@location@string"%
2308 \space-m\space gm%
2309 \space-x\space \GM@JK@xsize%
2310 \space-y\space \GM@JK@ysize%
2311 \space-z\space \GM@JK@zoom%
2312 \space-s\space \GM@JK@scale%
2313 \space-t\space \GM@JK@type%
2314 \space-i\space \GM@JK@imagetype%
2315 \space-c\space "\GM@JK@color"%
2316 \space-n\space \GM@JK@number%
2317 \space-L\space "\GM@JK@language"%
2318 \space-M\space "\GM@JK@markers@string"%
2319 \space-C\space "\GM@JK@location@string"%
2320 \space-P\space "\GM@JK@path@string"%
2321 \space-p\space "\GM@JK@pathfile"%
2322 \space-V\space "\GM@JK@visible@string"%
2323 \space-o\space \GM@JK@file}%
2324 }%
2325 {%
2326 \ifthenelse{\equal{\GM@JK@mode}{gsv}}%
2327 {%
2328 \ifluatex\directlua{os.setlocale('','ctype')}\fi%
2329 \ShellEscape{getmapdl \space-l\space "\GM@JK@location@string"%
2330 \space-m\space gsv%
2331 \space-x\space \GM@JK@xsize%
2332 \space-y\space \GM@JK@ysize%
2333 \space-H\space \GM@JK@heading%
2334 \space-F\space \GM@JK@fov%
2335 \space-T\space \GM@JK@pitch%
2336 \space-o\space \GM@JK@file}%
2337 }%
2338 {%
2339 \PackageError{getmap}{invalid mode}{invalid mode! Use osm, gm or gsv!}%
2340 }%
2341 }%
2342 }%
2343 \else%
2344 \PackageError{getmap}{\write18 disabled}%
2345 {\write18 disabled\MessageBreak%
2346 Use -shell-escape (TeXLive)\MessageBreak%
2347 or\space\space--enable-write18 (MiKTeX)}%
2348 \fi%
2349 }%
2350 % \end{macrocode}
2351 % \begin{macro}{\getmap}
2352 % Here, we define the user command to download the map.
2353 %
2354 % \cs{getmap}\oarg{options}\marg{address}
2355 % \begin{macrocode}
2356 \newcommand*\getmap[2][]%
2357 {%
2358 % \end{macrocode}
2359 % \changes{v1.1}{2014/06/23}{Bugfix: problem in URL when using \cmd\usepackage[utf8]\{inputenc\}}
2360 % \changes{v1.9}{2016/06/18}{Bugfix: restore mode defaults for \texttt{scale}, \texttt{zoom}, \texttt{type} and \texttt{color} options to guarantee correct download URLs}
2361 % We start a group to keep the setting of options local.
2362 % Then we test the mode to reset some defaults!
2363 % Finally, we set the local options again to override defaults if necessary!
2364 % \begin{macrocode}
2365 \begingroup%
2366 \setkeys{getmap}{#1}%
2367 \ifthenelse{\equal{\GM@JK@mode}{gm}}%
2368 {%
2369 \def\GM@JK@scale{1}%
2370 \def\GM@JK@zoom{17}%
2371 \def\GM@JK@type{roadmap}%
2372 \def\GM@JK@color{blue}%
2373 }%
2374 {}%
2375 \ifthenelse{\equal{\GM@JK@mode}{osm}}%
2376 {%
2377 \def\GM@JK@scale{3385}%
2378 \def\GM@JK@zoom{}%
2379 \def\GM@JK@type{map}%
2380 \def\GM@JK@color{yellow_1}%
2381 }%
2382 {}%
2383 \setkeys{getmap}{#1}%
2384 % \end{macrocode}
2385 % In \texttt{gsv} mode, we have an implicit \texttt{imagetype=jpg}.
2386 % Therefore, we have to set it to allow the later test on the existence
2387 % of the image file!
2388 % \begin{macrocode}
2389 \ifthenelse{\equal{\GM@JK@mode}{gsv}}%
2390 {\def\GM@JK@imagetype{jpg}}{}%
2391 \PackageInfo{getmap}{using \GM@JK@inputencoding\space encoding}%
2392 \def\GM@JK@location{#2}%
2393 % \end{macrocode}
2394 % \texttt{texlua} expects its arguments encoded in \texttt{utf8}!
2395 % \begin{macrocode}
2396 \StringEncodingConvert%
2397 {\GM@JK@location@string}%
2398 {\detokenize\expandafter{\GM@JK@location}}%
2399 {\GM@JK@inputencoding}{utf-8}%
2400 \StringEncodingSuccessFailure%
2401 {%
2402 %success
2403 }%
2404 {% failure
2405 \errmessage{Converting to UTF-8 failed}%
2406 }%
2407 \StringEncodingConvert%
2408 {\GM@JK@key@string}%
2409 {\detokenize\expandafter{\GM@JK@key}}%
2410 {\GM@JK@inputencoding}{utf-8}%
2411 \StringEncodingSuccessFailure%
2412 {%
2413 %success
2414 }%
2415 {% failure
2416 \errmessage{Converting to UTF-8 failed}%
2417 }%
2418 \StringEncodingConvert%
2419 {\GM@JK@markers@string}%
2420 {\GM@JK@markers}%
2421 {\GM@JK@inputencoding}{utf-8}%
2422 \StringEncodingSuccessFailure%
2423 {%
2424 %success
2425 }%
2426 {% failure
2427 \errmessage{Converting to UTF-8 failed}%
2428 }%
2429 \StringEncodingConvert%
2430 {\GM@JK@path@string}%
2431 {\GM@JK@path}%
2432 {\GM@JK@inputencoding}{utf-8}%
2433 \StringEncodingSuccessFailure%
2434 {%
2435 %success
2436 }%
2437 {% failure
2438 \errmessage{Converting to UTF-8 failed}%
2439 }%
2440 \StringEncodingConvert%
2441 {\GM@JK@visible@string}%
2442 {\GM@JK@visible}%
2443 {\GM@JK@inputencoding}{utf-8}%
2444 \StringEncodingSuccessFailure%
2445 {%
2446 %success
2447 }%
2448 {% failure
2449 \errmessage{Converting to UTF-8 failed}%
2450 }%
2451 % \end{macrocode}
2452 % We check, if \styleoption{overwrite} is \texttt{true} and download the map.
2453 % If not, we check if the image is already in the working directory. If not, we
2454 % download the image!
2455 % \begin{macrocode}
2456 \ifthenelse{\equal{\GM@JK@overwrite}{true}}%
2457 {%
2458 \GM@JK@shellescape%
2459 }%
2460 {%
2461 \IfFileExists{\GM@JK@file.\GM@JK@imagetype}%
2462 {%
2463 \PackageInfo{getmap}{overwrite=false; (\GM@JK@file.\GM@JK@imagetype)%
2464 using existing file!}%
2465 }%
2466 {%
2467 \PackageInfo{getmap}{overwrite=false; (\GM@JK@file.\GM@JK@imagetype)%
2468 file does not exist! downloading ...}%
2469 \GM@JK@shellescape%
2470 }%
2471 }%
2472 \endgroup%
2473 }%
2474 % \end{macrocode}
2475 % \end{macro}
2476 % \begin{macrocode}
2477 %</package>
2478 % \end{macrocode}
2479 %\Finale