Debian Codegraph @

texmf-dist/doc/latex/mercatormap/mercatormap.doc.routes.tex

raw
1 % !TeX root = mercatormap.tex
2 % !TeX encoding=UTF-8
3 % !TeX spellcheck=en_US
4 % include file of mercatormap.tex (manual of the LaTeX package mercatormap)
5 \clearpage
6 \section{Routes}\label{sec:routes}%
7
8 Routes are \tikzname\ |path| objects which can be drawn with the appropriate
9 \tikzname\ macros and the coordinate system documented in
10 \Fullref{sec:map_definition}.
11 Nevertheless, in the following some alternatives are described which allow
12 to specify a path by a sequence of points (\refCom{mrcpoint}).
13 The idea is that such a sequence of points is exported by a third-party
14 application for inclusion in a \LaTeX\ map, see \Fullref{sec:routes_gpx}.
15
16
17 %-------------------------------------------------------------------------------
18 \subsection{Route Path Definition}
19
20 \begin{docEnvironment}{mrcroute}{\oarg{options}}
21 This environment creates a \tikzname\ |path| with given \tikzname\ \meta{options}.
22 The \meta{environment content} is a sequence of points made by \refCom{mrcpoint}.
23 \begin{dispListing}
24 \begin{mrcroute}[red, very thick]
25 \mrcpoint{48.137222}{11.575556}
26 \mrcpoint{49.019479}{12.0976942}
27 ...
28 \end{mrcroute}
29 \end{dispListing}
30 Note that a map definition by \refCom{mrcdefinemap}, \refCom{mrcmap},
31 or \refCom{mrcapplymap} is needed before a route |path| can be drawn.\par
32 %A |path| can be closed by adding \docAuxCommand{pgfpathclose} as last entry
33 %after all \refCom{mrcpoint} macros. Further |pgf| commands may be added,
34 %but the sequence should start with a \refCom{mrcpoint}.
35 \end{docEnvironment}
36
37
38 \begin{docEnvironment}{mrcroute*}{\oarg{options}}
39 Identical to \refEnv{mrcroute}, but the created \tikzname\ |path| is
40 closed.
41 \end{docEnvironment}
42
43
44 \begin{docCommand}{mrcrouteinput}{\oarg{options}\marg{filename}}
45 Identical to \refEnv{mrcroute}, but the sequence of points is included
46 from a file with the given \meta{filename}.
47 \end{docCommand}
48
49 \begin{docCommand}{mrcrouteinput*}{\oarg{options}\marg{filename}}
50 Identical to \refCom{mrcrouteinput}, but the created \tikzname\ |path| is
51 closed.
52 \end{docCommand}
53
54
55 \begin{docCommand}{mrcpoint}{\marg{latitude}\marg{longitude}}
56 Specifies a single coordinate point with given \meta{latitude} and
57 \meta{longitude} as part of sequence inside \refEnv{mrcroute}.\par
58 This is a wrapper for |\pgfpathmoveto| respectively |\pgfpathlineto|.
59 \end{docCommand}
60
61
62 \begin{docMrcKey}{every route}{=\meta{options}}{no default, initially empty}
63 Sets \tikzname\ \meta{options} which are applied to every
64 \refEnv{mrcroute} and \refCom{mrcrouteinput}.
65 \end{docMrcKey}
66
67
68 \tikzsetnextfilename{routes_example}%
69 \begin{dispExample*}{center lower}
70 % \mrcsetapikey{thunderforest}{YOUR-API-KEY} % registered key
71 \begin{tikzpicture}
72 \mrcmap[type=areafit,
73 west=5,east=15,south=47,north=55,
74 source=thunderforest neighbourhood,
75 tex width=14cm, tex height=14cm,
76 flex area fit=5mm
77 ]{routes_example}
78 \mrcdrawmap
79 \node[below,font=\fontsize{7pt}{7pt}\sffamily] at (mrcmap.south)
80 {\mrcmapattribution};
81 \mrcclipmap
82 \path[draw] (mrcmap.south west) rectangle (mrcmap.north east);
83 \begin{mrcroute}[blue,line width=0.4mm,line cap=round,
84 line join=round,double=blue!5!white,double distance=0.4mm]
85 \mrcpoint{48.137222}{11.575556}
86 \mrcpoint{49.019479}{12.0976942}
87 \mrcpoint{49.45522}{11.07631}
88 \mrcpoint{50.978056}{11.029167}
89 \mrcpoint{52.518611}{13.408333}
90 \end{mrcroute}
91 \end{tikzpicture}
92 \end{dispExample*}
93
94
95 \clearpage
96 %-------------------------------------------------------------------------------
97 \subsection{Example Python Conversion Scripts for gpx}\label{sec:routes_gpx}
98 The following scripts are examples for conversions from a standard
99 routes and tracks of |gpx| files to \LaTeX\ include files
100 (assuming a single route/track per file).
101
102 \begin{dispListing*}{title=Python 3 script to convert \texttt{route.gpx} to
103 a sequence of points file \texttt{route.inc},
104 documentation minted language=python}
105 import xmltodict
106
107 with open('route.gpx', encoding='utf-8') as gpx:
108 doc = xmltodict.parse(gpx.read())
109 with open('route.inc', "w", encoding="utf-8") as inc:
110 for rtept in doc['gpx']['rte']['rtept']:
111 lat = rtept['@lat']
112 lon = rtept['@lon']
113 inc.write(f'\\mrcpoint{{{lat}}}{{{lon}}}\n')
114 \end{dispListing*}
115
116
117 \begin{dispListing*}{title=Python 3 script to convert \texttt{track.gpx} to
118 a sequence of points file \texttt{track.inc},
119 documentation minted language=python}
120 import xmltodict
121
122 with open('track.gpx', encoding='utf-8') as gpx:
123 doc = xmltodict.parse(gpx.read())
124 with open('track.inc', "w", encoding="utf-8") as inc:
125 for trkpt in doc['gpx']['trk']['trkseg']['trkpt']:
126 lat = trkpt['@lat']
127 lon = trkpt['@lon']
128 inc.write(f'\\mrcpoint{{{lat}}}{{{lon}}}\n')
129 \end{dispListing*}
130