diff options
author | Karl Berry <karl@freefriends.org> | 2014-08-18 22:31:15 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2014-08-18 22:31:15 +0000 |
commit | 0970cba8aa8e3b29c31184e9861f8dda14c08cc9 (patch) | |
tree | f0f965f40482b71a41d2a58636ab2b3e474e167d /Master/texmf-dist | |
parent | 9422fc520291ceb7eb36aaacb2b97c08bdb02c9e (diff) |
getmap (18aug14)
git-svn-id: svn://tug.org/texlive/trunk@34970 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/latex/getmap/README | 13 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/getmap/getmap.dtx | 412 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/getmap/getmap.pdf | bin | 1764654 -> 1767909 bytes | |||
-rwxr-xr-x | Master/texmf-dist/doc/latex/getmap/install.bat | 3 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/getmap/makefile | 5 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/getmap/manifest.txt | 1 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/getmap/getmapdl.lua | 136 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/getmap/gpx2gps | 40 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/getmap/getmap.sty | 2 |
9 files changed, 402 insertions, 210 deletions
diff --git a/Master/texmf-dist/doc/latex/getmap/README b/Master/texmf-dist/doc/latex/getmap/README index a11a0068849..c3ce117374a 100644 --- a/Master/texmf-dist/doc/latex/getmap/README +++ b/Master/texmf-dist/doc/latex/getmap/README @@ -8,13 +8,16 @@ use this script also from the command line. License: LPPL -Changes in v1.5: +Changes in v1.6: -- added gpx2gps bash file +- added gpx2epl, gps2epl and gpx2gps modes to getmapdl.lua - transforms a gpx file (exported route) into a plain list - of geographical coordinates (latitude,longitude) to create - an encoded polyline (route) for the map + parses gpx and gps files and outputs gps or epl (encoded + polylines) to STDOUT, e.g: + + getmapdl -m gpx2epl -G myroute.gpx >myroute.epl + +- removed gpx2gps bash file - updated documentation diff --git a/Master/texmf-dist/doc/latex/getmap/getmap.dtx b/Master/texmf-dist/doc/latex/getmap/getmap.dtx index ab20a47c83a..c6b299b4652 100644 --- a/Master/texmf-dist/doc/latex/getmap/getmap.dtx +++ b/Master/texmf-dist/doc/latex/getmap/getmap.dtx @@ -14,14 +14,17 @@ use this script also from the command line. License: LPPL -Changes in v1.5: +Changes in v1.6: -- added gpx2gps bash file +- added gpx2epl, gps2epl and gpx2gps modes to getmapdl.lua - transforms a gpx file (exported route) into a plain list - of geographical coordinates (latitude,longitude) to create - an encoded polyline (route) for the map + parses gpx and gps files and outputs gps or epl (encoded + polylines) to STDOUT, e.g: + getmapdl -m gpx2epl -G myroute.gpx >myroute.epl + +- removed gpx2gps bash file + - updated documentation @@ -137,7 +140,8 @@ download getmap.dtx and makefile (Linux) or install.bat (Windows) -- -- getmapdl [options] -- --- downloads an OpenStreetMap, Google Maps or Google Street View map specified by [options] +-- downloads an OpenStreetMap, Google Maps or Google Street View map +-- specified by [options] or parses gpx or gps files to create encoded polylines -- -- License: LPPL -- @@ -169,9 +173,10 @@ local HEADING = "" local FOV = "" local PITCH = "" local LANGUAGE = "" +local GPFILE = "" local OFILE = "getmap" local QUIET = "false" -local VERSION = "v1.2 (25/07/2014)" +local VERSION = "v1.3 (16/08/2014)" function pversion() print("getmapdl.lua " .. VERSION) @@ -183,11 +188,13 @@ function phelp() print([[ getmapdl.lua [options] - downloads an OpenStreetMap or Google Maps map specified by [options] + downloads an OpenStreetMap, Google Maps or Google Street View map + specified by [options] or parses gpx or gps files to create + encoded polylines Options: - -m specify the mode (osm|gm) + -m specify the mode (osm|gm|gsv|gpx2epl|gps2epl|gpx2gps) -l specify a location e.g. 'Bergheimer Straße 110A, 69115 Heidelberg, Germany' @@ -199,7 +206,7 @@ getmapdl.lua [options] -S short form to specify a size, e.g. 600,400 (osm) or 600x400 (gm) -s specify a scale factor in the range 1692-221871572 (osm) or - 1-2 (osm) + 1-2 (gm) -z specify a zoom in the range 1-18 (osm) or 0-21 (17) (gm) @@ -250,6 +257,11 @@ getmapdl.lua [options] -F specify horizontal field of view (90) (0 -- 120) The field of view is expressed in degrees and a kind of zoom! + + gpx2epl, gps2epl and gpx2gps mode only: + + -G specify the gpx or gps file + ]]) pversion() end @@ -276,7 +288,27 @@ function check_range(var,min,max,exitcode,varname) end end -print("\n") +function round(number, precision) + return math.floor(number*math.pow(10,precision)+0.5) / math.pow(10,precision) +end + +function encodeNumber(number) + local num = number + num = num * 2 + if num < 0 + then + num = (num * -1) - 1 + end + local t = {} + while num >= 32 + do + local num2 = 32 + (num % 32) + 63 + table.insert(t,string.char(num2)) + num = math.floor(num / 32) -- use floor to keep integer portion only + end + table.insert(t,string.char(num + 63)) + return table.concat(t) +end do local newarg = {} @@ -345,6 +377,9 @@ do elseif arg[i] == "-p" then FPATH = arg[i+1] i = i + 1 + elseif arg[i] == "-G" then + GPFILE = arg[i+1] + i = i + 1 elseif arg[i] == "-o" then OFILE = arg[i+1] i = i + 1 @@ -366,6 +401,97 @@ if QUIET == 1 then getmap_warning("-q option currently not supported!") end +if MODE == "gpx2epl" then + local file = io.open(GPFILE, "r") + local Olatitude = 0 + local Olongitude = 0 + local epl = {} + + io.input(file) + while true do + local line = io.read() + if line == nil + then + break + end + if string.match(line, "trkpt") then + local latitude + local longitude + local encnum + latitude = string.match(line, 'lat="(.-)"') + longitude = string.match(line, 'lon="(.-)"') + latitude = round(latitude,5)*100000 + longitude = round(longitude,5)*100000 + encnum = encodeNumber(latitude - Olatitude) + table.insert(epl,encnum) + encnum = encodeNumber(longitude - Olongitude) + table.insert(epl,encnum) + Olatitude = latitude + Olongitude = longitude + end + end + local string = table.concat(epl) + -- sometimes the sting contains unwanted control characters + local stingwithoutcontrolcharacters = string:gsub("%c", "") + print(stingwithoutcontrolcharacters) + os.exit(0) +end + +if MODE == "gpx2gps" then + local file = io.open(GPFILE, "r") + io.input(file) + while true do + local line = io.read() + if line == nil + then + break + end + if string.match(line, "trkpt") then + local latitude + local longitude + latitude = string.match(line, 'lat="(.-)"') + longitude = string.match(line, 'lon="(.-)"') + print(latitude .. "," .. longitude) + end + end + os.exit(0) +end + +if MODE == "gps2epl" then + local file = io.open(GPFILE, "r") + local Olatitude = 0 + local Olongitude = 0 + local epl = {} + + io.input(file) + while true do + local line = io.read() + if line == nil + then + break + end + local latitude + local longitude + local encnum + latitude, longitude = line:match("([^,]+),([^,]+)") + latitude = round(latitude,5)*100000 + longitude = round(longitude,5)*100000 + encnum = encodeNumber(latitude - Olatitude) + table.insert(epl,encnum) + encnum = encodeNumber(longitude - Olongitude) + table.insert(epl,encnum) + Olatitude = latitude + Olongitude = longitude + end + local string = table.concat(epl) + -- sometimes the sting contains unwanted control characters + local stingwithoutcontrolcharacters = string:gsub("%c", "") + print(stingwithoutcontrolcharacters) + os.exit(0) +end + +print("\n") + if KEY == "" then if MODE == "osm" then KEY="Kmjtd|luu7n162n1,22=o5-h61wh" @@ -609,6 +735,7 @@ ret, msg = http.request{ if not ret then getmap_error(22, msg) end +os.exit(0) %</luafile> %<*cfgfile> % \iffalse @@ -665,51 +792,8 @@ getmap.sty getmap.cfg getmap-example.tex getmapdl.lua -gpx2gps manifest.txt %</manifest> -%<*gpx2gps> -#!/bin/bash -# -# gpx2gps file.gpx -# -# parses file.gpx and outputs a list of -# geographical coordinates latitude,longitude -# -# License: LPPL -# -filename="$1" -version="v1.0 (12/08/2014)" -# -usage() -{ - echo -e "Usage: `basename $0` file.gpx" - echo -e "Version: $version" - exit 1 -} -# -if [ -z "$filename" ] -then - usage -fi -if [ "$filename" = "-h" ] -then - usage -fi -if [ ! -e "$filename" ] -then - echo -e "File $filename does not exist!" - exit 2 -fi -# -for line in `grep -e "<trkpt" $filename | tr ' ' '+'` -do - latitude=`echo "$line" | sed -e 's#.*lat="\(.*\)".*#\1#' -e 's#".*$##'` - longitude=`echo "$line" | sed -e 's#.*lon="\(.*\)".*#\1#' -e 's#".*$##'` - echo "$latitude,$longitude" -done -exit 0 -%</gpx2gps> %<*internal> \fi \def\nameofplainTeX{plain} @@ -776,9 +860,6 @@ This work consists of all files listed in manifest.txt. \generate{ \file{getmapdl.lua}{\from{\jobname.dtx}{luafile}} } -\generate{ - \file{gpx2gps.sh}{\from{\jobname.dtx}{gpx2gps}} -} \ifx\fmtname\nameofplainTeX \expandafter\endbatchfile \else @@ -1033,6 +1114,8 @@ emph={}} % I want to thank Norbert Preining, who did most of the recoding of \texttt{osmimage} % (\texttt{Bash} $\rightarrow$ \texttt{Lua}). Moreover many thanks to Taco Hoekwater, % Reinhard Kotucha and Heiko Oberdiek for their valuable contributions. +% Finally, I want to thank Doug Currie for helping me to implement the algorithm +% for encoded polylines in Lua. % \end{abstract} % \clearpage % \section{Options} @@ -1244,97 +1327,10 @@ path={&path=weight:5|color:orange|Bode Museum, Berlin|% % \fi % % With small enough spaces between way points you can also defines routes! -% The input of these would be very inconvenient. Therefore, Google Maps offers -% an online interactive map tool\footnote{\href{https://developers.google.com/maps/documentation/utilities/polylineutility}{https://developers.google.com/maps/documentation/utilities/polylineutility}}! -% Simply use \texttt{enc:polyline\_data} as location specifier. -% This string can contain all sorts of troublesome characters for \LaTeX{}. -% \cmd\getmap\ can deal with them, with the exception of curly braces! -% These will break your \LaTeX{} document. As a work-around, use the \texttt{pathfile} option. % \subsubsection{\texttt{pathfile}} % This option specifies the file holding the path specification. It will be loaded by the \texttt{Lua} script. % You can use the \env{filecontents*} environment to keep the definition in your document. % It should be a one line utf8-encoded file! -% -% \begin{filecontents*}{muc.epl} -% &path=weight:5|color:orange|enc:okydHa}peAXOHi@jANv@A@kJJmFAiDJuAHmDXcBb@cC`@gC^_DV}CJaCF{APaBVkBdAyEf@qC`@{B\aDSwB -% \end{filecontents*} -% \getmap[file=muc, mode=gm, -% markers={&markers=size:mid|label:H|color:green|München, Hbf -% &markers=label:S|color:yellow|Stachus, München -% &markers=label:M|color:blue|Marienplatz, München}, -% pathfile={muc.epl}]{} -%\includegraphics[width=10cm]{muc} -% \iffalse -%<*example> -% \fi -\begin{lstlisting} -\begin{filecontents*}{muc.epl} -&path=weight:5|color:orange|enc:okydHa}peAXOHi@jANv@A@kJJmFAi% -DJuAHmDXcBb@cC`@gC^_DV}CJaCF{APaBVkBdAyEf@qC`@{B\aDSwB -\end{filecontents*} -\getmap[file=muc, mode=gm, -markers={&markers=size:mid|label:H|color:green|München, Hbf - &markers=label:S|color:yellow|Stachus, München - &markers=label:M|color:blue|Marienplatz, München}, -pathfile={muc.epl}]{} -\includegraphics[width=10cm]{muc} -\end{lstlisting} -% \iffalse -%</example> -% \fi -% -% You can also use an OpenStreetMap based route service\footnote{\href{http://openrouteservice.org}{http://openrouteservice.org}} -% 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!}. -% It's basically a xml-packaged list of geographical coordinates. -% You can use the following one liner\footnote{The attached \texttt{gpx2gps} \texttt{bash} script does the same in a more general way} to clean the file: -% \clearpage -% \iffalse -%<*example> -% \fi -\begin{lstlisting} -grep -e 'trkpt' file.gpx | sed -e 's/^.*lon="//' -e 's/" lat="/,/' --e 's#"/>##' | sed -e 's/^\([^,]*\),\([^,]*\)/\2,\1/' >file.txt -\end{lstlisting} -% \iffalse -%</example> -% \fi -% First, we grep the track point lines, clean the xml parts and finally -% change the order of latitude and longitude. -% Thus, you have a clean list of geographical coordinates, which you can -% copy and paste into this -% \href{http://open.mapquestapi.com/common/encodedecode.html}{Mapquest web service}\footnote{\href{http://open.mapquestapi.com/common/encodedecode.html}{http://open.mapquestapi.com/common/encodedecode.html}} -% to get an encoded polyline! -% -% \begin{filecontents*}{berlin.epl} -% &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 -% \end{filecontents*} -% \getmap[file=berlin, mode=gm, language=de, xsize=400, ysize=600, -% markers={&markers=size:mid|label:H|color:green|Berlin, Hbf -% &markers=label:B|color:blue|Brandenburger Tor, Berlin}, -% pathfile={berlin.epl}]{} -% \includegraphics[width=6cm]{berlin} -% \iffalse -%<*example> -% \fi -\begin{lstlisting} -\begin{filecontents*}{berlin.epl} -&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@JWRSTO% -f@Gh@C^A?e@?gE?w@r@?lB@hA?`@??M?aA?]dI??O?O?Cn@cBfBeF|AeEHNVNBc@H% -@H_AEwA?OAMNA@N -\end{filecontents*} -\getmap[file=berlin, mode=gm, language=de, xsize=400, ysize=600, -markers={&markers=size:mid|label:H|color:green|Berlin, Hbf - &markers=label:B|color:blue|Brandenburger Tor, Berlin}, -pathfile={berlin.epl}]{} -\includegraphics[width=6cm]{berlin} -\end{lstlisting} -% \iffalse -%</example> -% \fi -% -% Please note that the length of the URL is limited to 2048 bytes. So, there's -% no way to support extreme long paths! % \subsection{\texttt{gsv} mode} % \subsubsection[\texttt{xsize}]{\texttt{xsize (\underline{600})}} % This option specifies the width of the map in pixels. (max: 640) @@ -1346,7 +1342,6 @@ pathfile={berlin.epl}]{} % This option specifies the pitch (angle) of the camera view in degrees in the range of -90 -- 90. % \subsubsection[\texttt{fov}]{\texttt{fov (\underline{90})}} % This option specifies the field of horizontal view (kind of zoom) in degrees in the range of 0 -- 120. -% \clearpage % \section{Command(s)} % \subsection[\textbackslash{}getmap]{\cmd\getmap} % With the \cmd\getmap\ command\margcs{\cmd\getmap\oarg{options}\marg{address}} you can download @@ -1373,7 +1368,6 @@ pathfile={berlin.epl}]{} %</example> % \fi % -% \clearpage % \section{Examples}\marginnote{\attachfile[author={Josef Kleber},subject={getmap-example.tex},description={getmap-example.tex (source example)} ,mimetype={text/plain}, icon={Tag}]{getmap-example.tex}} % % The same map as before from Google Maps: @@ -1407,7 +1401,6 @@ pathfile={berlin.epl}]{} % \iffalse %</example> % \fi -% \clearpage % L'afrique, mon amour! % % \getmap[file=africa,mode=gm,type=terrain,xsize=500,ysize=500,scale=2,zoom=3]{0,16} @@ -1438,7 +1431,6 @@ pathfile={berlin.epl}]{} % \iffalse %</example> % \fi -% \clearpage % Street View now: % % \getmap[file=parisgsv,mode=gsv,heading=320,pitch=30,fov=40,xsize=300,ysize=600]{Avenue Piere-Loti, Paris} @@ -1454,6 +1446,7 @@ pathfile={berlin.epl}]{} % \iffalse %</example> % \fi +% \clearpage % and from the platform: % % \getmap[file=parisgsvp,mode=gsv,heading=30,pitch=-25,fov=60]{Tour Eiffel, Paris} @@ -1469,7 +1462,124 @@ pathfile={berlin.epl}]{} % \iffalse %</example> % \fi -% \clearpage +% \section{The \texttt{getmapdl} Lua script} +% Basically, the \texttt{getmapdl} Lua script downloads static map images +% depending on command line options and allows to parse \texttt{gpx} and +% \texttt{gps} (a plain list of geographical coordinate pairs \texttt{(latitude,longitude)} +% on each line) files and outputs \texttt{gps} or encoded polylines (epl). +% The script offers the following modes (\texttt{-m}): +% \begin{description} +% \item[osm] downloads a static map image based on OpenStreetMap data +% \item[gm] downloads a static map image based on Google Maps data +% \item[gsv] downloads an image based on Google Street View data +% \item[gpx2epl] parses a \texttt{gpx} file and outputs encoded polylines (\texttt{epl}) to \texttt{STDOUT} +% \item[gps2epl] parses a \texttt{gps} file and outputs \texttt{epl} +% \item[gpx2gps] parses a \texttt{gpx} file and outputs a list of geographic coordinate pairs (\texttt{gps}) +% \end{description} +% The first three modes are used by \cmd\getmap. You may use the script also from the command line! +% \texttt{getmapdl -h} will give you a list of available commad line options. +% +% The other modes are usefull for creating encoded polylines (\texttt{epl}), which is +% the route format of Google Maps. You can parse the following example from Google Maps in \texttt{gpx} format +% \iffalse +%<*example> +% \fi +\begin{lstlisting} +<trkseg> + <trkpt lon="-120.2" lat="38.5"/> + <trkpt lon="-120.95" lat="40.7"/> + <trkpt lon="-126.453" lat="43.252"/> +</trkseg> +\end{lstlisting} +% \iffalse +%</example> +% \fi +% with +% \iffalse +%<*example> +% \fi +\begin{lstlisting} +$ getmapdl -m gpx2epl -G test.gpx +_p~iF~ps|U_ulLnnqClqNvxq`@ + +\end{lstlisting} +% \iffalse +%</example> +% \fi +% This encoded polyline can be used for the \texttt{path} or \texttt{pathfile} +% option of \cmd\getmap. +% \section{How to define routes} +% One possible way is to use Google Maps +% online interactive map tool\footnote{\href{https://developers.google.com/maps/documentation/utilities/polylineutility}{https://developers.google.com/maps/documentation/utilities/polylineutility}}! +% Simply use \texttt{enc:polyline\_data} as location specifier. +% This string can contain all sorts of troublesome characters for \LaTeX{}. +% \cmd\getmap\ can deal with them, with the exception of curly braces! +% These will break your \LaTeX{} document. As a work-around, use the \texttt{pathfile} option. +% +% \begin{filecontents*}{muc.epl} +% &path=weight:5|color:orange|enc:okydHa}peAXOHi@jANv@A@kJJmFAiDJuAHmDXcBb@cC`@gC^_DV}CJaCF{APaBVkBdAyEf@qC`@{B\aDSwB +% \end{filecontents*} +% \getmap[file=muc, mode=gm, +% markers={&markers=size:mid|label:H|color:green|München, Hbf +% &markers=label:S|color:yellow|Stachus, München +% &markers=label:M|color:blue|Marienplatz, München}, +% pathfile={muc.epl}]{} +%\includegraphics[width=10cm]{muc} +% \iffalse +%<*example> +% \fi +\begin{lstlisting} +\begin{filecontents*}{muc.epl} +&path=weight:5|color:orange|enc:okydHa}peAXOHi@jANv@A@kJJmFAi% +DJuAHmDXcBb@cC`@gC^_DV}CJaCF{APaBVkBdAyEf@qC`@{B\aDSwB +\end{filecontents*} +\getmap[file=muc, mode=gm, +markers={&markers=size:mid|label:H|color:green|München, Hbf + &markers=label:S|color:yellow|Stachus, München + &markers=label:M|color:blue|Marienplatz, München}, +pathfile={muc.epl}]{} +\includegraphics[width=10cm]{muc} +\end{lstlisting} +% \iffalse +%</example> +% \fi +% +% You can also use an OpenStreetMap based route service\footnote{\href{http://openrouteservice.org}{http://openrouteservice.org}} +% 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!}. +% It's basically a xml-packaged list of geographical coordinates. +% You can use the \texttt{getmapdl} script to convert a route to encoded polylines, e.g. +% a pedestrian route from Berlin Central Station to Brandenburg Gate: +% +% \begin{filecontents*}{berlin.epl} +% &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 +% \end{filecontents*} +% \getmap[file=berlin, mode=gm, language=de, xsize=400, ysize=600, +% markers={&markers=size:mid|label:H|color:green|Berlin, Hbf +% &markers=label:B|color:blue|Brandenburger Tor, Berlin}, +% pathfile={berlin.epl}]{} +% \includegraphics[width=6cm]{berlin} +% \iffalse +%<*example> +% \fi +\begin{lstlisting} +\begin{filecontents*}{berlin.epl} +&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@JWRSTO% +f@Gh@C^A?e@?gE?w@r@?lB@hA?`@??M?aA?]dI??O?O?Cn@cBfBeF|AeEHNVNBc@H% +@H_AEwA?OAMNA@N +\end{filecontents*} +\getmap[file=berlin, mode=gm, language=de, xsize=400, ysize=600, +markers={&markers=size:mid|label:H|color:green|Berlin, Hbf + &markers=label:B|color:blue|Brandenburger Tor, Berlin}, +pathfile={berlin.epl}]{} +\includegraphics[width=6cm]{berlin} +\end{lstlisting} +% \iffalse +%</example> +% \fi +% +% Please note that the length of the URL is limited to 2048 bytes. So, there's +% no way to support extreme long paths! % \section{Implementation} % \changes{v1.0}{2014/05/25}{CTAN upload} % \changes{v1.2}{2014/07/11}{added support for Google Maps} @@ -1477,13 +1587,15 @@ pathfile={berlin.epl}]{} % \changes{v1.3}{2014/07/19}{added support for Google Street View} % \changes{v1.4}{2014/07/25}{added options language, markers, visible, path and pathfile in gm mode} % \changes{v1.5}{2014/08/12}{added \texttt{gpx2gps} \texttt{bash} script} +% \changes{v1.6}{2014/08/16}{removed \texttt{gpx2gps} \texttt{bash} script} +% \changes{v1.6}{2014/08/16}{added \texttt{gpx2epl}, \texttt{gps2epl} and \texttt{gpx2gps} modes to \texttt{getmapdl.lua}} % \begin{macrocode} %<*package> % \end{macrocode} % First, we provide the \LaTeX\ package \package{getmap}. % \begin{macrocode} \NeedsTeXFormat{LaTeX2e}% -\ProvidesPackage{getmap}[2014/08/12 v1.5 getmap.sty - Josef Kleber (C) 2014]% +\ProvidesPackage{getmap}[2014/08/16 v1.6 getmap.sty - Josef Kleber (C) 2014]% % \end{macrocode} % We need a few packages! % \begin{macrocode} diff --git a/Master/texmf-dist/doc/latex/getmap/getmap.pdf b/Master/texmf-dist/doc/latex/getmap/getmap.pdf Binary files differindex c50734cdcf3..bd291ed0574 100644 --- a/Master/texmf-dist/doc/latex/getmap/getmap.pdf +++ b/Master/texmf-dist/doc/latex/getmap/getmap.pdf diff --git a/Master/texmf-dist/doc/latex/getmap/install.bat b/Master/texmf-dist/doc/latex/getmap/install.bat index e767153359b..d9c5fb9092e 100755 --- a/Master/texmf-dist/doc/latex/getmap/install.bat +++ b/Master/texmf-dist/doc/latex/getmap/install.bat @@ -19,11 +19,9 @@ makeindex -q -s gind.ist %pckname% >nul makeindex -q -s gglo.ist %pckname%.glo -o %pckname%.gls >nul pdflatex %pckname%.dtx >nul ren README.txt README >nul -ren gpx2gps.sh gpx2gps >nul echo Copying files to %texmfpath% md %texmfpath%\scripts\%pckname% >nul copy getmapdl.lua %texmfpath%\scripts\%pckname%\ >nul -copy gpx2gps %texmfpath%\scripts\%pckname%\ >nul md %texmfpath%\tex\latex\%pckname% >nul copy *.sty %texmfpath%\tex\latex\%pckname% >nul copy *.cfg %texmfpath%\tex\latex\%pckname% >nul @@ -57,7 +55,6 @@ del *.png del *.jpg del *.epl del getmapdl.lua -del gpx2gps del README del getmap.pdf echo Create getmapdl.exe diff --git a/Master/texmf-dist/doc/latex/getmap/makefile b/Master/texmf-dist/doc/latex/getmap/makefile index f5ebcf3f64a..322429c3e0d 100644 --- a/Master/texmf-dist/doc/latex/getmap/makefile +++ b/Master/texmf-dist/doc/latex/getmap/makefile @@ -21,7 +21,6 @@ $(PKGNAME).pdf: package: pdftex $(PKGNAME).dtx mv README.txt README - mv gpx2gps.sh gpx2gps install: doc mkdir -p ${TEXMF}/doc/latex/${PKGNAME} @@ -35,7 +34,6 @@ install: doc cp *.cfg ${TEXMF}/tex/latex/${PKGNAME}/ mkdir -p ${TEXMF}/scripts/${PKGNAME} cp getmapdl.lua ${TEXMF}/scripts/${PKGNAME}/ - cp gpx2gps ${TEXMF}/scripts/${PKGNAME}/ texhash chmod 0755 ${TEXMF}/scripts/${PKGNAME}/getmapdl.lua ln -s ${TEXMF}/scripts/${PKGNAME}/getmapdl.lua ${BINDIR}/getmapdl @@ -52,7 +50,6 @@ styles: package git: package cp getmapdl.lua ./../dev/scripts/getmap/getmapdl.lua - cp gpx2gps ./../dev/scripts/getmap/gpx2gps cp getmap.sty ./../dev/tex/latex/getmap/getmap.sty cp getmap.cfg ./../dev/tex/latex/getmap/getmap.cfg @@ -65,7 +62,7 @@ clean: *.bbl *.blg *.ins *.txt *.bib *.epl cleanall: clean - $(RM) getmapdl.lua gpx2gps *.sty *.png *.jpg\ + $(RM) getmapdl.lua *.sty *.png *.jpg\ *.cfg *.tex README getmap.pdf .PHONY: all doc package install uninstall styles git ctan clean cleanall diff --git a/Master/texmf-dist/doc/latex/getmap/manifest.txt b/Master/texmf-dist/doc/latex/getmap/manifest.txt index c7b1b61918b..b7f6f9043b6 100644 --- a/Master/texmf-dist/doc/latex/getmap/manifest.txt +++ b/Master/texmf-dist/doc/latex/getmap/manifest.txt @@ -12,5 +12,4 @@ getmap.sty getmap.cfg getmap-example.tex getmapdl.lua -gpx2gps manifest.txt diff --git a/Master/texmf-dist/scripts/getmap/getmapdl.lua b/Master/texmf-dist/scripts/getmap/getmapdl.lua index 77d2890cee0..f8dac4aa3cd 100755 --- a/Master/texmf-dist/scripts/getmap/getmapdl.lua +++ b/Master/texmf-dist/scripts/getmap/getmapdl.lua @@ -2,7 +2,8 @@ -- -- getmapdl [options] -- --- downloads an OpenStreetMap, Google Maps or Google Street View map specified by [options] +-- downloads an OpenStreetMap, Google Maps or Google Street View map +-- specified by [options] or parses gpx or gps files to create encoded polylines -- -- License: LPPL -- @@ -34,9 +35,10 @@ local HEADING = "" local FOV = "" local PITCH = "" local LANGUAGE = "" +local GPFILE = "" local OFILE = "getmap" local QUIET = "false" -local VERSION = "v1.2 (25/07/2014)" +local VERSION = "v1.3 (16/08/2014)" function pversion() print("getmapdl.lua " .. VERSION) @@ -48,11 +50,13 @@ function phelp() print([[ getmapdl.lua [options] - downloads an OpenStreetMap or Google Maps map specified by [options] + downloads an OpenStreetMap, Google Maps or Google Street View map + specified by [options] or parses gpx or gps files to create + encoded polylines Options: - -m specify the mode (osm|gm) + -m specify the mode (osm|gm|gsv|gpx2epl|gps2epl|gpx2gps) -l specify a location e.g. 'Bergheimer Straße 110A, 69115 Heidelberg, Germany' @@ -64,7 +68,7 @@ getmapdl.lua [options] -S short form to specify a size, e.g. 600,400 (osm) or 600x400 (gm) -s specify a scale factor in the range 1692-221871572 (osm) or - 1-2 (osm) + 1-2 (gm) -z specify a zoom in the range 1-18 (osm) or 0-21 (17) (gm) @@ -115,6 +119,11 @@ getmapdl.lua [options] -F specify horizontal field of view (90) (0 -- 120) The field of view is expressed in degrees and a kind of zoom! + + gpx2epl, gps2epl and gpx2gps mode only: + + -G specify the gpx or gps file + ]]) pversion() end @@ -141,7 +150,27 @@ function check_range(var,min,max,exitcode,varname) end end -print("\n") +function round(number, precision) + return math.floor(number*math.pow(10,precision)+0.5) / math.pow(10,precision) +end + +function encodeNumber(number) + local num = number + num = num * 2 + if num < 0 + then + num = (num * -1) - 1 + end + local t = {} + while num >= 32 + do + local num2 = 32 + (num % 32) + 63 + table.insert(t,string.char(num2)) + num = math.floor(num / 32) -- use floor to keep integer portion only + end + table.insert(t,string.char(num + 63)) + return table.concat(t) +end do local newarg = {} @@ -210,6 +239,9 @@ do elseif arg[i] == "-p" then FPATH = arg[i+1] i = i + 1 + elseif arg[i] == "-G" then + GPFILE = arg[i+1] + i = i + 1 elseif arg[i] == "-o" then OFILE = arg[i+1] i = i + 1 @@ -231,6 +263,97 @@ if QUIET == 1 then getmap_warning("-q option currently not supported!") end +if MODE == "gpx2epl" then + local file = io.open(GPFILE, "r") + local Olatitude = 0 + local Olongitude = 0 + local epl = {} + + io.input(file) + while true do + local line = io.read() + if line == nil + then + break + end + if string.match(line, "trkpt") then + local latitude + local longitude + local encnum + latitude = string.match(line, 'lat="(.-)"') + longitude = string.match(line, 'lon="(.-)"') + latitude = round(latitude,5)*100000 + longitude = round(longitude,5)*100000 + encnum = encodeNumber(latitude - Olatitude) + table.insert(epl,encnum) + encnum = encodeNumber(longitude - Olongitude) + table.insert(epl,encnum) + Olatitude = latitude + Olongitude = longitude + end + end + local string = table.concat(epl) + -- sometimes the sting contains unwanted control characters + local stingwithoutcontrolcharacters = string:gsub("%c", "") + print(stingwithoutcontrolcharacters) + os.exit(0) +end + +if MODE == "gpx2gps" then + local file = io.open(GPFILE, "r") + io.input(file) + while true do + local line = io.read() + if line == nil + then + break + end + if string.match(line, "trkpt") then + local latitude + local longitude + latitude = string.match(line, 'lat="(.-)"') + longitude = string.match(line, 'lon="(.-)"') + print(latitude .. "," .. longitude) + end + end + os.exit(0) +end + +if MODE == "gps2epl" then + local file = io.open(GPFILE, "r") + local Olatitude = 0 + local Olongitude = 0 + local epl = {} + + io.input(file) + while true do + local line = io.read() + if line == nil + then + break + end + local latitude + local longitude + local encnum + latitude, longitude = line:match("([^,]+),([^,]+)") + latitude = round(latitude,5)*100000 + longitude = round(longitude,5)*100000 + encnum = encodeNumber(latitude - Olatitude) + table.insert(epl,encnum) + encnum = encodeNumber(longitude - Olongitude) + table.insert(epl,encnum) + Olatitude = latitude + Olongitude = longitude + end + local string = table.concat(epl) + -- sometimes the sting contains unwanted control characters + local stingwithoutcontrolcharacters = string:gsub("%c", "") + print(stingwithoutcontrolcharacters) + os.exit(0) +end + +print("\n") + if KEY == "" then if MODE == "osm" then KEY="Kmjtd|luu7n162n1,22=o5-h61wh" @@ -474,3 +597,4 @@ ret, msg = http.request{ if not ret then getmap_error(22, msg) end +os.exit(0) diff --git a/Master/texmf-dist/scripts/getmap/gpx2gps b/Master/texmf-dist/scripts/getmap/gpx2gps deleted file mode 100755 index 1dc51b23614..00000000000 --- a/Master/texmf-dist/scripts/getmap/gpx2gps +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -# -# gpx2gps file.gpx -# -# parses file.gpx and outputs a list of -# geographical coordinates latitude,longitude -# -# License: LPPL -# -filename="$1" -version="v1.0 (12/08/2014)" -# -usage() -{ - echo -e "Usage: `basename $0` file.gpx" - echo -e "Version: $version" - exit 1 -} -# -if [ -z "$filename" ] -then - usage -fi -if [ "$filename" = "-h" ] -then - usage -fi -if [ ! -e "$filename" ] -then - echo -e "File $filename does not exist!" - exit 2 -fi -# -for line in `grep -e "<trkpt" $filename | tr ' ' '+'` -do - latitude=`echo "$line" | sed -e 's#.*lat="\(.*\)".*#\1#' -e 's#".*$##'` - longitude=`echo "$line" | sed -e 's#.*lon="\(.*\)".*#\1#' -e 's#".*$##'` - echo "$latitude,$longitude" -done -exit 0 diff --git a/Master/texmf-dist/tex/latex/getmap/getmap.sty b/Master/texmf-dist/tex/latex/getmap/getmap.sty index 7d1d54e6f27..cad23cbdd0c 100644 --- a/Master/texmf-dist/tex/latex/getmap/getmap.sty +++ b/Master/texmf-dist/tex/latex/getmap/getmap.sty @@ -27,7 +27,7 @@ %% This work consists of all files listed in manifest.txt. %% \NeedsTeXFormat{LaTeX2e}% -\ProvidesPackage{getmap}[2014/08/12 v1.5 getmap.sty - Josef Kleber (C) 2014]% +\ProvidesPackage{getmap}[2014/08/16 v1.6 getmap.sty - Josef Kleber (C) 2014]% \RequirePackage{xkeyval}% \RequirePackage{stringenc}% \RequirePackage{ifthen}% |