diff options
author | Karl Berry <karl@freefriends.org> | 2014-07-16 22:37:21 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2014-07-16 22:37:21 +0000 |
commit | 58ded3c00a780a49c9e7f0f3d9e66e2619a03056 (patch) | |
tree | 3d4368c6672fa6f48e43dee21aeae588806e5480 /Master/texmf-dist | |
parent | 966482b48825b6eb8921b32c685b0ce8805480f8 (diff) |
getmap (16jul14)
git-svn-id: svn://tug.org/texlive/trunk@34634 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/latex/getmap/README | 40 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/getmap/getmap-example.tex | 45 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/getmap/getmap.dtx | 852 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/getmap/getmap.pdf | bin | 516085 -> 1288925 bytes | |||
-rwxr-xr-x | Master/texmf-dist/doc/latex/getmap/install.bat | 25 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/getmap/makefile | 24 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/getmap/manifest.txt | 8 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/getmap/osmimage.png | bin | 444079 -> 0 bytes | |||
-rw-r--r-- | Master/texmf-dist/scripts/getmap/getmapdl.lua | 381 | ||||
-rw-r--r-- | Master/texmf-dist/scripts/getmap/osmimage | 224 | ||||
-rwxr-xr-x | Master/texmf-dist/scripts/getmap/osmimage.lua | 261 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/getmap/getmap.cfg | 39 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/getmap/getmap.sty | 51 |
13 files changed, 1028 insertions, 922 deletions
diff --git a/Master/texmf-dist/doc/latex/getmap/README b/Master/texmf-dist/doc/latex/getmap/README index bd1438fd0b1..ff8daf21794 100644 --- a/Master/texmf-dist/doc/latex/getmap/README +++ b/Master/texmf-dist/doc/latex/getmap/README @@ -1,38 +1,47 @@ The goal of this package is the simplest possible provision of -OpenStreetMap maps. In the simplest case, the specification of -the address is sufficient. The package loads the map using the -\write18 feature, which you must activate to use this package. -The image will be downloaded by an external Lua script. You can -use this script, as well as the attached bash script also from -the command line. +map images (OpenStreetMap and Google Maps are supported). In the +simplest case, the specification of an address is sufficient. +The package loads the map using the \write18 feature, which you +must activate to use this package. The image will be downloaded +by an external Lua script. You can use this script, as well as +the attached bash script also from the command line. License: LPPL -Changes in v1.1: +Changes in v1.2: -- Bugfix: problem in URL with \usepackage[utf8]{inputenc} +- added support for Google Maps - reported by: Ulrike Fischer + * new option mode + * renamed osmimage.lua -> getmapdl.lua + * changed defaults for xsize (600) and file (getmap) + * broader support of satellite and hybrid images + * new map type terrain + * much smaller files for maps + (less details like house numbers) -- added makefile and install.bat - for easy manual installation +- added more examples to the documentation + +- added getmap.cfg to store default key (osm) + + feature request by: Ulrike Fischer INSTALL =========== First of all, install the package with the package manager of -your TeX distribution, if possible. +your TeX distribution, if possible! A getmap package is +available for TeXLive2014+ and MiKTeX! Manual installation: -download getmap.dtx, osmimage.png and -makefile (Linux) or install.bat (Windows) +download getmap.dtx and makefile (Linux) or install.bat (Windows) * Linux simply run make to extract the files and to create the documentation. Run sudo make install to copy the files - in $TEXMFLOCAL + into $TEXMFLOCAL Moreover, there are the following usefull make targets: @@ -40,7 +49,6 @@ makefile (Linux) or install.bat (Windows) package only extracts the files clean cleans all aux files cleanall cleans all files except the downloaded files - and getmap.pdf * Windows diff --git a/Master/texmf-dist/doc/latex/getmap/getmap-example.tex b/Master/texmf-dist/doc/latex/getmap/getmap-example.tex new file mode 100644 index 00000000000..8029e5f0cfe --- /dev/null +++ b/Master/texmf-dist/doc/latex/getmap/getmap-example.tex @@ -0,0 +1,45 @@ +%% +%% This is file `getmap-example', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% getmap.dtx (with options: `examplefile') +%% +%% Copyright (C) 2014 by: +%% Josef Kleber +%% <josef.kleber@gmx.de> +%% +%% This file may be distributed and/or modified under the conditions of +%% the LaTeX Project Public License, either version 1.3 of this license +%% or (at your option) any later version. The latest version of this +%% license is in: +%% +%% http://www.latex-project.org/lppl.txt +%% +%% and version 1.3 or later is part of all distributions of LaTeX version +%% 2003/12/01 or later. +%% +%% This work has the LPPL maintenance status "author-maintained". +%% +%% The Current Maintainer of this work is Josef Kleber. +%% +%% This work consists of all files listed in manifest.txt. +%% +%% +%% +%% compile with pdflatex -shell-escape getmap-example +%% +%% +\documentclass{article} +\usepackage[utf8]{inputenc} +\usepackage{graphicx} +%% use overwrite while optimizing the image +\usepackage[overwrite,mode=gm]{getmap} +\begin{document} +\getmap[type=satellite,scale=2,zoom=16]{Estádio do Maracanã, Rio de Janeiro} +\includegraphics[width=10cm]{getmap} +\end{document} +\endinput +%% +%% End of file `getmap-example'. diff --git a/Master/texmf-dist/doc/latex/getmap/getmap.dtx b/Master/texmf-dist/doc/latex/getmap/getmap.dtx index ecd02887ade..c76b98c7db5 100644 --- a/Master/texmf-dist/doc/latex/getmap/getmap.dtx +++ b/Master/texmf-dist/doc/latex/getmap/getmap.dtx @@ -5,41 +5,50 @@ %</internal> %<*readme> The goal of this package is the simplest possible provision of -OpenStreetMap maps. In the simplest case, the specification of -the address is sufficient. The package loads the map using the -\write18 feature, which you must activate to use this package. -The image will be downloaded by an external Lua script. You can -use this script, as well as the attached bash script also from -the command line. +map images (OpenStreetMap and Google Maps are supported). In the +simplest case, the specification of an address is sufficient. +The package loads the map using the \write18 feature, which you +must activate to use this package. The image will be downloaded +by an external Lua script. You can use this script, as well as +the attached bash script also from the command line. License: LPPL -Changes in v1.1: +Changes in v1.2: -- Bugfix: problem in URL with \usepackage[utf8]{inputenc} - - reported by: Ulrike Fischer +- added support for Google Maps -- added makefile and install.bat - for easy manual installation + * new option mode + * renamed osmimage.lua -> getmapdl.lua + * changed defaults for xsize (600) and file (getmap) + * broader support of satellite and hybrid images + * new map type terrain + * much smaller files for maps + (less details like house numbers) + +- added more examples to the documentation + +- added getmap.cfg to store default key (osm) + + feature request by: Ulrike Fischer INSTALL =========== First of all, install the package with the package manager of -your TeX distribution, if possible. +your TeX distribution, if possible! A getmap package is +available for TeXLive2014+ and MiKTeX! Manual installation: -download getmap.dtx, osmimage.png and -makefile (Linux) or install.bat (Windows) +download getmap.dtx and makefile (Linux) or install.bat (Windows) * Linux simply run make to extract the files and to create the documentation. Run sudo make install to copy the files - in $TEXMFLOCAL + into $TEXMFLOCAL Moreover, there are the following usefull make targets: @@ -47,8 +56,6 @@ makefile (Linux) or install.bat (Windows) package only extracts the files clean cleans all aux files cleanall cleans all files except the downloaded files - and getmap.pdf - * Windows @@ -65,270 +72,45 @@ makefile (Linux) or install.bat (Windows) @misc{bib:devmapquest, author = {{MapQuest, Inc}}, note = {\href{http://developer.mapquest.com}{http://developer.mapquest.com}}, - title = {Introducing the Data Manager API Web Service}, + title = {{Introducing the Data Manager API Web Service}}, year = {2014}, } @misc{bib:mapquestopen, author = {{MapQuest, Inc}}, note = {\href{http://open.mapquestapi.com/}{http://open.mapquestapi.com/}}, - title = {MapQuest Open Platform Web Services}, + title = {{MapQuest Open Platform Web Services}}, year = {2014}, } @misc{bib:mapquestopenzoomscale, author = {{MapQuest, Inc}}, note = {\href{http://open.mapquestapi.com/staticmap/zoomToScale.html}{http://open.mapquestapi.com/staticmap/zoomToScale.html}}, - title = {Zoom To Scale Mapping}, + title = {{Zoom To Scale Mapping}}, year = {2014}, } @misc{bib:mapquestopencolors, author = {{MapQuest, Inc}}, note = {\href{http://open.mapquestapi.com/staticmap/icons.html}{http://open.mapquestapi.com/staticmap/icons.html}}, - title = {Static Map Service: Standard Icons}, + title = {{Static Map Service: Standard Icons}}, + year = {2014}, + } + +@misc{bib:googlemapsapi, + author = {{Google, Inc.}}, + note = {\href{https://developers.google.com/maps/documentation/staticmaps/}{https://developers.google.com/maps/documentation/staticmaps/}}, + title = {{Static Maps API V2 Developer Guide}}, year = {2014}, } %</bibfile> -%<*bashfile> -#!/bin/bash -# -# osmimage [options] -# -# downloads an OpenStreetMap map specified by [options] -# by using http://developer.mapquest.com/ web service -# -# License: LPPL -# -pversion() -{ - echo "`basename $0` $VERSION" - echo "(C) Josef Kleber License: LPPL" - exit 0; -} -# -function phelp() -{ - echo -e \ - "\n `basename $0` [options]\n\n"\ - " downloads an OpenStreetMap map specified by [options]\n"\ - " by using http://developer.mapquest.com/ web service\n\n"\ - " Options:\n\n"\ - " -k key registered at http://developer.mapquest.com/\n"\ - " default (Example key from web site)!\n"\ - " Please register and use your own key!\n\n"\ - " -l specify a location\n"\ - " e.g. 'Bergheimer Straße 110A, 69115 Heidelberg, Germany'\n\n"\ - " -x specify a xsize (800)\n\n"\ - " -y specify a ysize (400)\n\n"\ - " -S short form to specify a size, e.g. 800,400\n\n"\ - " -s specify a scale factor in the range 1692-221871572 (3385 = -z 17)\n"\ - " see: http://open.mapquestapi.com/staticmap/zoomToScale.html\n\n"\ - " -z specify a zoom in the range 1-18 (zoom overrides scale!)\n\n"\ - " -t specify map type {map|sat|hyb} (map)\n\n"\ - " -i specify image type {jpeg|jpg|gif|png} (png)\n\n"\ - " -c specify icon color (yellow_1)\n"\ - " see: http://open.mapquestapi.com/staticmap/icons.html\n\n"\ - " -n specify the icon number (1)\n\n"\ - " -o specify output basename without file extension (osmimage.IMAGETYPE)\n\n"\ - " -q quiet; no output!\n\n"\ - " -v prints version information\n\n"\ - " -h prints help information\n\n" - pversion -} -# -osmimage_error() -{ - local exitcode="$1" - local errortext="$2" - echo "Error ($exitcode): $errortext" >&2 - exit $exitcode -} -# -osmimage_warning() -{ - local warningtext="$1" - echo -e "WARNING: $warningtext\n" >&2 -} -# -check_prog() -{ - local prog="$1" - hash $prog 2>/dev/null || osmimage_error 1 "$prog not installed! Aborting." -} -# -check_number() -{ - local var="$1" - local varname="$2" - local number='^[0-9]+$' - if ! [[ $var =~ $number ]] - then - osmimage_error 2 "$varname can't be $var! Not a number!" - fi -} -# -check_range() -{ - local var="$1" - local min="$2" - local max="$3" - local exitcode="$4" - local varname="$5" - check_number $var $varname - if [ $var -lt $min ] - then - osmimage_error $exitcode "$varname = $var; must be in the range of $min-$max" - fi - if [ $var -gt $max ] - then - osmimage_error $exitcode "$varname = $var; must be in the range of $min-$max" - - fi -} -# -check_prog wget -# -URL="http://open.mapquestapi.com/staticmap/v4/getplacemap" -KEY="" -LOCATION="" -XSIZE="" -YSIZE="" -SCALE="" -ZOOM="" -TYPE="" -IMAGETYPE="" -COLOR="" -NUMBER="" -OFILE="osmimage" -QUIET="false" -VERSION="v1.2 (23/05/2014)" -# -while getopts "k:l:x:y:S:s:z:t:i:c:n:o:qvh" flag -do - case "$flag" in - k) KEY="$OPTARG";; - l) LOCATION="$OPTARG";; - x) XSIZE="$OPTARG";; - y) YSIZE="$OPTARG";; - S) SIZE="$OPTARG";; - s) SCALE="$OPTARG";; - z) ZOOM="$OPTARG";; - t) TYPE="$OPTARG";; - i) IMAGETYPE="$OPTARG";; - c) COLOR="$OPTARG";; - n) NUMBER="$OPTARG";; - o) OFILE="$OPTARG";; - q) QUIET="true";; - v) pversion;; - h) phelp;; - esac -done -# -if [ "$QUIET" = "true" ] -then - exec 1>/dev/null - exec 2>/dev/null -fi -# -if [ -z $KEY ] -then - KEY="Kmjtd%7Cluu7n162n1%2C22%3Do5-h61wh" - osmimage_warning "KEY not specified; using mapquest example key as default!" -fi -# -if [ -z $LOCATION ] -then - LOCATION="Bergheimer Straße 110A, 69115 Heidelberg, Germany" - osmimage_warning "LOCATION not specified; using Dante e.V. Office as default!" -fi -# -if [ -z $XSIZE ] -then - XSIZE=800 - osmimage_warning "XSIZE not specified; using XSIZE=800 as default!" -fi -check_range $XSIZE 1 3840 11 XSIZE -# -if [ -z $YSIZE ] -then - YSIZE=400 - osmimage_warning "YSIZE not specified; using YSIZE=400 as default!" -fi -check_range $YSIZE 1 3840 12 YSIZE -# -if [ -z $SIZE ] -then - SIZE="$XSIZE,$YSIZE" -fi -# -if [ -z $SCALE ] -then - if [ -z $ZOOM ] - then - SCALE=3385 - osmimage_warning "SCALE not specified, using SCALE=3385 as default!" - fi -else - check_range $SCALE 1692 221871572 13 SCALE -fi -# -if [ -z $TYPE ] -then - TYPE="map" - osmimage_warning "TYPE not specified; using map as default!" -fi -# -if [ -z $IMAGETYPE ] -then - IMAGETYPE="png" - osmimage_warning "IMAGETYPE not specified; using png as default!" -fi -# -if [ -z $COLOR ] -then - COLOR="yellow_1" - osmimage_warning "COLOR not specified; using yellow_1 as default!" -fi -if [ -z $NUMBER ] -then - NUMBER=1 - osmimage_warning "NUMBER not specified; using 1 as default!" -fi -check_number $NUMBER NUMBER -# -ULOCATION="&location=$LOCATION" -USIZE="&size=$SIZE" -if [ -z $ZOOM ] -then - USCALEZOOM="&scale=$SCALE" -else - check_range $ZOOM 1 18 14 ZOOM - USCALEZOOM="&zoom=$ZOOM" -fi -UTYPE="&type=$TYPE" -UIMAGETYPE="&imagetype=$IMAGETYPE" -USHOWICON="&showicon=${COLOR}-${NUMBER}" -UOFILE="${OFILE}.${IMAGETYPE}" -# -IMGURL="${URL}?key=${KEY}${ULOCATION}${USIZE}${USCALEZOOM}${UTYPE}${UIMAGETYPE}${USHOWICON}" -# -wget "$IMGURL" -O "$UOFILE" -exit 0 -%</bashfile> %<*luafile> #!/usr/bin/env texlua -- --- osmimage [options] +-- getmapdl [options] -- --- downloads an OpenStreetMap map specified by [options] --- by using http://developer.mapquest.com/ web service --- --- recoding the osmimage bash script to lua was mostly done --- by Norbert Preining with valuable inputs from --- Taco Hoekwater, Reinhard Kotucha and Heiko Oberdiek --- Message-ID: <537A098C.8000902@gmx.de> ff +-- downloads an OpenStreetMap or Google Maps map specified by [options] -- -- License: LPPL -- @@ -336,10 +118,13 @@ local http = require("socket.http"); local ltn12 = require("ltn12") local url = require("socket.url") -local URL = "http://open.mapquestapi.com/staticmap/v4/getplacemap" +local OSMURL = "http://open.mapquestapi.com/staticmap/v4/getplacemap" +local GMURL = "http://maps.googleapis.com/maps/api/staticmap" local KEY = "" +local MODE = "" local LOCATION = "" local XSIZE = "" +local CENTER = "" local YSIZE = "" local SIZE = "" local SCALE = "" @@ -348,54 +133,56 @@ local TYPE = "" local IMAGETYPE = "" local COLOR = "" local NUMBER = "" -local OFILE = "osmimage" +local VISIBLE = "" +local IPATH = "" +local MARKERS = "" +local OFILE = "getmap" local QUIET = "false" -local VERSION = "v1.2 (23/05/2014)" - +local VERSION = "v1.0 (15/07/2014)" function pversion() - print("osmimage.lua " .. VERSION) + print("getmapdl.lua " .. VERSION) print("(C) Josef Kleber License: LPPL") os.exit(0) end function phelp() print([[ -osmimage.lua [options] +getmapdl.lua [options] - downloads an OpenStreetMap map specified by [options] - by using http://developer.mapquest.com/ web service + downloads an OpenStreetMap or Google Maps map specified by [options] Options: - -k key registered at http://developer.mapquest.com/ - default (Example key from web site)! - Please register and use your own key! - + -m specify the mode (osm|gm) + -l specify a location e.g. 'Bergheimer Straße 110A, 69115 Heidelberg, Germany' - -x specify a xsize (800) + -x specify a xsize (600) -y specify a ysize (400) - -S short form to specify a size, e.g. 800,400 + -S short form to specify a size, e.g. 600,400 (osm) or 600x400 (gm) - -s specify a scale factor in the range 1692-221871572 (3385 = -z 17) - see: http://open.mapquestapi.com/staticmap/zoomToScale.html + -s specify a scale factor in the range 1692-221871572 (osmm) or + 1-2 (osm) - -z specify a zoom in the range 1-18 (zoom overrides scale!) + -z specify a zoom in the range 1-18 (osm) or 0-21 (17) (gm) - -t specify map type {map|sat|hyb} (map) + -t specify map type {map|sathyb} (map) (osm) or + {roadmap|satellite|hybrid|terrain} (roadmap) (gm) - -i specify image type {jpeg|jpg|gif|png} (png) + -i specify image type {png|gif|jpg|jpeg} (png) (osm) or + {png|png8|png32|gif|jpg|jpg-baseline} (png) (gm) - -c specify icon color (yellow_1) + -c specify icon color (yelow_1) (osm) or (blue) (gm) see: http://open.mapquestapi.com/staticmap/icons.html + https://developers.google.com/maps/documentation/staticmaps/#MarkerStyles -n specify the icon number (1) - -o specify output basename without file extension (osmimage.IMAGETYPE) + -o specify output basename without file extension (getmap.IMAGETYPE) -q quiet; no output! @@ -403,31 +190,44 @@ osmimage.lua [options] -h prints help information + gm mode only: + + -M specify markers; see: + https://developers.google.com/maps/documentation/staticmaps/index#Markers + e.g.: &markers=size:mid|color:blue|label:1|address or more of these + location and zoom will be ignored if used! + + -C specify center of the map + + -V specify a list of visible locations (loc1|loc2) + + -P specify path from location to location + e.g.: &path=weight:7|color:purple|loc1|loc2 + ]]) pversion() end -function osmimage_error(exitcode, errortext) +function getmap_error(exitcode, errortext) io.stderr:write ("Error (" .. exitcode .. "): " .. errortext .. "\n") os.exit(exitcode) end -function osmimage_warning(warningtext) +function getmap_warning(warningtext) io.stderr:write("WARNING: " .. warningtext .. "\n") end - function check_number(var, varname) local number='^[0-9]+$' if not(string.match(var, '^[0-9]+$')) then - osmimage_error(2, varname .. " can't be " .. var .. "! Not a number!") + getmap_error(2, varname .. " can't be " .. var .. "! Not a number!") end end function check_range(var,min,max,exitcode,varname) check_number(var,varname) if (tonumber(var) < tonumber(min) or tonumber(var) > tonumber(max)) then - osmimage_error(exitcode, varname .. " = " .. var .. "; must be in the range of " .. min .. "-" .. max) + getmap_error(exitcode, varname .. " = " .. var .. "; must be in the range of " .. min .. "-" .. max) end end @@ -435,12 +235,18 @@ do local newarg = {} local i, limit = 1, #arg while (i <= limit) do - if arg[i] == "-k" then - KEY = arg[i+1] - i = i + 1 - elseif arg[i] == "-l" then + if arg[i] == "-l" then LOCATION = arg[i+1] i = i + 1 + elseif arg[i] == "-C" then + CENTER = arg[i+1] + i = i + 1 + elseif arg[i] == "-m" then + MODE = arg[i+1] + i = i + 1 + elseif arg[i] == "-k" then + KEY = arg[i+1] + i = i + 1 elseif arg[i] == "-x" then XSIZE = arg[i+1] i = i + 1 @@ -468,6 +274,15 @@ do elseif arg[i] == "-n" then NUMBER = arg[i+1] i = i + 1 + elseif arg[i] == "-M" then + MARKERS = arg[i+1] + i = i + 1 + elseif arg[i] == "-V" then + VISIBLE = arg[i+1] + i = i + 1 + elseif arg[i] == "-P" then + IPATH = arg[i+1] + i = i + 1 elseif arg[i] == "-o" then OFILE = arg[i+1] i = i + 1 @@ -485,93 +300,184 @@ do arg = newarg end - if QUIET == 1 then - osmimage_warning("-q option currently not supported!") + getmap_warning("-q option currently not supported!") end if KEY == "" then - -- KEY="Kmjtd%7Cluu7n162n1%2C22%3Do5-h61wh" - KEY="Kmjtd|luu7n162n1,22=o5-h61wh" - osmimage_warning("KEY not specified; using mapquest example key as default!") + if MODE == "osm" then + KEY="Kmjtd|luu7n162n1,22=o5-h61wh" + getmap_warning("KEY not specified; using mapquest example key as default!") + end end if LOCATION == "" then LOCATION = "Bergheimer Straße 110A, 69115 Heidelberg, Germany" - osmimage_warning("LOCATION not specified; using Dante e.V. Office as default!") + getmap_warning("LOCATION not specified; using Dante e.V. Office as default!") end -if XSIZE == "" then - XSIZE=800 - osmimage_warning("XSIZE not specified; using XSIZE=800 as default!") +if MODE == "gm" then + if ZOOM == "" then + ZOOM=17 + getmap_warning("ZOOM not specified; using ZOOM=17 as default!") + end end -check_range(XSIZE,1,3840,11,"XSIZE") +if XSIZE == "" then + XSIZE=600 + getmap_warning("XSIZE not specified; using XSIZE=600 as default!") +end if YSIZE == "" then YSIZE=400 - osmimage_warning("YSIZE not specified; using YSIZE=400 as default!") + getmap_warning("YSIZE not specified; using YSIZE=400 as default!") end -check_range(YSIZE,1,3840,12,"YSIZE") if SIZE == "" then - SIZE = XSIZE .. "," .. YSIZE + if MODE == "gm" then + SIZE = XSIZE .. "x" .. YSIZE + elseif MODE == "osm" then + SIZE = XSIZE .. "," .. YSIZE + end end if SCALE == "" then - if ZOOM == "" then - SCALE=3385 - osmimage_warning("SCALE not specified, using SCALE=3385 as default!") + if MODE == "gm" then + SCALE=1 + getmap_warning("SCALE not specified, using SCALE=1 as default!") + elseif MODE == "osm" then + if ZOOM == "" then + SCALE=3385 + getmap_warning("SCALE not specified, using SCALE=3385 as default!") + end end -else - check_range(SCALE,1692,221871572,13,"SCALE") end if TYPE == "" then - TYPE = "map" - osmimage_warning("TYPE not specified; using map as default!") + if MODE == "gm" then + TYPE = "roadmap" + getmap_warning("TYPE not specified; using roadmap as default!") + elseif MODE == "osm" then + TYPE = "map" + getmap_warning("TYPE not specified; using map as default!") + end end if IMAGETYPE == "" then IMAGETYPE="png" - osmimage_warning("IMAGETYPE not specified; using png as default!") + getmap_warning("IMAGETYPE not specified; using png as default!") end if COLOR == "" then - COLOR="yellow_1" - osmimage_warning("COLOR not specified; using yellow_1 as default!") + if MODE == "gm" then + COLOR="blue" + getmap_warning("COLOR not specified; using blue as default!") + elseif MODE == "osm" then + COLOR="yellow_1" + getmap_warning("COLOR not specified; using yellow_1 as default!") + end end if NUMBER == "" then NUMBER=1 - osmimage_warning("NUMBER not specified; using 1 as default!") + getmap_warning("NUMBER not specified; using 1 as default!") end -check_number(NUMBER,"NUMBER") - -local UKEY = "?key=" .. url.escape(KEY) -local ULOCATION = "&location=" .. url.escape(LOCATION) -local USIZE = "&size=" .. url.escape(SIZE) -local USCALEZOOM -if ZOOM == "" then - USCALEZOOM = "&scale=" .. url.escape(SCALE) -else - check_range(ZOOM,1,18,14,"ZOOM") - USCALEZOOM = "&zoom=" .. url.escape(ZOOM) + +if MODE == "gm" then + if ZOOM == "" then + ZOOM = 17 + else + check_range(ZOOM,0,21,11,"ZOOM") + end + check_range(XSIZE,1,640,12,"XSIZE") + check_range(YSIZE,1,640,13,"YSIZE") + check_range(SCALE,1,2,14,"SCALE") +elseif MODE == "osm" then + check_range(XSIZE,1,3840,11,"XSIZE") + check_range(YSIZE,1,3840,12,"YSIZE") + if ZOOM == "" then + check_range(SCALE,1692,221871572,13,"SCALE") + else + check_range(ZOOM,1,18,14,"ZOOM") + end + check_number(NUMBER,"NUMBER") end -local UTYPE = "&type=" .. url.escape(TYPE) -local UIMAGETYPE = "&imagetype=" .. url.escape(IMAGETYPE) -local USHOWICON = "&showicon=" .. url.escape(COLOR) .. "-" .. url.escape(NUMBER) -local UOFILE = OFILE .. "." .. IMAGETYPE -local IMGURL = URL .. UKEY .. ULOCATION .. USIZE .. USCALEZOOM .. UTYPE .. UIMAGETYPE .. USHOWICON +local UKEY = "" +local ULOCATION = "" +local UZOOM = "" +local USCALEZOOM = "" +local UMARKERS = "" +local USIZE = "" +local USCALE = "" +local UTYPE = "" +local USHOWICON = "" +local UIMAGETYPE = "" +local UVISIBLE = "" +local UIPATH = "" +local UOFILE = "" +local IMGURL = "" + +if MODE == "gm" then + ULOCATION = "center=" .. url.escape(LOCATION) + if MARKERS == "" then + UMARKERS = "&markers=size:mid|color:" .. COLOR .. "|label:" .. NUMBER .. "|" .. url.escape(LOCATION) + UZOOM = "&zoom=" .. url.escape(ZOOM) + else + UMARKERS = "" .. url.escape(MARKERS) + -- correct cruft escaping of "&markers=" + UMARKERS = UMARKERS:gsub("%%26markers%%3d","&markers=") + UZOMM = "" + if CENTER == "" then + ULOCATION = "" + else + ULOCATION = "center=" .. url.escape(CENTER) + end + end + USIZE = "&size=" .. url.escape(SIZE) + USCALE = "&scale=" .. url.escape(SCALE) + UTYPE = "&maptype=" .. url.escape(TYPE) + UIMAGETYPE = "&format=" .. url.escape(IMAGETYPE) + if IMAGETYPE == "jpg-baseline" then + IMAGETYPE = "jpg" + end + if VISIBLE == "" then + UVISIBLE = "" + else + UVISIBLE = "&visible=" .. url.escape(VISIBLE) + end + if IPATH == "" then + UIPATH = "" + else + UIPATH = "" .. url.escape(IPATH) + -- correct cruft escaping of "&path=" + UIPATH = UIPATH:gsub("%%26path%%3d","&path=") + end + UOFILE = OFILE .. "." .. IMAGETYPE + IMGURL = GMURL .. "?" .. ULOCATION .. USIZE .. UZOOM .. UMARKERS .. UTYPE .. USCALE .. UIMAGETYPE .. UVISIBLE .. UIPATH .. "&sensor=false" +elseif MODE == "osm" then + UKEY = "?key=" .. url.escape(KEY) + ULOCATION = "&location=" .. url.escape(LOCATION) + USIZE = "&size=" .. url.escape(SIZE) + if ZOOM == "" then + USCALEZOOM = "&scale=" .. url.escape(SCALE) + else + USCALEZOOM = "&zoom=" .. url.escape(ZOOM) + end + UTYPE = "&type=" .. url.escape(TYPE) + UIMAGETYPE = "&imagetype=" .. url.escape(IMAGETYPE) + USHOWICON = "&showicon=" .. url.escape(COLOR) .. "-" .. url.escape(NUMBER) + UOFILE = OFILE .. "." .. IMAGETYPE + IMGURL = OSMURL .. UKEY .. ULOCATION .. USIZE .. USCALEZOOM .. UTYPE .. UIMAGETYPE .. USHOWICON +end local ret, msg local ofile ofile, msg = io.open(UOFILE, "wb") if not ofile then - osmimage_error(21, msg) + getmap_error(21, msg) end -print("\n\nosmimage.lua:") +print("\n\ngetmap.lua:") print("url = " .. IMGURL) print("output = " .. UOFILE) ret, msg = http.request{ @@ -579,19 +485,56 @@ ret, msg = http.request{ sink = ltn12.sink.file(ofile) } if not ret then - osmimage_error(22, msg) + getmap_error(22, msg) end - %</luafile> +%<*cfgfile> +% \iffalse +%% +%% +%% copy this file to your local or home tree +%% and put it under TEXMF/tex/latex/getmap +%% run texhash afterwards +%% +%% +% \fi +\gdef\GM@JK@key{Fmjtd|luur20u22d,75=o5-9aylh6}% +%</cfgfile> +%<*examplefile> +% \iffalse +%% +%% +%% compile with pdflatex -shell-escape getmap-example +%% +%% +% \fi +\documentclass{article} +\usepackage[utf8]{inputenc} +\usepackage{graphicx} +% \iffalse +%% use overwrite while optimizing the image +% \fi +\usepackage[overwrite,mode=gm]{getmap} +\begin{document} +\getmap[type=satellite,scale=2,zoom=16]{Estádio do Maracanã, Rio de Janeiro} +\includegraphics[width=10cm]{getmap} +\end{document} +%</examplefile> %<*manifest> This work consists of the following files: getmap.pdf getmap.dtx -osmimage.png README makefile install.bat + +Files packaged in getmap.dtx: + +getmap.sty +getmap.cfg +getmap-example.tex +getmapdl.lua %</manifest> %<*internal> \fi @@ -632,6 +575,12 @@ This work consists of all files listed in manifest.txt. \generate{ \file{\jobname.sty}{\from{\jobname.dtx}{package}} } +\generate{ + \file{\jobname.cfg}{\from{\jobname.dtx}{cfgfile}} +} +\generate{ + \file{\jobname-example}{\from{\jobname.dtx}{examplefile}} +} %</install> %<install>\endbatchfile %<*internal> @@ -651,10 +600,7 @@ This work consists of all files listed in manifest.txt. \file{\jobname.bib}{\from{\jobname.dtx}{bibfile}} } \generate{ - \file{osmimage.sh}{\from{\jobname.dtx}{bashfile}} -} -\generate{ - \file{osmimage.lua}{\from{\jobname.dtx}{luafile}} + \file{getmapdl.lua}{\from{\jobname.dtx}{luafile}} } \ifx\fmtname\nameofplainTeX \expandafter\endbatchfile @@ -683,7 +629,8 @@ This work consists of all files listed in manifest.txt. \usepackage[automark,nouppercase]{scrpage2} \usepackage[tocgraduated]{tocstyle} \usetocstyle{classic} -\usepackage{getmap} +\usepackage[overwrite=false]{getmap} +\usepackage{attachfile} \usepackage{tikz} % turn off idiotic tikz error in doc generation \makeatletter @@ -732,7 +679,7 @@ emph={}} \draw[anchor=west,yshift=-9cm,xshift=3cm,color=NavyBlue] (0,0) node% {\parbox{15cm}{\RaggedRight\huge\sffamily\textbf{\@subtitle}}};% \draw[anchor=west,yshift=-13cm,xshift=3cm,color=NavyBlue] (0,0) node% - {\includegraphics[width=10cm]{osmimage}};% + {\includegraphics[width=8cm]{getmap}};% \draw[anchor=west,yshift=-17cm,xshift=3cm,color=NavyBlue] (0,0) node% {\parbox{15cm}{\huge\sffamily\textbf{\@date}}};% \draw[anchor=west,yshift=-20cm,xshift=3cm,color=NavyBlue] (0,0) node% @@ -855,11 +802,12 @@ emph={}} %</driver> % \fi % +% \getmap{Bergheimer Straße 110A, 69115 Heidelberg, Germany} %\GetFileInfo{\jobname.sty} -%\hypersetup{pdfauthor={Josef Kleber},pdftitle={A style file for downloading OpenStreetMap maps},pdfsubject={Documentation for LaTeX style \filename},pageanchor=true,hyperindex=true}% +%\hypersetup{pdfauthor={Josef Kleber},pdftitle={Downloading maps from OpenStreetMap or Google Maps},pdfsubject={Documentation for LaTeX style \filename},pageanchor=true,hyperindex=true}% %\lstset{language=[LaTeX]TeX,numbers=left,numberstyle=\tiny, basicstyle=\ttfamily, aboveskip=\baselineskip, frame=single, backgroundcolor=\color{LightGoldenrodYellow}, keywordstyle=\color{Blue}, %emph={},emphstyle=\color{Tomato}, -%emph={[2]width},emphstyle={[2]\color{OliveDrab}}, +%emph={[2]width,xsize,ysize,zoom,scale,mode,file,type},emphstyle={[2]\color{OliveDrab}}, %morekeywords={getmap,includegraphics}} %\DoNotIndex{\,,\begingroup,\endgroup,\csname,\def,\else,\endcsname,\equal,\expandafter, %\fi,\gdef,\ifnum,\ifthenelse,\immediate,\MessageBreak,\NeedsTeXFormat,\newcommand,\newif, @@ -868,7 +816,7 @@ emph={}} % % \bibliographystyle{plain} % \title{\filename}% -% \Subtitle{A style file for downloading \mbox{OpenStreetMap} maps}% +% \Subtitle{Downloading maps from OpenStreetMap or Google Maps}% % \author{Josef Kleber} % \Fileversion{\fileversion} % \date{\filedate} @@ -894,11 +842,13 @@ emph={}} % % \Headline{Abstract} % \begin{abstract} -% The goal of this package is the simplest possible provision of OpenStreetMap maps. -% In the simplest case, the specification of the address is sufficient. -% The package loads the map using the \cmd\write18 feature, which you must activate to use this package. -% The image will be downloaded by an external Lua script. -% You can use this script, as well as the attached bash script also from the command line. +% The goal of this package is the simplest possible provision of +% map images (OpenStreetMap and Google Maps are supported). +% In the simplest case, the specification of an address is sufficient. +% The package loads the map using the \cmd\write18 feature, which you +% must activate to use this package. The image will be downloaded +% by an external Lua script. You can use this script, as well as +% the attached bash script also from the command line. % \end{abstract} % \vfill % \renewcommand*{\abstractname}{Acknowledgment} @@ -911,38 +861,56 @@ emph={}} % \section{Options} % The following options can be used as package options with global scope, % as well as options for the \cmd\getmap\ command with local scope! -% \subsection[\texttt{key}]{\texttt{key (\underline{Kmjtd\textbar{}luu7n162n1,22=o5-h61wh}})} -% The download script requires a key in order to use the service of MapQuest. -% By default, it uses the example key of the web page. -% Maybe this will not work forever. -% If you use the service frequently, i strongly recommend to register with -% \href{http://developer.mapquest.com}{MapQuest} to use your own key. -% Be fair to the company that offers this free service! -% \subsection[\texttt{scale}]{\texttt{scale (\underline{3385}})} -% This option allows you to specify a display scale for the map image in the range of +% \subsection[\texttt{mode}]{\texttt{mode (\underline{osm}\textbar{}gm})} +% This option sets the mode, that is the source of the images. OpenStreetMap or Google Maps! +% \subsection[\texttt{key}]{\texttt{key (\underline{Fmjtd\textbar{}luur20u22d,75=o5-9aylh6}})} +% In \texttt{osm} mode, the download script requires a key in order to use the service of MapQuest. +% By default, it uses a key, which is registered for \package{getmap}. +% But you can register and use your own key with this option. +% The default key is stored in \texttt{getmap.cfg}. You can copy this file to your local \TeX\ tree +% and store your own key there\footnote{Mapquest will deliver an url-encoded key, which must +% be decoded to ASCII, e.g. by \href{http://urldecode.org/}{Url decode}}! +% This file will be found after running \texttt{texhash}! +% \subsection[\texttt{scale}]{\texttt{scale (\underline{3385} (osm), \underline{1} (gm)})} +% \texttt{osm}: This option allows you to specify a display scale for the map image in the range of % 1692 -- 221871572. You will not necessarily see a difference between 5000 and 5500. % A scale value of 3385 corresponds to a zoom level of 17. +% +% \texttt{gm}: For the free version of Google Maps the image size is limited to 640x640. +% You can set \texttt{scale} to a value of 2, to get exactly the same map in doubled size in pixels. % \subsection[\texttt{zoom}]{\texttt{zoom}} -% This option allows you to specify a zoom level in the range of 1 -- 18. -% This option overwrites a possibly given scale. -% \subsection[\texttt{xsize}]{\texttt{xsize (\underline{800})}} +% This option allows you to specify a zoom level in the range of 1 -- 18 +% ( osm - this option overwrites a possibly given scale) or 0 -- 21 (gm). +% \subsection[\texttt{xsize}]{\texttt{xsize (\underline{600})}} % This option specifies the width of the map in pixels. -% If you only want to slightly increase or decrease the map extract, +% If \marginpar{\footnotesize\fbox{\parbox{3cm}{\raggedright{}changed default value to \texttt{600} in version 1.2!}}} +% you only want to slightly increase or decrease the map extract, % you should adjust the size of the map. You still have full control over the size of -% the map in the document with the options of \cmd\includegraphics. (max: 3840) +% the map in the document with the options of \cmd\includegraphics. (max: 3840 (osm) or 640 (gm)) % \subsection[\texttt{ysize}]{\texttt{ysize (\underline{400})}} -% This option specifies the height of the map in pixels. max: 3840) -% \subsection[\texttt{file}]{\texttt{file (\underline{osmimage})}} -% This option allows you to specify the name of the image (without extension). -% \subsection[\texttt{imagetype}]{\texttt{imagetype (\underline{png}\textbar{}jpeg\textbar{}jpg\textbar{}gif)}} +% This option specifies the height of the map in pixels. max: 3840 (osm) or 640 (gm)) +% \subsection[\texttt{file}]{\texttt{file (\underline{getmap})}} +% This \marginpar{\footnotesize\fbox{\parbox{3cm}{\raggedright{}changed default value to \texttt{getmap} in version 1.2!}}} +% option allows you to specify the name of the image (without extension). +% \subsection[\texttt{imagetype}]{\texttt{imagetype (\underline{png})}} % This option allows you to specify the type of the image. -% \subsection[\texttt{type}]{\texttt{type (\underline{map}\textbar{}sat\textbar{}hyb)}} -% This option specifies the type of the map. It seems as if there were only a few regions of Mother Earth, +% +% \texttt{osm}: \texttt{\underline{png}\textbar{}jpeg\textbar{}jpg\textbar{}gif} +% +% \texttt{gm}: \texttt{\underline{png}\textbar{}png8\textbar{}png32\textbar{}gif\textbar{}jpg} (progressive)\texttt{\textbar{}jpg-baseline} (flat) +% \subsection[\texttt{type}]{\texttt{type (\underline{map} (osm)\textbar{}\underline{roadmap} (gm))}} +% This option specifies the type of the map. +% +% \texttt{osm}: \texttt{\underline{map}\textbar{}sat\textbar{}hyb} \quad\quad\ It seems as if there would be only a few regions of Mother Earth, % for which satellite and hybrid images are available. -% \subsection[\texttt{color}]{\texttt{color (\underline{yellow\_1})}} -% This option specifies the color of the marker. % -% Possible colors: \href{http://open.mapquestapi.com/staticmap/icons.html}{http://open.mapquestapi.com/staticmap/icons.html} +% \texttt{gm}: \texttt{\underline{roadmap}\textbar{}satellite\textbar{}hybrid\textbar{}terrain} +% \subsection[\texttt{color}]{\texttt{color (\underline{yellow\_1}) (osm)\textbar{}\underline{blue} (gm))}} +% This option specifies the color of the marker. Possible colors: +% +% \texttt{osm} \href{http://open.mapquestapi.com/staticmap/icons.html}{http://open.mapquestapi.com/staticmap/icons.html} +% +% \texttt{gm}: black, brown, green, purple, yellow, blue, gray, orange, red, white or in hex format \texttt{0x3399FF} % \subsection[\texttt{number}]{\texttt{number (\underline{1})}} % This option specifies the number of the marker. % \subsection[\texttt{inputencoding}]{\texttt{inputencoding}} @@ -967,33 +935,100 @@ emph={}} % You can use the options described above to specify the properties of the downloaded image. % After executing the command, the image is available in the current working directory! % -% In the simplest case, you only need an address to download the map. -% By default, the image is saved under the name \texttt{osmimage.png}! +% In the simplest case, you only need an address, a POI or geographic coordinates +% (\texttt{latitude,longitude}) to download the map. \marg{address} must be fully expanded and must not contain macros! +% By default, the image is saved under the name \texttt{getmap.png}! % If you need only one map (e.g. the office of Dante e.V.) in your document, it can be as simple as: % +% \includegraphics[width=9cm]{getmap} +% % \iffalse %<*example> % \fi \begin{lstlisting} \getmap{Bergheimer Straße 110A, 69115 Heidelberg, Germany} -\includegraphics[width=10cm]{osmimage} +\includegraphics[width=9cm]{getmap} +\end{lstlisting} +% \iffalse +%</example> +% \fi +% +% \section{Examples}\marginnote{\attachfile[author={Josef Kleber},subject={getmap-example.tex},description={getmap-example.tex (source example)} ,mimetype={text/plain}, icon={Tag}]{getmap-example.tex}} +% +% The same map as before from Google Maps: +% +% \getmap[file=dantegm,mode=gm]{Bergheimer Straße 110A, 69115 Heidelberg, Germany} +% \includegraphics[width=9cm]{dantegm} +% \iffalse +%<*example> +% \fi +\begin{lstlisting} +\getmap[file=dantegm,mode=gm]{Bergheimer Straße 110A,% + 69115 Heidelberg, Germany} +\includegraphics[width=9cm]{dantegm} \end{lstlisting} % \iffalse %</example> % \fi % -% \includegraphics[width=10cm]{osmimage} +% The same map as satellite image: % +% \getmap[file=dantegmsat,mode=gm,type=satellite]{Bergheimer Straße 110A, 69115 Heidelberg, Germany} +% \includegraphics[width=9cm]{dantegmsat} +% \iffalse +%<*example> +% \fi +\begin{lstlisting} +\getmap[file=dantegmsat,mode=gm,type=satellite] + {Bergheimer Straße 110A, 69115 Heidelberg, Germany} +\includegraphics[width=9cm]{dantegmsat} +\end{lstlisting} +% \iffalse +%</example> +% \fi +% \clearpage +% L'afrique, mon amour! +% +% \getmap[file=africa,mode=gm,type=terrain,xsize=500,ysize=500,scale=2,zoom=3]{0,16} +% \includegraphics[width=9cm]{africa} +% \iffalse +%<*example> +% \fi +\begin{lstlisting} +\getmap[file=africa,mode=gm,type=terrain,xsize=500,ysize=500,% + scale=2,zoom=3]{0,16} +\includegraphics[width=9cm]{africa} +\end{lstlisting} +% \iffalse +%</example> +% \fi +% L'amour, ... +% +% \getmap[file=paris,mode=gm,type=hybrid,xsize=500,ysize=300,scale=2,zoom=16]{Tour Eiffel, Paris} +% \includegraphics[width=9cm]{paris} +% \iffalse +%<*example> +% \fi +\begin{lstlisting} +\getmap[file=paris,mode=gm,type=hybrid,xsize=500,ysize=300,% + scale=2,zoom=16]{Tour Eiffel, Paris} +\includegraphics[width=9cm]{paris} +\end{lstlisting} +% \iffalse +%</example> +% \fi % \clearpage % \section{Implementation} % \changes{v1.0}{2014/05/25}{CTAN upload} +% \changes{v1.2}{2014/07/11}{added support for Google Maps} +% \changes{v1.2}{2014/07/11}{renamed osmimage.lua to getmapdl.lua} % \begin{macrocode} %<*package> % \end{macrocode} % First, we provide the \LaTeX\ package \package{getmap}. % \begin{macrocode} \NeedsTeXFormat{LaTeX2e}% -\ProvidesPackage{getmap}[2014/06/24 v1.1 getmap.sty - Josef Kleber (C) 2014]% +\ProvidesPackage{getmap}[2014/07/15 v1.2 getmap.sty - Josef Kleber (C) 2014]% % \end{macrocode} % We need a few packages! % \begin{macrocode} @@ -1019,9 +1054,11 @@ emph={}} }% % \end{macrocode} % Now, we can use this macro to define our options. +% \changes{v1.2}{2014/07/11}{changed default values of \texttt{xsize }(600) and \texttt{file} (getmap)} % \begin{macrocode} -\GM@JK@define@key{GM@JK}{getmap}{key}{Kmjtd|luu7n162n1,22=o5-h61wh}% -\GM@JK@define@key{GM@JK}{getmap}{xsize}{800}% +\GM@JK@define@key{GM@JK}{getmap}{mode}{osm}% +\GM@JK@define@key{GM@JK}{getmap}{key}{}% +\GM@JK@define@key{GM@JK}{getmap}{xsize}{600}% \GM@JK@define@key{GM@JK}{getmap}{ysize}{400}% \GM@JK@define@key{GM@JK}{getmap}{scale}{3385}% \GM@JK@define@key{GM@JK}{getmap}{zoom}{}% @@ -1029,7 +1066,7 @@ emph={}} \GM@JK@define@key{GM@JK}{getmap}{imagetype}{png}% \GM@JK@define@key{GM@JK}{getmap}{color}{yellow_1}% \GM@JK@define@key{GM@JK}{getmap}{number}{1}% -\GM@JK@define@key{GM@JK}{getmap}{file}{osmimage}% +\GM@JK@define@key{GM@JK}{getmap}{file}{getmap}% \GM@JK@define@key{GM@JK}{getmap}{inputencoding}{}% \GM@JK@define@key{GM@JK}{getmap}{overwrite}{true}% % \end{macrocode} @@ -1038,9 +1075,22 @@ emph={}} % \styleoption{overwrite} to be \texttt{true} by default, but that \styleoption{overwrite} % is equivalent to \styleoption{overwrite}=\texttt{true}! % +% \changes{v1.2}{2014/07/11}{added getmap.cfg to store default key (FR by Ulrike Fischer)} +% Moreover, we load \texttt{getmap.cfg} to set the default key. You can copy this file +% to your local \TeX\ tree and replace the key with your own! +% % We try to use the input encoding specified for \package{inputenc} or \texttt{utf8} instead. % \begin{macrocode} \gdef\GM@JK@overwrite{false}% +\gdef\GM@JK@key{}% +% +\IfFileExists{getmap.cfg}% +{% + \input{getmap.cfg}% +}% +{% + \gdef\GM@JK@key{Fmjtd|luur20u22d,75=o5-9aylh6}% +}% % \@ifpackageloaded{inputenc}% {% @@ -1058,11 +1108,24 @@ emph={}} % \end{macrocode} % We execute the package options to define and set the option macros. % \begin{macrocode} -\ExecuteOptionsX{key,xsize,ysize,scale,zoom,type,imagetype,color,number,file}% +\ExecuteOptionsX{mode,xsize,ysize,scale,zoom,type,imagetype,color,number,file}% % \ProcessOptionsX\relax% % % \end{macrocode} +% We need to reset some defaults in \texttt{gm} mode. +% \begin{macrocode} +% +\ifthenelse{\equal{\GM@JK@mode}{gm}}% +{% + \gdef\GM@JK@scale{1}% + \gdef\GM@JK@zoom{17}% + \gdef\GM@JK@type{roadmap}% + \gdef\GM@JK@color{blue}% +}% +{}% +% +% \end{macrocode} % We check if \cmd\pdf@shellescape\ is available to test if \cmd\write18 % is enabled. % @@ -1070,6 +1133,7 @@ emph={}} % % If \texttt{true}, we set the switch \cmd\GM@JK@writexviii\ accordingly! % \begin{macrocode} +% \ltx@IfUndefined{pdf@shellescape}% {% \PackageInfo{getmap}{\pdf@shellescape is undefined}% @@ -1085,21 +1149,23 @@ emph={}} \GM@JK@writexviiifalse% \fi% }% +% % \end{macrocode} % We define a macro that is executed as \cmd\write18\ call. First, we test if% % \cmd\write18\ is enabled and issue a package error if not! Otherwise we execute% -% \cmd\write18\ depending on the existence of a \styleoption{zoom}% -% (\styleoption{zoom} overrides \styleoption{scale}). +% \cmd\write18\ depending on the mode% % \begin{macrocode} \newcommand*\GM@JK@shellescape% {% - \ifGM@JK@writexviii% - \ifthenelse{\equal{\GM@JK@zoom}{}}% + \ifGM@JK@writexviii\relax% + \ifthenelse{\equal{\GM@JK@mode}{osm}}% {% - \immediate\write18{osmimage \space-l\space "\GM@JK@location@string"% + \immediate\write18{getmapdl \space-l\space "\GM@JK@location@string"% + \space-m\space osm% \space-k\space "\GM@JK@key@string"% \space-x\space \GM@JK@xsize% \space-y\space \GM@JK@ysize% + \space-z\space "\GM@JK@zoom"% \space-s\space \GM@JK@scale% \space-t\space \GM@JK@type% \space-i\space \GM@JK@imagetype% @@ -1108,11 +1174,12 @@ emph={}} \space-o\space \GM@JK@file}% }% {% - \immediate\write18{osmimage \space-l\space "\GM@JK@location@string"% - \space-k\space "\GM@JK@key@string% + \immediate\write18{getmapdl \space-l\space "\GM@JK@location@string"% + \space-m\space gm% \space-x\space \GM@JK@xsize% \space-y\space \GM@JK@ysize% \space-z\space \GM@JK@zoom% + \space-s\space \GM@JK@scale% \space-t\space \GM@JK@type% \space-i\space \GM@JK@imagetype% \space-c\space "\GM@JK@color"% @@ -1120,7 +1187,7 @@ emph={}} \space-o\space \GM@JK@file}% }% \else% - \PackageError{getmap}{\write18 disabled} + \PackageError{getmap}{\write18 disabled}% {\write18 disabled\MessageBreak% Use -shell-escape (TeXLive)\MessageBreak% or\space\space--enable-write18 (MiKTeX)}% @@ -1136,14 +1203,25 @@ emph={}} {% % \end{macrocode} % \changes{v1.1}{2014/06/23}{Bugfix: problem in URL when using \cmd\usepackage[utf8]\{inputenc\}} -% We start a group to keep the setting of options local. +% We start a group to keep the setting of options local. +% Then we test, if we are in \texttt{gm} mode to reset some defaults! +% Finally, we set the local options again to override defaults if necessary! % \begin{macrocode} \begingroup% \setkeys{getmap}{#1}% + \ifthenelse{\equal{\GM@JK@mode}{gm}}% + {% + \def\GM@JK@scale{1}% + \def\GM@JK@zoom{17}% + \def\GM@JK@type{roadmap}% + \def\GM@JK@color{blue}% + }% + {}% + \setkeys{getmap}{#1}% \PackageInfo{getmap}{using \GM@JK@inputencoding\space encoding}% \def\GM@JK@location{#2}% % \end{macrocode} -% Both, the bash as well as the Lua script need their string arguments encoded in \texttt{utf8}! +% \texttt{texlua} expects its arguments encoded in \texttt{utf8}! % \begin{macrocode} \StringEncodingConvert% {\GM@JK@location@string}% diff --git a/Master/texmf-dist/doc/latex/getmap/getmap.pdf b/Master/texmf-dist/doc/latex/getmap/getmap.pdf Binary files differindex f804bf348e4..2c49d1b422d 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 e0444d22f6d..dc3f4fdec45 100755 --- a/Master/texmf-dist/doc/latex/getmap/install.bat +++ b/Master/texmf-dist/doc/latex/getmap/install.bat @@ -1,14 +1,15 @@ @echo off +rem Adjust these pathes for your installation. +rem Usually, you just need to change the base directory part! set texmfpath=C:\texlive\texmf-local -set texmfroot=C:\texlive\2014 -set tlarch=win32 +set bindir=C:\texlive\2014\bin\win32\ set pckname=getmap echo. echo. echo Installing %pckname% into %texmfpath% echo. echo Creating %pckname%.pdf -pdflatex %pckname%.dtx >nul +pdflatex -shell-escape %pckname%.dtx >nul bibtex %pckname% >nul makeindex -q -s gind.ist %pckname% >nul makeindex -q -s gglo.ist %pckname%.glo -o %pckname%.gls >nul @@ -17,17 +18,17 @@ bibtex %pckname% >nul makeindex -q -s gind.ist %pckname% >nul makeindex -q -s gglo.ist %pckname%.glo -o %pckname%.gls >nul pdflatex %pckname%.dtx >nul -ren osmimage.sh osmimage >nul ren README.txt README >nul echo Copying files to %texmfpath% md %texmfpath%\scripts\%pckname% >nul -copy osmimage %texmfpath%\scripts\%pckname%\ >nul -copy osmimage.lua %texmfpath%\scripts\%pckname%\ >nul +copy getmapdl.lua %texmfpath%\scripts\%pckname%\ >nul md %texmfpath%\tex\latex\%pckname% >nul copy *.sty %texmfpath%\tex\latex\%pckname% >nul +copy *.cfg %texmfpath%\tex\latex\%pckname% >nul md %texmfpath%\doc\latex\%pckname% >nul copy README %texmfpath%\doc\latex\%pckname% >nul copy *.txt %texmfpath%\doc\latex\%pckname% >nul +copy *.tex %texmfpath%\doc\latex\%pckname% >nul copy *.dtx %texmfpath%\doc\latex\%pckname% >nul copy *.pdf %texmfpath%\doc\latex\%pckname% >nul echo Running texhash @@ -45,15 +46,17 @@ del *.ind del *.ins del *.log del *.out +del *.tex del *.sty +del *.cfg del *.toc del *.txt -del osmimage -del osmimage.lua +del getmapdl.lua del README -echo Create osmimage.exe -pushd %texmfroot%\bin\%tlarch%\ -copy runscript.exe osmimage.exe >nul +del getmap.pdf +echo Create getmapdl.exe +pushd %bindir% +copy runscript.exe getmapdl.exe >nul popd echo. echo Done diff --git a/Master/texmf-dist/doc/latex/getmap/makefile b/Master/texmf-dist/doc/latex/getmap/makefile index 59d77b47347..9967330f4f6 100644 --- a/Master/texmf-dist/doc/latex/getmap/makefile +++ b/Master/texmf-dist/doc/latex/getmap/makefile @@ -8,7 +8,7 @@ all: doc doc: $(PKGNAME).pdf package $(PKGNAME).pdf: - pdflatex $(PKGNAME).dtx + pdflatex -shell-escape $(PKGNAME).dtx bibtex $(PKGNAME) makeindex -s gind.ist $(PKGNAME) makeindex -s gglo.ist $(PKGNAME).glo -o $(PKGNAME).gls @@ -20,7 +20,6 @@ $(PKGNAME).pdf: package: pdftex $(PKGNAME).dtx - mv osmimage.sh osmimage mv README.txt README install: doc @@ -28,39 +27,42 @@ install: doc cp README ${TEXMF}/doc/latex/${PKGNAME}/ cp *.txt ${TEXMF}/doc/latex/${PKGNAME}/ cp *.dtx ${TEXMF}/doc/latex/${PKGNAME}/ + cp *.tex ${TEXMF}/doc/latex/${PKGNAME}/ cp *.pdf ${TEXMF}/doc/latex/${PKGNAME}/ mkdir -p ${TEXMF}/tex/latex/${PKGNAME} cp *.sty ${TEXMF}/tex/latex/${PKGNAME}/ + cp *.cfg ${TEXMF}/tex/latex/${PKGNAME}/ mkdir -p ${TEXMF}/scripts/${PKGNAME} - cp osmimage.lua osmimage ${TEXMF}/scripts/${PKGNAME}/ + cp getmapdl.lua ${TEXMF}/scripts/${PKGNAME}/ texhash - chmod 0755 ${TEXMF}/scripts/${PKGNAME}/osmimage.lua - ln -s ${TEXMF}/scripts/${PKGNAME}/osmimage.lua ${BINDIR}/osmimage + chmod 0755 ${TEXMF}/scripts/${PKGNAME}/getmapdl.lua + ln -s ${TEXMF}/scripts/${PKGNAME}/getmapdl.lua ${BINDIR}/getmapdl uninstall: rm -rf ${TEXMF}/doc/latex/${PKGNAME} rm -rf ${TEXMF}/tex/latex/${PKGNAME} rm -rf ${TEXMF}/scripts/${PKGNAME} - rm -f ${BINDIR}/osmimage + rm -f ${BINDIR}/getmapdl texhash styles: package cp *.sty ${TEXMF}/tex/latex/${PKGNAME}/ git: package - cp osmimage ./../dev/scripts/getmap/osmimage - cp osmimage.lua ./../dev/scripts/getmap/osmimage.lua + cp getmapdl.lua ./../dev/scripts/getmap/getmapdl.lua cp getmap.sty ./../dev/tex/latex/getmap/getmap.sty + cp getmap.cfg ./../dev/tex/latex/getmap/getmap.cfg ctan: ./copyCTAN clean: $(RM) *.aux *.fdb_latexmk *.fls *.ind *.idx *.ilg *.glo *.gls \ - *.log *.lol *.m *.out *.tmp *.toc *.sty *.sh *.hd \ - *.bbl *.blg *.ins *.txt *.bib + *.log *.lol *.m *.out *.tmp *.toc *.sh *.hd \ + *.bbl *.blg *.ins *.txt *.bib cleanall: clean - $(RM) osmimage osmimage.lua README + $(RM) getmapdl.lua *.sty *.png \ + *.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 2c39629c9b0..be74e3cefe9 100644 --- a/Master/texmf-dist/doc/latex/getmap/manifest.txt +++ b/Master/texmf-dist/doc/latex/getmap/manifest.txt @@ -2,7 +2,13 @@ This work consists of the following files: getmap.pdf getmap.dtx -osmimage.png README makefile install.bat + +Files packaged in getmap.dtx: + +getmap.sty +getmap.cfg +getmap-example.tex +getmapdl.lua diff --git a/Master/texmf-dist/doc/latex/getmap/osmimage.png b/Master/texmf-dist/doc/latex/getmap/osmimage.png Binary files differdeleted file mode 100644 index 3d53439cb61..00000000000 --- a/Master/texmf-dist/doc/latex/getmap/osmimage.png +++ /dev/null diff --git a/Master/texmf-dist/scripts/getmap/getmapdl.lua b/Master/texmf-dist/scripts/getmap/getmapdl.lua new file mode 100644 index 00000000000..198796414bd --- /dev/null +++ b/Master/texmf-dist/scripts/getmap/getmapdl.lua @@ -0,0 +1,381 @@ +#!/usr/bin/env texlua +-- +-- getmapdl [options] +-- +-- downloads an OpenStreetMap or Google Maps map specified by [options] +-- +-- License: LPPL +-- +local http = require("socket.http"); +local ltn12 = require("ltn12") +local url = require("socket.url") + +local OSMURL = "http://open.mapquestapi.com/staticmap/v4/getplacemap" +local GMURL = "http://maps.googleapis.com/maps/api/staticmap" +local KEY = "" +local MODE = "" +local LOCATION = "" +local XSIZE = "" +local CENTER = "" +local YSIZE = "" +local SIZE = "" +local SCALE = "" +local ZOOM = "" +local TYPE = "" +local IMAGETYPE = "" +local COLOR = "" +local NUMBER = "" +local VISIBLE = "" +local IPATH = "" +local MARKERS = "" +local OFILE = "getmap" +local QUIET = "false" +local VERSION = "v1.0 (15/07/2014)" + +function pversion() + print("getmapdl.lua " .. VERSION) + print("(C) Josef Kleber License: LPPL") + os.exit(0) +end + +function phelp() + print([[ +getmapdl.lua [options] + + downloads an OpenStreetMap or Google Maps map specified by [options] + + Options: + + -m specify the mode (osm|gm) + + -l specify a location + e.g. 'Bergheimer Straße 110A, 69115 Heidelberg, Germany' + + -x specify a xsize (600) + + -y specify a ysize (400) + + -S short form to specify a size, e.g. 600,400 (osm) or 600x400 (gm) + + -s specify a scale factor in the range 1692-221871572 (osmm) or + 1-2 (osm) + + -z specify a zoom in the range 1-18 (osm) or 0-21 (17) (gm) + + -t specify map type {map|sathyb} (map) (osm) or + {roadmap|satellite|hybrid|terrain} (roadmap) (gm) + + -i specify image type {png|gif|jpg|jpeg} (png) (osm) or + {png|png8|png32|gif|jpg|jpg-baseline} (png) (gm) + + -c specify icon color (yelow_1) (osm) or (blue) (gm) + see: http://open.mapquestapi.com/staticmap/icons.html + https://developers.google.com/maps/documentation/staticmaps/#MarkerStyles + + -n specify the icon number (1) + + -o specify output basename without file extension (getmap.IMAGETYPE) + + -q quiet; no output! + + -v prints version information + + -h prints help information + + gm mode only: + + -M specify markers; see: + https://developers.google.com/maps/documentation/staticmaps/index#Markers + e.g.: &markers=size:mid|color:blue|label:1|address or more of these + location and zoom will be ignored if used! + + -C specify center of the map + + -V specify a list of visible locations (loc1|loc2) + + -P specify path from location to location + e.g.: &path=weight:7|color:purple|loc1|loc2 + +]]) + pversion() +end + +function getmap_error(exitcode, errortext) + io.stderr:write ("Error (" .. exitcode .. "): " .. errortext .. "\n") + os.exit(exitcode) +end + +function getmap_warning(warningtext) + io.stderr:write("WARNING: " .. warningtext .. "\n") +end + +function check_number(var, varname) + local number='^[0-9]+$' + if not(string.match(var, '^[0-9]+$')) then + getmap_error(2, varname .. " can't be " .. var .. "! Not a number!") + end +end + +function check_range(var,min,max,exitcode,varname) + check_number(var,varname) + if (tonumber(var) < tonumber(min) or tonumber(var) > tonumber(max)) then + getmap_error(exitcode, varname .. " = " .. var .. "; must be in the range of " .. min .. "-" .. max) + end +end + +do + local newarg = {} + local i, limit = 1, #arg + while (i <= limit) do + if arg[i] == "-l" then + LOCATION = arg[i+1] + i = i + 1 + elseif arg[i] == "-C" then + CENTER = arg[i+1] + i = i + 1 + elseif arg[i] == "-m" then + MODE = arg[i+1] + i = i + 1 + elseif arg[i] == "-k" then + KEY = arg[i+1] + i = i + 1 + elseif arg[i] == "-x" then + XSIZE = arg[i+1] + i = i + 1 + elseif arg[i] == "-y" then + YSIZE = arg[i+1] + i = i + 1 + elseif arg[i] == "-S" then + SIZE = arg[i+1] + i = i + 1 + elseif arg[i] == "-s" then + SCALE = arg[i+1] + i = i + 1 + elseif arg[i] == "-z" then + ZOOM = arg[i+1] + i = i + 1 + elseif arg[i] == "-t" then + TYPE = arg[i+1] + i = i + 1 + elseif arg[i] == "-i" then + IMAGETYPE = arg[i+1] + i = i + 1 + elseif arg[i] == "-c" then + COLOR = arg[i+1] + i = i + 1 + elseif arg[i] == "-n" then + NUMBER = arg[i+1] + i = i + 1 + elseif arg[i] == "-M" then + MARKERS = arg[i+1] + i = i + 1 + elseif arg[i] == "-V" then + VISIBLE = arg[i+1] + i = i + 1 + elseif arg[i] == "-P" then + IPATH = arg[i+1] + i = i + 1 + elseif arg[i] == "-o" then + OFILE = arg[i+1] + i = i + 1 + elseif arg[i] == "-q" then + QUIET = 1 + elseif arg[i] == "-v" then + pversion() + elseif arg[i] == "-h" then + phelp() + else + newarg[#newarg+1] = arg[i] + end + i = i + 1 + end + arg = newarg +end + +if QUIET == 1 then + getmap_warning("-q option currently not supported!") +end + +if KEY == "" then + if MODE == "osm" then + KEY="Kmjtd|luu7n162n1,22=o5-h61wh" + getmap_warning("KEY not specified; using mapquest example key as default!") + end +end + +if LOCATION == "" then + LOCATION = "Bergheimer Straße 110A, 69115 Heidelberg, Germany" + getmap_warning("LOCATION not specified; using Dante e.V. Office as default!") +end + +if MODE == "gm" then + if ZOOM == "" then + ZOOM=17 + getmap_warning("ZOOM not specified; using ZOOM=17 as default!") + end +end + +if XSIZE == "" then + XSIZE=600 + getmap_warning("XSIZE not specified; using XSIZE=600 as default!") +end + +if YSIZE == "" then + YSIZE=400 + getmap_warning("YSIZE not specified; using YSIZE=400 as default!") +end + +if SIZE == "" then + if MODE == "gm" then + SIZE = XSIZE .. "x" .. YSIZE + elseif MODE == "osm" then + SIZE = XSIZE .. "," .. YSIZE + end +end + +if SCALE == "" then + if MODE == "gm" then + SCALE=1 + getmap_warning("SCALE not specified, using SCALE=1 as default!") + elseif MODE == "osm" then + if ZOOM == "" then + SCALE=3385 + getmap_warning("SCALE not specified, using SCALE=3385 as default!") + end + end +end + +if TYPE == "" then + if MODE == "gm" then + TYPE = "roadmap" + getmap_warning("TYPE not specified; using roadmap as default!") + elseif MODE == "osm" then + TYPE = "map" + getmap_warning("TYPE not specified; using map as default!") + end +end + +if IMAGETYPE == "" then + IMAGETYPE="png" + getmap_warning("IMAGETYPE not specified; using png as default!") +end + +if COLOR == "" then + if MODE == "gm" then + COLOR="blue" + getmap_warning("COLOR not specified; using blue as default!") + elseif MODE == "osm" then + COLOR="yellow_1" + getmap_warning("COLOR not specified; using yellow_1 as default!") + end +end + +if NUMBER == "" then + NUMBER=1 + getmap_warning("NUMBER not specified; using 1 as default!") +end + +if MODE == "gm" then + if ZOOM == "" then + ZOOM = 17 + else + check_range(ZOOM,0,21,11,"ZOOM") + end + check_range(XSIZE,1,640,12,"XSIZE") + check_range(YSIZE,1,640,13,"YSIZE") + check_range(SCALE,1,2,14,"SCALE") +elseif MODE == "osm" then + check_range(XSIZE,1,3840,11,"XSIZE") + check_range(YSIZE,1,3840,12,"YSIZE") + if ZOOM == "" then + check_range(SCALE,1692,221871572,13,"SCALE") + else + check_range(ZOOM,1,18,14,"ZOOM") + end + check_number(NUMBER,"NUMBER") +end + +local UKEY = "" +local ULOCATION = "" +local UZOOM = "" +local USCALEZOOM = "" +local UMARKERS = "" +local USIZE = "" +local USCALE = "" +local UTYPE = "" +local USHOWICON = "" +local UIMAGETYPE = "" +local UVISIBLE = "" +local UIPATH = "" +local UOFILE = "" +local IMGURL = "" + +if MODE == "gm" then + ULOCATION = "center=" .. url.escape(LOCATION) + if MARKERS == "" then + UMARKERS = "&markers=size:mid|color:" .. COLOR .. "|label:" .. NUMBER .. "|" .. url.escape(LOCATION) + UZOOM = "&zoom=" .. url.escape(ZOOM) + else + UMARKERS = "" .. url.escape(MARKERS) + -- correct cruft escaping of "&markers=" + UMARKERS = UMARKERS:gsub("%%26markers%%3d","&markers=") + UZOMM = "" + if CENTER == "" then + ULOCATION = "" + else + ULOCATION = "center=" .. url.escape(CENTER) + end + end + USIZE = "&size=" .. url.escape(SIZE) + USCALE = "&scale=" .. url.escape(SCALE) + UTYPE = "&maptype=" .. url.escape(TYPE) + UIMAGETYPE = "&format=" .. url.escape(IMAGETYPE) + if IMAGETYPE == "jpg-baseline" then + IMAGETYPE = "jpg" + end + if VISIBLE == "" then + UVISIBLE = "" + else + UVISIBLE = "&visible=" .. url.escape(VISIBLE) + end + if IPATH == "" then + UIPATH = "" + else + UIPATH = "" .. url.escape(IPATH) + -- correct cruft escaping of "&path=" + UIPATH = UIPATH:gsub("%%26path%%3d","&path=") + end + UOFILE = OFILE .. "." .. IMAGETYPE + IMGURL = GMURL .. "?" .. ULOCATION .. USIZE .. UZOOM .. UMARKERS .. UTYPE .. USCALE .. UIMAGETYPE .. UVISIBLE .. UIPATH .. "&sensor=false" +elseif MODE == "osm" then + UKEY = "?key=" .. url.escape(KEY) + ULOCATION = "&location=" .. url.escape(LOCATION) + USIZE = "&size=" .. url.escape(SIZE) + if ZOOM == "" then + USCALEZOOM = "&scale=" .. url.escape(SCALE) + else + USCALEZOOM = "&zoom=" .. url.escape(ZOOM) + end + UTYPE = "&type=" .. url.escape(TYPE) + UIMAGETYPE = "&imagetype=" .. url.escape(IMAGETYPE) + USHOWICON = "&showicon=" .. url.escape(COLOR) .. "-" .. url.escape(NUMBER) + UOFILE = OFILE .. "." .. IMAGETYPE + IMGURL = OSMURL .. UKEY .. ULOCATION .. USIZE .. USCALEZOOM .. UTYPE .. UIMAGETYPE .. USHOWICON +end + +local ret, msg +local ofile +ofile, msg = io.open(UOFILE, "wb") +if not ofile then + getmap_error(21, msg) +end +print("\n\ngetmap.lua:") +print("url = " .. IMGURL) +print("output = " .. UOFILE) +ret, msg = http.request{ + url = IMGURL, + sink = ltn12.sink.file(ofile) +} +if not ret then + getmap_error(22, msg) +end diff --git a/Master/texmf-dist/scripts/getmap/osmimage b/Master/texmf-dist/scripts/getmap/osmimage deleted file mode 100644 index 82ddf3da8da..00000000000 --- a/Master/texmf-dist/scripts/getmap/osmimage +++ /dev/null @@ -1,224 +0,0 @@ -#!/bin/bash -# -# osmimage [options] -# -# downloads an OpenStreetMap map specified by [options] -# by using http://developer.mapquest.com/ web service -# -# License: LPPL -# -pversion() -{ - echo "`basename $0` $VERSION" - echo "(C) Josef Kleber License: LPPL" - exit 0; -} -# -function phelp() -{ - echo -e \ - "\n `basename $0` [options]\n\n"\ - " downloads an OpenStreetMap map specified by [options]\n"\ - " by using http://developer.mapquest.com/ web service\n\n"\ - " Options:\n\n"\ - " -k key registered at http://developer.mapquest.com/\n"\ - " default (Example key from web site)!\n"\ - " Please register and use your own key!\n\n"\ - " -l specify a location\n"\ - " e.g. 'Bergheimer Straße 110A, 69115 Heidelberg, Germany'\n\n"\ - " -x specify a xsize (800)\n\n"\ - " -y specify a ysize (400)\n\n"\ - " -S short form to specify a size, e.g. 800,400\n\n"\ - " -s specify a scale factor in the range 1692-221871572 (3385 = -z 17)\n"\ - " see: http://open.mapquestapi.com/staticmap/zoomToScale.html\n\n"\ - " -z specify a zoom in the range 1-18 (zoom overrides scale!)\n\n"\ - " -t specify map type {map|sat|hyb} (map)\n\n"\ - " -i specify image type {jpeg|jpg|gif|png} (png)\n\n"\ - " -c specify icon color (yellow_1)\n"\ - " see: http://open.mapquestapi.com/staticmap/icons.html\n\n"\ - " -n specify the icon number (1)\n\n"\ - " -o specify output basename without file extension (osmimage.IMAGETYPE)\n\n"\ - " -q quiet; no output!\n\n"\ - " -v prints version information\n\n"\ - " -h prints help information\n\n" - pversion -} -# -osmimage_error() -{ - local exitcode="$1" - local errortext="$2" - echo "Error ($exitcode): $errortext" >&2 - exit $exitcode -} -# -osmimage_warning() -{ - local warningtext="$1" - echo -e "WARNING: $warningtext\n" >&2 -} -# -check_prog() -{ - local prog="$1" - hash $prog 2>/dev/null || osmimage_error 1 "$prog not installed! Aborting." -} -# -check_number() -{ - local var="$1" - local varname="$2" - local number='^[0-9]+$' - if ! [[ $var =~ $number ]] - then - osmimage_error 2 "$varname can't be $var! Not a number!" - fi -} -# -check_range() -{ - local var="$1" - local min="$2" - local max="$3" - local exitcode="$4" - local varname="$5" - check_number $var $varname - if [ $var -lt $min ] - then - osmimage_error $exitcode "$varname = $var; must be in the range of $min-$max" - fi - if [ $var -gt $max ] - then - osmimage_error $exitcode "$varname = $var; must be in the range of $min-$max" - - fi -} -# -check_prog wget -# -URL="http://open.mapquestapi.com/staticmap/v4/getplacemap" -KEY="" -LOCATION="" -XSIZE="" -YSIZE="" -SCALE="" -ZOOM="" -TYPE="" -IMAGETYPE="" -COLOR="" -NUMBER="" -OFILE="osmimage" -QUIET="false" -VERSION="v1.2 (23/05/2014)" -# -while getopts "k:l:x:y:S:s:z:t:i:c:n:o:qvh" flag -do - case "$flag" in - k) KEY="$OPTARG";; - l) LOCATION="$OPTARG";; - x) XSIZE="$OPTARG";; - y) YSIZE="$OPTARG";; - S) SIZE="$OPTARG";; - s) SCALE="$OPTARG";; - z) ZOOM="$OPTARG";; - t) TYPE="$OPTARG";; - i) IMAGETYPE="$OPTARG";; - c) COLOR="$OPTARG";; - n) NUMBER="$OPTARG";; - o) OFILE="$OPTARG";; - q) QUIET="true";; - v) pversion;; - h) phelp;; - esac -done -# -if [ "$QUIET" = "true" ] -then - exec 1>/dev/null - exec 2>/dev/null -fi -# -if [ -z $KEY ] -then - KEY="Kmjtd%7Cluu7n162n1%2C22%3Do5-h61wh" - osmimage_warning "KEY not specified; using mapquest example key as default!" -fi -# -if [ -z $LOCATION ] -then - LOCATION="Bergheimer Straße 110A, 69115 Heidelberg, Germany" - osmimage_warning "LOCATION not specified; using Dante e.V. Office as default!" -fi -# -if [ -z $XSIZE ] -then - XSIZE=800 - osmimage_warning "XSIZE not specified; using XSIZE=800 as default!" -fi -check_range $XSIZE 1 3840 11 XSIZE -# -if [ -z $YSIZE ] -then - YSIZE=400 - osmimage_warning "YSIZE not specified; using YSIZE=400 as default!" -fi -check_range $YSIZE 1 3840 12 YSIZE -# -if [ -z $SIZE ] -then - SIZE="$XSIZE,$YSIZE" -fi -# -if [ -z $SCALE ] -then - if [ -z $ZOOM ] - then - SCALE=3385 - osmimage_warning "SCALE not specified, using SCALE=3385 as default!" - fi -else - check_range $SCALE 1692 221871572 13 SCALE -fi -# -if [ -z $TYPE ] -then - TYPE="map" - osmimage_warning "TYPE not specified; using map as default!" -fi -# -if [ -z $IMAGETYPE ] -then - IMAGETYPE="png" - osmimage_warning "IMAGETYPE not specified; using png as default!" -fi -# -if [ -z $COLOR ] -then - COLOR="yellow_1" - osmimage_warning "COLOR not specified; using yellow_1 as default!" -fi -if [ -z $NUMBER ] -then - NUMBER=1 - osmimage_warning "NUMBER not specified; using 1 as default!" -fi -check_number $NUMBER NUMBER -# -ULOCATION="&location=$LOCATION" -USIZE="&size=$SIZE" -if [ -z $ZOOM ] -then - USCALEZOOM="&scale=$SCALE" -else - check_range $ZOOM 1 18 14 ZOOM - USCALEZOOM="&zoom=$ZOOM" -fi -UTYPE="&type=$TYPE" -UIMAGETYPE="&imagetype=$IMAGETYPE" -USHOWICON="&showicon=${COLOR}-${NUMBER}" -UOFILE="${OFILE}.${IMAGETYPE}" -# -IMGURL="${URL}?key=${KEY}${ULOCATION}${USIZE}${USCALEZOOM}${UTYPE}${UIMAGETYPE}${USHOWICON}" -# -wget "$IMGURL" -O "$UOFILE" -exit 0 diff --git a/Master/texmf-dist/scripts/getmap/osmimage.lua b/Master/texmf-dist/scripts/getmap/osmimage.lua deleted file mode 100755 index 55220ed5219..00000000000 --- a/Master/texmf-dist/scripts/getmap/osmimage.lua +++ /dev/null @@ -1,261 +0,0 @@ -#!/usr/bin/env texlua --- --- osmimage [options] --- --- downloads an OpenStreetMap map specified by [options] --- by using http://developer.mapquest.com/ web service --- --- recoding the osmimage bash script to lua was mostly done --- by Norbert Preining with valuable inputs from --- Taco Hoekwater, Reinhard Kotucha and Heiko Oberdiek --- Message-ID: <537A098C.8000902@gmx.de> ff --- --- License: LPPL --- -local http = require("socket.http"); -local ltn12 = require("ltn12") -local url = require("socket.url") - -local URL = "http://open.mapquestapi.com/staticmap/v4/getplacemap" -local KEY = "" -local LOCATION = "" -local XSIZE = "" -local YSIZE = "" -local SIZE = "" -local SCALE = "" -local ZOOM = "" -local TYPE = "" -local IMAGETYPE = "" -local COLOR = "" -local NUMBER = "" -local OFILE = "osmimage" -local QUIET = "false" -local VERSION = "v1.2 (23/05/2014)" - -function pversion() - print("osmimage.lua " .. VERSION) - print("(C) Josef Kleber License: LPPL") - os.exit(0) -end - -function phelp() - print([[ -osmimage.lua [options] - - downloads an OpenStreetMap map specified by [options] - by using http://developer.mapquest.com/ web service - - Options: - - -k key registered at http://developer.mapquest.com/ - default (Example key from web site)! - Please register and use your own key! - - -l specify a location - e.g. 'Bergheimer Straße 110A, 69115 Heidelberg, Germany' - - -x specify a xsize (800) - - -y specify a ysize (400) - - -S short form to specify a size, e.g. 800,400 - - -s specify a scale factor in the range 1692-221871572 (3385 = -z 17) - see: http://open.mapquestapi.com/staticmap/zoomToScale.html - - -z specify a zoom in the range 1-18 (zoom overrides scale!) - - -t specify map type {map|sat|hyb} (map) - - -i specify image type {jpeg|jpg|gif|png} (png) - - -c specify icon color (yellow_1) - see: http://open.mapquestapi.com/staticmap/icons.html - - -n specify the icon number (1) - - -o specify output basename without file extension (osmimage.IMAGETYPE) - - -q quiet; no output! - - -v prints version information - - -h prints help information - -]]) - pversion() -end - -function osmimage_error(exitcode, errortext) - io.stderr:write ("Error (" .. exitcode .. "): " .. errortext .. "\n") - os.exit(exitcode) -end - -function osmimage_warning(warningtext) - io.stderr:write("WARNING: " .. warningtext .. "\n") -end - -function check_number(var, varname) - local number='^[0-9]+$' - if not(string.match(var, '^[0-9]+$')) then - osmimage_error(2, varname .. " can't be " .. var .. "! Not a number!") - end -end - -function check_range(var,min,max,exitcode,varname) - check_number(var,varname) - if (tonumber(var) < tonumber(min) or tonumber(var) > tonumber(max)) then - osmimage_error(exitcode, varname .. " = " .. var .. "; must be in the range of " .. min .. "-" .. max) - end -end - -do - local newarg = {} - local i, limit = 1, #arg - while (i <= limit) do - if arg[i] == "-k" then - KEY = arg[i+1] - i = i + 1 - elseif arg[i] == "-l" then - LOCATION = arg[i+1] - i = i + 1 - elseif arg[i] == "-x" then - XSIZE = arg[i+1] - i = i + 1 - elseif arg[i] == "-y" then - YSIZE = arg[i+1] - i = i + 1 - elseif arg[i] == "-S" then - SIZE = arg[i+1] - i = i + 1 - elseif arg[i] == "-s" then - SCALE = arg[i+1] - i = i + 1 - elseif arg[i] == "-z" then - ZOOM = arg[i+1] - i = i + 1 - elseif arg[i] == "-t" then - TYPE = arg[i+1] - i = i + 1 - elseif arg[i] == "-i" then - IMAGETYPE = arg[i+1] - i = i + 1 - elseif arg[i] == "-c" then - COLOR = arg[i+1] - i = i + 1 - elseif arg[i] == "-n" then - NUMBER = arg[i+1] - i = i + 1 - elseif arg[i] == "-o" then - OFILE = arg[i+1] - i = i + 1 - elseif arg[i] == "-q" then - QUIET = 1 - elseif arg[i] == "-v" then - pversion() - elseif arg[i] == "-h" then - phelp() - else - newarg[#newarg+1] = arg[i] - end - i = i + 1 - end - arg = newarg -end - -if QUIET == 1 then - osmimage_warning("-q option currently not supported!") -end - -if KEY == "" then - -- KEY="Kmjtd%7Cluu7n162n1%2C22%3Do5-h61wh" - KEY="Kmjtd|luu7n162n1,22=o5-h61wh" - osmimage_warning("KEY not specified; using mapquest example key as default!") -end - -if LOCATION == "" then - LOCATION = "Bergheimer Straße 110A, 69115 Heidelberg, Germany" - osmimage_warning("LOCATION not specified; using Dante e.V. Office as default!") -end - -if XSIZE == "" then - XSIZE=800 - osmimage_warning("XSIZE not specified; using XSIZE=800 as default!") -end - -check_range(XSIZE,1,3840,11,"XSIZE") - -if YSIZE == "" then - YSIZE=400 - osmimage_warning("YSIZE not specified; using YSIZE=400 as default!") -end -check_range(YSIZE,1,3840,12,"YSIZE") - -if SIZE == "" then - SIZE = XSIZE .. "," .. YSIZE -end - -if SCALE == "" then - if ZOOM == "" then - SCALE=3385 - osmimage_warning("SCALE not specified, using SCALE=3385 as default!") - end -else - check_range(SCALE,1692,221871572,13,"SCALE") -end - -if TYPE == "" then - TYPE = "map" - osmimage_warning("TYPE not specified; using map as default!") -end - -if IMAGETYPE == "" then - IMAGETYPE="png" - osmimage_warning("IMAGETYPE not specified; using png as default!") -end - -if COLOR == "" then - COLOR="yellow_1" - osmimage_warning("COLOR not specified; using yellow_1 as default!") -end - -if NUMBER == "" then - NUMBER=1 - osmimage_warning("NUMBER not specified; using 1 as default!") -end -check_number(NUMBER,"NUMBER") - -local UKEY = "?key=" .. url.escape(KEY) -local ULOCATION = "&location=" .. url.escape(LOCATION) -local USIZE = "&size=" .. url.escape(SIZE) -local USCALEZOOM -if ZOOM == "" then - USCALEZOOM = "&scale=" .. url.escape(SCALE) -else - check_range(ZOOM,1,18,14,"ZOOM") - USCALEZOOM = "&zoom=" .. url.escape(ZOOM) -end -local UTYPE = "&type=" .. url.escape(TYPE) -local UIMAGETYPE = "&imagetype=" .. url.escape(IMAGETYPE) -local USHOWICON = "&showicon=" .. url.escape(COLOR) .. "-" .. url.escape(NUMBER) -local UOFILE = OFILE .. "." .. IMAGETYPE - -local IMGURL = URL .. UKEY .. ULOCATION .. USIZE .. USCALEZOOM .. UTYPE .. UIMAGETYPE .. USHOWICON - -local ret, msg -local ofile -ofile, msg = io.open(UOFILE, "wb") -if not ofile then - osmimage_error(21, msg) -end -print("\n\nosmimage.lua:") -print("url = " .. IMGURL) -print("output = " .. UOFILE) -ret, msg = http.request{ - url = IMGURL, - sink = ltn12.sink.file(ofile) -} -if not ret then - osmimage_error(22, msg) -end - diff --git a/Master/texmf-dist/tex/latex/getmap/getmap.cfg b/Master/texmf-dist/tex/latex/getmap/getmap.cfg new file mode 100644 index 00000000000..a389f27ac95 --- /dev/null +++ b/Master/texmf-dist/tex/latex/getmap/getmap.cfg @@ -0,0 +1,39 @@ +%% +%% This is file `getmap.cfg', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% getmap.dtx (with options: `cfgfile') +%% +%% Copyright (C) 2014 by: +%% Josef Kleber +%% <josef.kleber@gmx.de> +%% +%% This file may be distributed and/or modified under the conditions of +%% the LaTeX Project Public License, either version 1.3 of this license +%% or (at your option) any later version. The latest version of this +%% license is in: +%% +%% http://www.latex-project.org/lppl.txt +%% +%% and version 1.3 or later is part of all distributions of LaTeX version +%% 2003/12/01 or later. +%% +%% This work has the LPPL maintenance status "author-maintained". +%% +%% The Current Maintainer of this work is Josef Kleber. +%% +%% This work consists of all files listed in manifest.txt. +%% +%% +%% +%% copy this file to your local or home tree +%% and put it under TEXMF/tex/latex/getmap +%% run texhash afterwards +%% +%% +\gdef\GM@JK@key{Fmjtd|luur20u22d,75=o5-9aylh6}% +\endinput +%% +%% End of file `getmap.cfg'. diff --git a/Master/texmf-dist/tex/latex/getmap/getmap.sty b/Master/texmf-dist/tex/latex/getmap/getmap.sty index fd25b08c1d8..de8d3d34243 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/06/24 v1.1 getmap.sty - Josef Kleber (C) 2014]% +\ProvidesPackage{getmap}[2014/07/15 v1.2 getmap.sty - Josef Kleber (C) 2014]% \RequirePackage{xkeyval}% \RequirePackage{stringenc}% \RequirePackage{ifthen}% @@ -43,8 +43,9 @@ \expandafter\def\csname#1@#3\endcsname{##1}% }% }% -\GM@JK@define@key{GM@JK}{getmap}{key}{Kmjtd|luu7n162n1,22=o5-h61wh}% -\GM@JK@define@key{GM@JK}{getmap}{xsize}{800}% +\GM@JK@define@key{GM@JK}{getmap}{mode}{osm}% +\GM@JK@define@key{GM@JK}{getmap}{key}{}% +\GM@JK@define@key{GM@JK}{getmap}{xsize}{600}% \GM@JK@define@key{GM@JK}{getmap}{ysize}{400}% \GM@JK@define@key{GM@JK}{getmap}{scale}{3385}% \GM@JK@define@key{GM@JK}{getmap}{zoom}{}% @@ -52,10 +53,18 @@ \GM@JK@define@key{GM@JK}{getmap}{imagetype}{png}% \GM@JK@define@key{GM@JK}{getmap}{color}{yellow_1}% \GM@JK@define@key{GM@JK}{getmap}{number}{1}% -\GM@JK@define@key{GM@JK}{getmap}{file}{osmimage}% +\GM@JK@define@key{GM@JK}{getmap}{file}{getmap}% \GM@JK@define@key{GM@JK}{getmap}{inputencoding}{}% \GM@JK@define@key{GM@JK}{getmap}{overwrite}{true}% \gdef\GM@JK@overwrite{false}% +\gdef\GM@JK@key{}% +\IfFileExists{getmap.cfg}% +{% + \input{getmap.cfg}% +}% +{% + \gdef\GM@JK@key{Fmjtd|luur20u22d,75=o5-9aylh6}% +}% \@ifpackageloaded{inputenc}% {% \gdef\GM@JK@inputencoding{\inputencodingname}% @@ -64,8 +73,16 @@ \gdef\GM@JK@inputencoding{utf8}% }% \newif\ifGM@JK@writexviii\GM@JK@writexviiifalse% -\ExecuteOptionsX{key,xsize,ysize,scale,zoom,type,imagetype,color,number,file}% +\ExecuteOptionsX{mode,xsize,ysize,scale,zoom,type,imagetype,color,number,file}% \ProcessOptionsX\relax% +\ifthenelse{\equal{\GM@JK@mode}{gm}}% +{% + \gdef\GM@JK@scale{1}% + \gdef\GM@JK@zoom{17}% + \gdef\GM@JK@type{roadmap}% + \gdef\GM@JK@color{blue}% +}% +{}% \ltx@IfUndefined{pdf@shellescape}% {% \PackageInfo{getmap}{\pdf@shellescape is undefined}% @@ -83,13 +100,15 @@ }% \newcommand*\GM@JK@shellescape% {% - \ifGM@JK@writexviii% - \ifthenelse{\equal{\GM@JK@zoom}{}}% + \ifGM@JK@writexviii\relax% + \ifthenelse{\equal{\GM@JK@mode}{osm}}% {% - \immediate\write18{osmimage \space-l\space "\GM@JK@location@string"% + \immediate\write18{getmapdl \space-l\space "\GM@JK@location@string"% + \space-m\space osm% \space-k\space "\GM@JK@key@string"% \space-x\space \GM@JK@xsize% \space-y\space \GM@JK@ysize% + \space-z\space "\GM@JK@zoom"% \space-s\space \GM@JK@scale% \space-t\space \GM@JK@type% \space-i\space \GM@JK@imagetype% @@ -98,11 +117,12 @@ \space-o\space \GM@JK@file}% }% {% - \immediate\write18{osmimage \space-l\space "\GM@JK@location@string"% - \space-k\space "\GM@JK@key@string% + \immediate\write18{getmapdl \space-l\space "\GM@JK@location@string"% + \space-m\space gm% \space-x\space \GM@JK@xsize% \space-y\space \GM@JK@ysize% \space-z\space \GM@JK@zoom% + \space-s\space \GM@JK@scale% \space-t\space \GM@JK@type% \space-i\space \GM@JK@imagetype% \space-c\space "\GM@JK@color"% @@ -110,7 +130,7 @@ \space-o\space \GM@JK@file}% }% \else% - \PackageError{getmap}{\write18 disabled} + \PackageError{getmap}{\write18 disabled}% {\write18 disabled\MessageBreak% Use -shell-escape (TeXLive)\MessageBreak% or\space\space--enable-write18 (MiKTeX)}% @@ -120,6 +140,15 @@ {% \begingroup% \setkeys{getmap}{#1}% + \ifthenelse{\equal{\GM@JK@mode}{gm}}% + {% + \def\GM@JK@scale{1}% + \def\GM@JK@zoom{17}% + \def\GM@JK@type{roadmap}% + \def\GM@JK@color{blue}% + }% + {}% + \setkeys{getmap}{#1}% \PackageInfo{getmap}{using \GM@JK@inputencoding\space encoding}% \def\GM@JK@location{#2}% \StringEncodingConvert% |