diff options
author | Karl Berry <karl@freefriends.org> | 2014-06-24 17:54:51 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2014-06-24 17:54:51 +0000 |
commit | d5da2d8e71a9fec467343ea6f8c68228c54e0f24 (patch) | |
tree | 286128bec30bd9cfe4b03579567f646c380bd520 | |
parent | e1a3b7c2ba086fd66714cde211d6b996d926d4f7 (diff) |
getmap (24jun14)
git-svn-id: svn://tug.org/texlive/trunk@34379 c570f23f-e606-0410-a88d-b1316a301751
37 files changed, 2325 insertions, 1 deletions
diff --git a/Build/source/texk/texlive/linked_scripts/Makefile.am b/Build/source/texk/texlive/linked_scripts/Makefile.am index 6ba879c1c5d..7950e94640a 100644 --- a/Build/source/texk/texlive/linked_scripts/Makefile.am +++ b/Build/source/texk/texlive/linked_scripts/Makefile.am @@ -102,6 +102,7 @@ texmf_other_scripts = \ fontools/autoinst \ fontools/ot2kpx \ fragmaster/fragmaster.pl \ + getmap/osmimage.lua \ glossaries/makeglossaries \ jfontmaps/kanji-fontmap-creator.pl \ jfontmaps/kanji-config-updmap.pl \ diff --git a/Build/source/texk/texlive/linked_scripts/Makefile.in b/Build/source/texk/texlive/linked_scripts/Makefile.in index 505ba4f2834..8fc2550516c 100644 --- a/Build/source/texk/texlive/linked_scripts/Makefile.in +++ b/Build/source/texk/texlive/linked_scripts/Makefile.in @@ -309,6 +309,7 @@ texmf_other_scripts = \ fontools/autoinst \ fontools/ot2kpx \ fragmaster/fragmaster.pl \ + getmap/osmimage.lua \ glossaries/makeglossaries \ jfontmaps/kanji-fontmap-creator.pl \ jfontmaps/kanji-config-updmap.pl \ diff --git a/Build/source/texk/texlive/linked_scripts/getmap/osmimage.lua b/Build/source/texk/texlive/linked_scripts/getmap/osmimage.lua new file mode 100644 index 00000000000..55220ed5219 --- /dev/null +++ b/Build/source/texk/texlive/linked_scripts/getmap/osmimage.lua @@ -0,0 +1,261 @@ +#!/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/bin/alpha-linux/osmimage b/Master/bin/alpha-linux/osmimage new file mode 120000 index 00000000000..fb996eb944c --- /dev/null +++ b/Master/bin/alpha-linux/osmimage @@ -0,0 +1 @@ +../../texmf-dist/scripts/getmap/osmimage.lua
\ No newline at end of file diff --git a/Master/bin/amd64-freebsd/osmimage b/Master/bin/amd64-freebsd/osmimage new file mode 120000 index 00000000000..fb996eb944c --- /dev/null +++ b/Master/bin/amd64-freebsd/osmimage @@ -0,0 +1 @@ +../../texmf-dist/scripts/getmap/osmimage.lua
\ No newline at end of file diff --git a/Master/bin/amd64-kfreebsd/osmimage b/Master/bin/amd64-kfreebsd/osmimage new file mode 120000 index 00000000000..fb996eb944c --- /dev/null +++ b/Master/bin/amd64-kfreebsd/osmimage @@ -0,0 +1 @@ +../../texmf-dist/scripts/getmap/osmimage.lua
\ No newline at end of file diff --git a/Master/bin/amd64-netbsd/osmimage b/Master/bin/amd64-netbsd/osmimage new file mode 120000 index 00000000000..fb996eb944c --- /dev/null +++ b/Master/bin/amd64-netbsd/osmimage @@ -0,0 +1 @@ +../../texmf-dist/scripts/getmap/osmimage.lua
\ No newline at end of file diff --git a/Master/bin/armel-linux/osmimage b/Master/bin/armel-linux/osmimage new file mode 120000 index 00000000000..fb996eb944c --- /dev/null +++ b/Master/bin/armel-linux/osmimage @@ -0,0 +1 @@ +../../texmf-dist/scripts/getmap/osmimage.lua
\ No newline at end of file diff --git a/Master/bin/armhf-linux/osmimage b/Master/bin/armhf-linux/osmimage new file mode 120000 index 00000000000..fb996eb944c --- /dev/null +++ b/Master/bin/armhf-linux/osmimage @@ -0,0 +1 @@ +../../texmf-dist/scripts/getmap/osmimage.lua
\ No newline at end of file diff --git a/Master/bin/i386-cygwin/osmimage b/Master/bin/i386-cygwin/osmimage new file mode 120000 index 00000000000..fb996eb944c --- /dev/null +++ b/Master/bin/i386-cygwin/osmimage @@ -0,0 +1 @@ +../../texmf-dist/scripts/getmap/osmimage.lua
\ No newline at end of file diff --git a/Master/bin/i386-freebsd/osmimage b/Master/bin/i386-freebsd/osmimage new file mode 120000 index 00000000000..fb996eb944c --- /dev/null +++ b/Master/bin/i386-freebsd/osmimage @@ -0,0 +1 @@ +../../texmf-dist/scripts/getmap/osmimage.lua
\ No newline at end of file diff --git a/Master/bin/i386-kfreebsd/osmimage b/Master/bin/i386-kfreebsd/osmimage new file mode 120000 index 00000000000..fb996eb944c --- /dev/null +++ b/Master/bin/i386-kfreebsd/osmimage @@ -0,0 +1 @@ +../../texmf-dist/scripts/getmap/osmimage.lua
\ No newline at end of file diff --git a/Master/bin/i386-linux/osmimage b/Master/bin/i386-linux/osmimage new file mode 120000 index 00000000000..fb996eb944c --- /dev/null +++ b/Master/bin/i386-linux/osmimage @@ -0,0 +1 @@ +../../texmf-dist/scripts/getmap/osmimage.lua
\ No newline at end of file diff --git a/Master/bin/i386-netbsd/osmimage b/Master/bin/i386-netbsd/osmimage new file mode 120000 index 00000000000..fb996eb944c --- /dev/null +++ b/Master/bin/i386-netbsd/osmimage @@ -0,0 +1 @@ +../../texmf-dist/scripts/getmap/osmimage.lua
\ No newline at end of file diff --git a/Master/bin/i386-solaris/osmimage b/Master/bin/i386-solaris/osmimage new file mode 120000 index 00000000000..fb996eb944c --- /dev/null +++ b/Master/bin/i386-solaris/osmimage @@ -0,0 +1 @@ +../../texmf-dist/scripts/getmap/osmimage.lua
\ No newline at end of file diff --git a/Master/bin/mipsel-linux/osmimage b/Master/bin/mipsel-linux/osmimage new file mode 120000 index 00000000000..fb996eb944c --- /dev/null +++ b/Master/bin/mipsel-linux/osmimage @@ -0,0 +1 @@ +../../texmf-dist/scripts/getmap/osmimage.lua
\ No newline at end of file diff --git a/Master/bin/powerpc-linux/osmimage b/Master/bin/powerpc-linux/osmimage new file mode 120000 index 00000000000..fb996eb944c --- /dev/null +++ b/Master/bin/powerpc-linux/osmimage @@ -0,0 +1 @@ +../../texmf-dist/scripts/getmap/osmimage.lua
\ No newline at end of file diff --git a/Master/bin/sparc-solaris/osmimage b/Master/bin/sparc-solaris/osmimage new file mode 120000 index 00000000000..fb996eb944c --- /dev/null +++ b/Master/bin/sparc-solaris/osmimage @@ -0,0 +1 @@ +../../texmf-dist/scripts/getmap/osmimage.lua
\ No newline at end of file diff --git a/Master/bin/universal-darwin/osmimage b/Master/bin/universal-darwin/osmimage new file mode 120000 index 00000000000..fb996eb944c --- /dev/null +++ b/Master/bin/universal-darwin/osmimage @@ -0,0 +1 @@ +../../texmf-dist/scripts/getmap/osmimage.lua
\ No newline at end of file diff --git a/Master/bin/win32/osmimage.exe b/Master/bin/win32/osmimage.exe Binary files differnew file mode 100755 index 00000000000..5777d90a17a --- /dev/null +++ b/Master/bin/win32/osmimage.exe diff --git a/Master/bin/x86_64-cygwin/osmimage b/Master/bin/x86_64-cygwin/osmimage new file mode 120000 index 00000000000..fb996eb944c --- /dev/null +++ b/Master/bin/x86_64-cygwin/osmimage @@ -0,0 +1 @@ +../../texmf-dist/scripts/getmap/osmimage.lua
\ No newline at end of file diff --git a/Master/bin/x86_64-darwin/osmimage b/Master/bin/x86_64-darwin/osmimage new file mode 120000 index 00000000000..fb996eb944c --- /dev/null +++ b/Master/bin/x86_64-darwin/osmimage @@ -0,0 +1 @@ +../../texmf-dist/scripts/getmap/osmimage.lua
\ No newline at end of file diff --git a/Master/bin/x86_64-linux/osmimage b/Master/bin/x86_64-linux/osmimage new file mode 120000 index 00000000000..fb996eb944c --- /dev/null +++ b/Master/bin/x86_64-linux/osmimage @@ -0,0 +1 @@ +../../texmf-dist/scripts/getmap/osmimage.lua
\ No newline at end of file diff --git a/Master/bin/x86_64-solaris/osmimage b/Master/bin/x86_64-solaris/osmimage new file mode 120000 index 00000000000..fb996eb944c --- /dev/null +++ b/Master/bin/x86_64-solaris/osmimage @@ -0,0 +1 @@ +../../texmf-dist/scripts/getmap/osmimage.lua
\ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/getmap/README b/Master/texmf-dist/doc/latex/getmap/README new file mode 100644 index 00000000000..bd1438fd0b1 --- /dev/null +++ b/Master/texmf-dist/doc/latex/getmap/README @@ -0,0 +1,54 @@ +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. + +License: LPPL + +Changes in v1.1: + +- Bugfix: problem in URL with \usepackage[utf8]{inputenc} + + reported by: Ulrike Fischer + +- added makefile and install.bat + for easy manual installation + + INSTALL +=========== + +First of all, install the package with the package manager of +your TeX distribution, if possible. + +Manual installation: + +download getmap.dtx, osmimage.png 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 + + Moreover, there are the following usefull make targets: + + uninstall deletes the package in $TEXMFOCAL + package only extracts the files + clean cleans all aux files + cleanall cleans all files except the downloaded files + and getmap.pdf + +* Windows + + In MiKTeX scripts like osmimage.lua must be registered. + This can not be done manually! Please use the package + manager to install getmap. + + For TeXLive simply run install.bat! It assumes that you + use a standard installation of TeXLive2014. Otherwise you + must adjust the variables in the first lines of install.bat! + diff --git a/Master/texmf-dist/doc/latex/getmap/getmap.dtx b/Master/texmf-dist/doc/latex/getmap/getmap.dtx new file mode 100644 index 00000000000..ecd02887ade --- /dev/null +++ b/Master/texmf-dist/doc/latex/getmap/getmap.dtx @@ -0,0 +1,1198 @@ +% \iffalse meta-comment +% !TEX program = pdfLaTeX +%<*internal> +\iffalse +%</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. + +License: LPPL + +Changes in v1.1: + +- Bugfix: problem in URL with \usepackage[utf8]{inputenc} + + reported by: Ulrike Fischer + +- added makefile and install.bat + for easy manual installation + + + INSTALL +=========== + +First of all, install the package with the package manager of +your TeX distribution, if possible. + +Manual installation: + +download getmap.dtx, osmimage.png 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 + + Moreover, there are the following usefull make targets: + + uninstall deletes the package in $TEXMFOCAL + package only extracts the files + clean cleans all aux files + cleanall cleans all files except the downloaded files + and getmap.pdf + + +* Windows + + In MiKTeX scripts like osmimage.lua must be registered. + This can not be done manually! Please use the package + manager to install getmap. + + For TeXLive simply run install.bat! It assumes that you + use a standard installation of TeXLive2014. Otherwise you + must adjust the variables in the first lines of install.bat! + +%</readme> +%<*bibfile> +@misc{bib:devmapquest, + author = {{MapQuest, Inc}}, + note = {\href{http://developer.mapquest.com}{http://developer.mapquest.com}}, + title = {Introducing the Data Manager API Web Service}, + year = {2014}, + } + +@misc{bib:mapquestopen, + author = {{MapQuest, Inc}}, + note = {\href{http://open.mapquestapi.com/}{http://open.mapquestapi.com/}}, + title = {MapQuest Open Platform Web Services}, + year = {2014}, + } + +@misc{bib:mapquestopenzoomscale, + author = {{MapQuest, Inc}}, + note = {\href{http://open.mapquestapi.com/staticmap/zoomToScale.html}{http://open.mapquestapi.com/staticmap/zoomToScale.html}}, + title = {Zoom To Scale Mapping}, + year = {2014}, + } + +@misc{bib:mapquestopencolors, + author = {{MapQuest, Inc}}, + note = {\href{http://open.mapquestapi.com/staticmap/icons.html}{http://open.mapquestapi.com/staticmap/icons.html}}, + title = {Static Map Service: Standard Icons}, + year = {2014}, + } + +%</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] +-- +-- 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 + +%</luafile> +%<*manifest> +This work consists of the following files: + +getmap.pdf +getmap.dtx +osmimage.png +README +makefile +install.bat +%</manifest> +%<*internal> +\fi +\def\nameofplainTeX{plain} +\ifx\fmtname\nameofplainTeX\else + \expandafter\begingroup +\fi +%</internal> +%<*install> +\input docstrip.tex +\keepsilent +\askforoverwritefalse +\preamble + +Copyright (C) 2014 by: +Josef Kleber +<josef.kleber@gmx.de> + +This file may be distributed and/or modified under the conditions of +the LaTeX Project Public License, either version 1.3 of this license +or (at your option) any later version. The latest version of this +license is in: + + http://www.latex-project.org/lppl.txt + +and version 1.3 or later is part of all distributions of LaTeX version +2003/12/01 or later. + +This work has the LPPL maintenance status "author-maintained". + +The Current Maintainer of this work is Josef Kleber. + +This work consists of all files listed in manifest.txt. + +\endpreamble + +\usedir{tex/latex/getmap} +\generate{ + \file{\jobname.sty}{\from{\jobname.dtx}{package}} +} +%</install> +%<install>\endbatchfile +%<*internal> +\usedir{source/latex/getmap} +\generate{ + \file{\jobname.ins}{\from{\jobname.dtx}{install}} +} +\nopreamble\nopostamble +\usedir{doc/latex/getmap} +\generate{ + \file{README.txt}{\from{\jobname.dtx}{readme}} +} +\generate{ + \file{manifest.txt}{\from{\jobname.dtx}{manifest}} +} +\generate{ + \file{\jobname.bib}{\from{\jobname.dtx}{bibfile}} +} +\generate{ + \file{osmimage.sh}{\from{\jobname.dtx}{bashfile}} +} +\generate{ + \file{osmimage.lua}{\from{\jobname.dtx}{luafile}} +} +\ifx\fmtname\nameofplainTeX + \expandafter\endbatchfile +\else + \expandafter\endgroup +\fi +%</internal> +%<*driver> +\documentclass[a4paper]{ltxdoc}% +\usepackage[english]{babel}% +\usepackage[utf8]{inputenc}% +\usepackage[T1]{fontenc}% +\usepackage{textcomp}% +\usepackage{lmodern}% +\usepackage{bera}% +\usepackage[svgnames,rgb]{xcolor}% +\usepackage{makeidx} +\usepackage{ragged2e} +\usepackage{ccicons} +\usepackage{tabularx} +\usepackage{microtype}% +\usepackage{listings} +\usepackage{nicefrac} +\usepackage[numbered]{hypdoc} +\usepackage{marginnote}% +\usepackage[automark,nouppercase]{scrpage2} +\usepackage[tocgraduated]{tocstyle} +\usetocstyle{classic} +\usepackage{getmap} +\usepackage{tikz} +% turn off idiotic tikz error in doc generation +\makeatletter +\global\let\tikz@ensure@dollar@catcode=\relax +\makeatother +\usepackage{hyperref} +\EnableCrossrefs +\CodelineIndex +\RecordChanges +\makeatletter +\setlength{\headheight}{1.1\baselineskip}% +\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}% + {-2.5ex\@plus -1ex \@minus -.25ex}% + {1.25ex \@plus .25ex}% + {\normalfont\normalsize\bfseries}} +\setcounter{secnumdepth}{5} +\setcounter{tocdepth}{5} +\hypersetup{colorlinks=true,urlcolor=NavyBlue,linkcolor=NavyBlue,citecolor=CornflowerBlue}% +\lstset{literate=% + {Ö}{{\"O}}1 + {Ä}{{\"A}}1 + {Ü}{{\"U}}1 + {ß}{{\ss}}1 + {ü}{{\"u}}1 + {ä}{{\"a}}1 + {ö}{{\"o}}1 + {~}{{\textasciitilde}}1 +} +\lstset{language=[LaTeX]TeX,numbers=left,numberstyle=\tiny, basicstyle=\ttfamily, aboveskip=\baselineskip, frame=single, backgroundcolor=\color{LightGoldenrodYellow}, keywordstyle=\color{Blue}, +emph={}} +\renewcommand{\maketitle}% +{% + \thispagestyle{empty}% + \pagecolor{Ivory}% + \begin{titlepage}% + \begin{tikzpicture}[remember picture,overlay]% + \node[yshift=-2cm] at (current page.north west)% + {% + \begin{tikzpicture}[remember picture, overlay]% + \draw[fill=CornflowerBlue,color=CornflowerBlue] (0,0) rectangle% + (\paperwidth,2cm);% + \draw[anchor=west,yshift=-4cm,xshift=3cm,color=NavyBlue] (0,0) node% + {\parbox{15cm}{\RaggedRight\Huge\sffamily\textbf{\@title}}};% + \draw[anchor=west,yshift=-6cm,xshift=3cm,color=NavyBlue] (0,0) node% + {\parbox{15cm}{\huge\sffamily\textbf{\@fileversion}}};% + \draw[anchor=west,yshift=-9cm,xshift=3cm,color=NavyBlue] (0,0) node% + {\parbox{15cm}{\RaggedRight\huge\sffamily\textbf{\@subtitle}}};% + \draw[anchor=west,yshift=-13cm,xshift=3cm,color=NavyBlue] (0,0) node% + {\includegraphics[width=10cm]{osmimage}};% + \draw[anchor=west,yshift=-17cm,xshift=3cm,color=NavyBlue] (0,0) node% + {\parbox{15cm}{\huge\sffamily\textbf{\@date}}};% + \draw[anchor=west,yshift=-20cm,xshift=3cm,color=NavyBlue] (0,0) node% + {\parbox{15cm}{\Large\sffamily{\@authorline\\\textbf{\@author}}}};% + \end{tikzpicture}% + };% + \node[yshift=0cm] at (current page.south west)% + {% + \begin{tikzpicture}[remember picture, overlay]% + \draw[fill=NavyBlue,color=NavyBlue,yshift=6cm,xshift=2cm] (0,0) rectangle (0.2cm,19cm);% + \draw[fill=CornflowerBlue,color=CornflowerBlue] (0,0) rectangle (\paperwidth,2cm);% + \draw[anchor=west,yshift=1cm,xshift=3cm,color=NavyBlue] (0,0) node% + {\parbox{15cm}{\large\sffamily{\@refline}}};% + \end{tikzpicture}% + };% + \end{tikzpicture}% + \end{titlepage}% + \pagecolor{white}% +}% +% +\newcommand*{\@tikzhead}[1]% +{% + \begin{tikzpicture}[remember picture,overlay]% + \node[yshift=-2cm] at (current page.north west)% + {% + \begin{tikzpicture}[remember picture, overlay]% + \draw[fill=CornflowerBlue] (0,0) rectangle (\paperwidth,2cm);% + \draw[anchor=west,yshift=1cm,xshift=1.5cm,color=NavyBlue] (0,0) node% + {\parbox{15cm}{\LARGE\sffamily\textbf{\@title}}};% + \node[anchor=east,xshift=.9\paperwidth,rectangle,% + rounded corners=15pt,inner sep=11pt,fill=NavyBlue]% + {\color{white}\textsc{#1}};% + \end{tikzpicture}% + };% + \end{tikzpicture}% +}% +\clearscrheadings% +\ihead{\@tikzhead{\headmark}}% +\cfoot{\upshape\thepage}% +\pagestyle{scrheadings}% +% +\newcommand*{\Headline}[1]{\@mkboth{#1}{#1}}% +% +\renewcommand{\headfont}{\normalfont\mdseries\scshape} +% +\gdef\@subtitle{}% +\providecommand*{\Subtitle}[1]{\gdef\@subtitle{#1}}% +\gdef\@fileversion{}% +\providecommand*{\Fileversion}[1]{\gdef\@fileversion{#1}}% +\gdef\@author{}% +\providecommand*{\Author}[1]{\gdef\@author{#1}}% +\gdef\@authorline{Package author:}% +\providecommand*{\Authorline}[1]{\gdef\@authorline{#1}}% +\gdef\@refline{}% +\providecommand*{\Refline}[1]{\gdef\@refline{#1}}% +\gdef\and{\unskip{}, }% +\newcommand\doubledash{-\kern0.5pt-} +\def\enoteformat{\rightskip\z@ \leftskip\z@ \parindent=1em\leavevmode\llap{\makeenmark}} +\def\filename{logicpuzzle.sty}% +\def\XeLaTeX{Xe\LaTeX}% +% +\newenvironment{optionlist} +{\begin{trivlist}\setlength\leftskip{2em}} +{\end{trivlist}} +\newcommand\optitem[3]{\item [\texttt{\textbf{\textcolor{DodgerBlue}{#1}} \lbrack\textcolor{Crimson}{#2}\rbrack}] #3} +\renewcommand\tableofcontents% +{% + %\section*{\contentsname}% + \@mkboth{% + \MakeUppercase\contentsname}{\MakeUppercase\contentsname}% + \@starttoc{toc}% +}% +% +\newcommand\env[1]{\texttt{#1}}% +\newcommand\layer[1]{\texttt{#1}\SortIndex{#1}{\texttt{#1} (PGF layer)}% + \SortIndex{PGF layer>#1}{\texttt{#1}}}% +\newcommand\styleoption[1]{\texttt{#1}\SortIndex{#1}{\texttt{#1} (Style option)}% + \SortIndex{Style option>#1}{\texttt{#1}}}% +\newcommand\envoption[1]{\texttt{#1}\SortIndex{#1}{\texttt{#1} (Puzzle option)}% + \SortIndex{Puzzle option>#1}{\texttt{#1}}}% +\newcommand\stylename[1]{\texttt{#1}\SortIndex{#1}{\texttt{#1} (Style file)}% + \SortIndex{Style file>#1}{\texttt{#1}}}% +\newcommand\package[1]{\texttt{#1}\SortIndex{#1}{\texttt{#1} (Package)}% + \SortIndex{Package>#1}{\texttt{#1}}}% +\newcommand*\margcs[1]{\marginnote{\hbadness=10000\RaggedLeft\scriptsize #1}}% +\def\PrintIndex{\clearpage\Headline{Index}\@input@{\jobname.ind}% + \global\let\PrintIndex\@empty} + \renewenvironment{theindex} + {\if@twocolumn + \@restonecolfalse + \else + \@restonecoltrue + \fi + \columnseprule \z@ + \columnsep 35\p@ +\def\see##1##2{\textit{See} ##1}% +\def\seealso##1##2{\textit{See also} ##1}% +\long\def\cmd##1{\cs{\expandafter\cmd@to@cs\string##1}}% +\def\@url##1{\url@break\ttt{##1}\endgroup}% +\def\ttt{\begingroup\@sanitize\ttfamily\@ttt}% +\def\@ttt##1{##1\endgroup}% +\mathchardef\save@secnumdepth\c@secnumdepth +\c@secnumdepth\m@ne + \phantomsection% + \twocolumn%[\section{\indexname}]% + \refstepcounter{section} + \addcontentsline{toc}{section}{\protect\numberline{\thesection}Index}% +\c@secnumdepth\save@secnumdepth + %\thispagestyle{plain} + \parindent\z@ + \parskip\z@ \@plus .3\p@\relax + \let\item\@idxitem} + {\if@restonecol\onecolumn\else\clearpage\fi} +\setlength\parindent{0pt}% +\newcommand*\myref[1]{[see: \ref{#1} on page \pageref{#1}]} +\makeatother +\begin{document} + \DocInput{\jobname.dtx} +\end{document} +%</driver> +% \fi +% +%\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}% +%\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}}, +%morekeywords={getmap,includegraphics}} +%\DoNotIndex{\,,\begingroup,\endgroup,\csname,\def,\else,\endcsname,\equal,\expandafter, +%\fi,\gdef,\ifnum,\ifthenelse,\immediate,\MessageBreak,\NeedsTeXFormat,\newcommand,\newif, +%\PackageInfo,\PackageError,\ProcessOptionsX,\ProvidesPackage,\relax,\RequirePackage, +%\space,\errmessage,\ExecuteOptionsX,} +% +% \bibliographystyle{plain} +% \title{\filename}% +% \Subtitle{A style file for downloading \mbox{OpenStreetMap} maps}% +% \author{Josef Kleber} +% \Fileversion{\fileversion} +% \date{\filedate} +% \Refline{\href{mailto:josef.kleber@gmx.de}{\texttt{josef.kleber@gmx.de}}\\\href{https://bitbucket.org/kleberj/getmap/}{\texttt{https://bitbucket.org/kleberj/getmap/}}} +% \maketitle +% \stepcounter{page} +% \tableofcontents +% \clearpage +% \setlength\parskip{6pt}% +% +% +%\StopEventually{^^A +% { +% \clearpage +% \raggedright +% \nocite{*} +% \bibliography{getmap} +% } +% \clearpage +% \PrintChanges +% \PrintIndex +%} +% +% \Headline{Abstract} +% \begin{abstract} +% The goal of this package is the simplest possible provision of 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. +% \end{abstract} +% \vfill +% \renewcommand*{\abstractname}{Acknowledgment} +% \begin{abstract} +% I want to thank Norbert Preining, who did most of the recoding of \texttt{osmimage} +% (\texttt{Bash} $\rightarrow$ \texttt{Lua}). Moreover many thanks to Taco Hoekwater, +% Reinhard Kotucha and Heiko Oberdiek for their valuable contributions. +% \end{abstract} +% \clearpage +% \section{Options} +% The following options can be used as package options with global scope, +% as well as options for the \cmd\getmap\ command with local scope! +% \subsection[\texttt{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 +% 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. +% \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 specifies the width of the map in pixels. +% If 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) +% \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 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, +% 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} +% \subsection[\texttt{number}]{\texttt{number (\underline{1})}} +% This option specifies the number of the marker. +% \subsection[\texttt{inputencoding}]{\texttt{inputencoding}} +% This option specifies the input encoding of your file. +% The download script requires the strings encoded in utf8. +% For the safe conversion the input encoding of the file is required. +% Normally, you don't have to specify an encoding. +% The package tries to evaluate the encoding given to \package{inputenc} or assumes utf8. +% Usually that should work. +% \subsection[\texttt{overwrite}]{\texttt{overwrite (\underline{false}\textbar{}true)}} +% With this option, you can specify whether the image should be downloaded in any case. +% By default, the option is set to \texttt{false} in order to save bandwidth and compilation time. +% Nevertheless a check is performed on the existence of the image and the +% image will be downloaded, if it is not present. +% In the case of \texttt{true}, the image will be downloaded anyway! +% BTW, \texttt{overwrite} is equivalent to \texttt{overwrite=true}. +% \section{Command(s)} +% \subsection{\cmd\getmap} +% With the \cmd\getmap\ command\margcs{\cmd\getmap\oarg{options}\marg{address}} you can download +% a map, if you enable \cmd\write18 (TeXLive: \texttt{-shell-escape}, MiKTeX: \texttt{-{}-enable-write18}). +% This is only necessary if you actually download an image. +% You can use the options described above to specify the properties of the downloaded image. +% After executing the command, the image is available in the current working directory! +% +% In the simplest case, you only need an address to download the map. +% By default, the image is saved under the name \texttt{osmimage.png}! +% If you need only one map (e.g. the office of Dante e.V.) in your document, it can be as simple as: +% +% \iffalse +%<*example> +% \fi +\begin{lstlisting} +\getmap{Bergheimer Straße 110A, 69115 Heidelberg, Germany} +\includegraphics[width=10cm]{osmimage} +\end{lstlisting} +% \iffalse +%</example> +% \fi +% +% \includegraphics[width=10cm]{osmimage} +% +% \clearpage +% \section{Implementation} +% \changes{v1.0}{2014/05/25}{CTAN upload} +% \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]% +% \end{macrocode} +% We need a few packages! +% \begin{macrocode} +\RequirePackage{xkeyval}% +\RequirePackage{stringenc}% +\RequirePackage{ifthen}% +% \end{macrocode} +% We provide a macro \cmd\GM@JK@define@key, which defines package options with global scope% +% and options for \cmd\getmap\ with local scope. It takes four arguments \marg{prefix},% +% \marg{package},\marg{option} and \marg{default}. +% \begin{macrocode} +\newcommand*\GM@JK@define@key[4]% +{% + \expandafter\gdef\csname#1@#3\endcsname{#4}% + \define@key{#2.sty}{#3}[#4]% + {% + \expandafter\gdef\csname#1@#3\endcsname{##1}% + }% + \define@key{#2}{#3}% + {% + \expandafter\def\csname#1@#3\endcsname{##1}% + }% +}% +% \end{macrocode} +% Now, we can use this macro to define our options. +% \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}{ysize}{400}% +\GM@JK@define@key{GM@JK}{getmap}{scale}{3385}% +\GM@JK@define@key{GM@JK}{getmap}{zoom}{}% +\GM@JK@define@key{GM@JK}{getmap}{type}{map}% +\GM@JK@define@key{GM@JK}{getmap}{imagetype}{png}% +\GM@JK@define@key{GM@JK}{getmap}{color}{yellow_1}% +\GM@JK@define@key{GM@JK}{getmap}{number}{1}% +\GM@JK@define@key{GM@JK}{getmap}{file}{osmimage}% +\GM@JK@define@key{GM@JK}{getmap}{inputencoding}{}% +\GM@JK@define@key{GM@JK}{getmap}{overwrite}{true}% +% \end{macrocode} +% For options without default value, we define reasonable default values! +% We overwrite the default for \styleoption{overwrite}, because we don't want +% \styleoption{overwrite} to be \texttt{true} by default, but that \styleoption{overwrite} +% is equivalent to \styleoption{overwrite}=\texttt{true}! +% +% We try to use the input encoding specified for \package{inputenc} or \texttt{utf8} instead. +% \begin{macrocode} +\gdef\GM@JK@overwrite{false}% +% +\@ifpackageloaded{inputenc}% +{% + \gdef\GM@JK@inputencoding{\inputencodingname}% +}% +{% + \gdef\GM@JK@inputencoding{utf8}% +}% +% +% \end{macrocode} +% Later, we will need a switch, if \cmd\write18\ is enabled. +% \begin{macrocode} +\newif\ifGM@JK@writexviii\GM@JK@writexviiifalse% +% +% \end{macrocode} +% We execute the package options to define and set the option macros. +% \begin{macrocode} +\ExecuteOptionsX{key,xsize,ysize,scale,zoom,type,imagetype,color,number,file}% +% +\ProcessOptionsX\relax% +% +% \end{macrocode} +% We check if \cmd\pdf@shellescape\ is available to test if \cmd\write18 +% is enabled. +% +% If \texttt{false}, we assume \cmd\write18\ is available and hope for the best. +% +% If \texttt{true}, we set the switch \cmd\GM@JK@writexviii\ accordingly! +% \begin{macrocode} +\ltx@IfUndefined{pdf@shellescape}% +{% + \PackageInfo{getmap}{\pdf@shellescape is undefined}% + \PackageInfo{getmap}{can not test if \write18 is available}% + \GM@JK@writexviiitrue% +}% +{% + \PackageInfo{getmap}{\pdf@shellescape is available}% + \ifnum\pdf@shellescape=1\relax% + \PackageInfo{getmap}{\write18 enabled}% + \GM@JK@writexviiitrue% + \else% + \GM@JK@writexviiifalse% + \fi% +}% +% \end{macrocode} +% We define a macro that is executed as \cmd\write18\ call. First, we test if% +% \cmd\write18\ is enabled and issue a package error if not! Otherwise we execute% +% \cmd\write18\ depending on the existence of a \styleoption{zoom}% +% (\styleoption{zoom} overrides \styleoption{scale}). +% \begin{macrocode} +\newcommand*\GM@JK@shellescape% +{% + \ifGM@JK@writexviii% + \ifthenelse{\equal{\GM@JK@zoom}{}}% + {% + \immediate\write18{osmimage \space-l\space "\GM@JK@location@string"% + \space-k\space "\GM@JK@key@string"% + \space-x\space \GM@JK@xsize% + \space-y\space \GM@JK@ysize% + \space-s\space \GM@JK@scale% + \space-t\space \GM@JK@type% + \space-i\space \GM@JK@imagetype% + \space-c\space "\GM@JK@color"% + \space-n\space \GM@JK@number% + \space-o\space \GM@JK@file}% + }% + {% + \immediate\write18{osmimage \space-l\space "\GM@JK@location@string"% + \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-t\space \GM@JK@type% + \space-i\space \GM@JK@imagetype% + \space-c\space "\GM@JK@color"% + \space-n\space \GM@JK@number% + \space-o\space \GM@JK@file}% + }% + \else% + \PackageError{getmap}{\write18 disabled} + {\write18 disabled\MessageBreak% + Use -shell-escape (TeXLive)\MessageBreak% + or\space\space--enable-write18 (MiKTeX)}% + \fi% +}% +% \end{macrocode} +% \begin{macro}{\getmap} +% Here, we define the user command to download the map. +% +% \cs{getmap}\oarg{options}\marg{address} +% \begin{macrocode} +\newcommand*\getmap[2][]% +{% +% \end{macrocode} +% \changes{v1.1}{2014/06/23}{Bugfix: problem in URL when using \cmd\usepackage[utf8]\{inputenc\}} +% We start a group to keep the setting of options local. +% \begin{macrocode} + \begingroup% + \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}! +% \begin{macrocode} + \StringEncodingConvert% + {\GM@JK@location@string}% + {\detokenize\expandafter{\GM@JK@location}}% + {\GM@JK@inputencoding}{utf-8}% + \StringEncodingSuccessFailure% + {% + %success + }% + {% failure + \errmessage{Converting to UTF-8 failed}% + }% + \StringEncodingConvert% + {\GM@JK@key@string}% + {\detokenize\expandafter{\GM@JK@key}}% + {\GM@JK@inputencoding}{utf-8}% + \StringEncodingSuccessFailure% + {% + %success + }% + {% failure + \errmessage{Converting to UTF-8 failed}% + }% +% \end{macrocode} +% We check, if \styleoption{overwrite} is \texttt{true} and download the map. +% If not, we check if the image is already in the working directory. If not, we +% download the image! +% \begin{macrocode} + \ifthenelse{\equal{\GM@JK@overwrite}{true}}% + {% + \GM@JK@shellescape% + }% + {% + \IfFileExists{\GM@JK@file.\GM@JK@imagetype}% + {% + \PackageInfo{getmap}{overwrite=false; (\GM@JK@file.\GM@JK@imagetype)% + using existing file!}% + }% + {% + \PackageInfo{getmap}{overwrite=false; (\GM@JK@file.\GM@JK@imagetype)% + file does not exist! downloading ...}% + \GM@JK@shellescape% + }% + }% + \endgroup% +}% +% \end{macrocode} +% \end{macro} +% \begin{macrocode} +%</package> +% \end{macrocode} +%\Finale
\ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/getmap/getmap.pdf b/Master/texmf-dist/doc/latex/getmap/getmap.pdf Binary files differnew file mode 100644 index 00000000000..f804bf348e4 --- /dev/null +++ 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 new file mode 100755 index 00000000000..e0444d22f6d --- /dev/null +++ b/Master/texmf-dist/doc/latex/getmap/install.bat @@ -0,0 +1,60 @@ +@echo off +set texmfpath=C:\texlive\texmf-local +set texmfroot=C:\texlive\2014 +set tlarch=win32 +set pckname=getmap +echo. +echo. +echo Installing %pckname% into %texmfpath% +echo. +echo Creating %pckname%.pdf +pdflatex %pckname%.dtx >nul +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 +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 +md %texmfpath%\tex\latex\%pckname% >nul +copy *.sty %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 *.dtx %texmfpath%\doc\latex\%pckname% >nul +copy *.pdf %texmfpath%\doc\latex\%pckname% >nul +echo Running texhash +texhash >nul +del *.aux +del *.bib +del *.blg +del *.bbl +del *.gls +del *.glo +del *.hd +del *.idx +del *.ilg +del *.ind +del *.ins +del *.log +del *.out +del *.sty +del *.toc +del *.txt +del osmimage +del osmimage.lua +del README +echo Create osmimage.exe +pushd %texmfroot%\bin\%tlarch%\ +copy runscript.exe osmimage.exe >nul +popd +echo. +echo Done +echo.
\ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/getmap/makefile b/Master/texmf-dist/doc/latex/getmap/makefile new file mode 100644 index 00000000000..59d77b47347 --- /dev/null +++ b/Master/texmf-dist/doc/latex/getmap/makefile @@ -0,0 +1,66 @@ +TEXMF = $(shell kpsewhich -var-value TEXMFLOCAL) +BINDIR = /usr/local/bin +RM = rm -f +PKGNAME = getmap + +all: doc + +doc: $(PKGNAME).pdf package + +$(PKGNAME).pdf: + pdflatex $(PKGNAME).dtx + bibtex $(PKGNAME) + makeindex -s gind.ist $(PKGNAME) + makeindex -s gglo.ist $(PKGNAME).glo -o $(PKGNAME).gls + pdflatex $(PKGNAME).dtx + bibtex $(PKGNAME) + makeindex -s gind.ist $(PKGNAME) + makeindex -s gglo.ist $(PKGNAME).glo -o $(PKGNAME).gls + pdflatex $(PKGNAME).dtx + +package: + pdftex $(PKGNAME).dtx + mv osmimage.sh osmimage + mv README.txt README + +install: doc + mkdir -p ${TEXMF}/doc/latex/${PKGNAME} + cp README ${TEXMF}/doc/latex/${PKGNAME}/ + cp *.txt ${TEXMF}/doc/latex/${PKGNAME}/ + cp *.dtx ${TEXMF}/doc/latex/${PKGNAME}/ + cp *.pdf ${TEXMF}/doc/latex/${PKGNAME}/ + mkdir -p ${TEXMF}/tex/latex/${PKGNAME} + cp *.sty ${TEXMF}/tex/latex/${PKGNAME}/ + mkdir -p ${TEXMF}/scripts/${PKGNAME} + cp osmimage.lua osmimage ${TEXMF}/scripts/${PKGNAME}/ + texhash + chmod 0755 ${TEXMF}/scripts/${PKGNAME}/osmimage.lua + ln -s ${TEXMF}/scripts/${PKGNAME}/osmimage.lua ${BINDIR}/osmimage + +uninstall: + rm -rf ${TEXMF}/doc/latex/${PKGNAME} + rm -rf ${TEXMF}/tex/latex/${PKGNAME} + rm -rf ${TEXMF}/scripts/${PKGNAME} + rm -f ${BINDIR}/osmimage + 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 getmap.sty ./../dev/tex/latex/getmap/getmap.sty + +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 + +cleanall: clean + $(RM) osmimage osmimage.lua README + +.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 new file mode 100644 index 00000000000..2c39629c9b0 --- /dev/null +++ b/Master/texmf-dist/doc/latex/getmap/manifest.txt @@ -0,0 +1,8 @@ +This work consists of the following files: + +getmap.pdf +getmap.dtx +osmimage.png +README +makefile +install.bat diff --git a/Master/texmf-dist/doc/latex/getmap/osmimage.png b/Master/texmf-dist/doc/latex/getmap/osmimage.png Binary files differnew file mode 100644 index 00000000000..3d53439cb61 --- /dev/null +++ b/Master/texmf-dist/doc/latex/getmap/osmimage.png diff --git a/Master/texmf-dist/scripts/getmap/osmimage b/Master/texmf-dist/scripts/getmap/osmimage new file mode 100644 index 00000000000..82ddf3da8da --- /dev/null +++ b/Master/texmf-dist/scripts/getmap/osmimage @@ -0,0 +1,224 @@ +#!/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 new file mode 100644 index 00000000000..55220ed5219 --- /dev/null +++ b/Master/texmf-dist/scripts/getmap/osmimage.lua @@ -0,0 +1,261 @@ +#!/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.sty b/Master/texmf-dist/tex/latex/getmap/getmap.sty new file mode 100644 index 00000000000..fd25b08c1d8 --- /dev/null +++ b/Master/texmf-dist/tex/latex/getmap/getmap.sty @@ -0,0 +1,167 @@ +%% +%% This is file `getmap.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% getmap.dtx (with options: `package') +%% +%% 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. +%% +\NeedsTeXFormat{LaTeX2e}% +\ProvidesPackage{getmap}[2014/06/24 v1.1 getmap.sty - Josef Kleber (C) 2014]% +\RequirePackage{xkeyval}% +\RequirePackage{stringenc}% +\RequirePackage{ifthen}% +\newcommand*\GM@JK@define@key[4]% +{% + \expandafter\gdef\csname#1@#3\endcsname{#4}% + \define@key{#2.sty}{#3}[#4]% + {% + \expandafter\gdef\csname#1@#3\endcsname{##1}% + }% + \define@key{#2}{#3}% + {% + \expandafter\def\csname#1@#3\endcsname{##1}% + }% +}% +\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}{ysize}{400}% +\GM@JK@define@key{GM@JK}{getmap}{scale}{3385}% +\GM@JK@define@key{GM@JK}{getmap}{zoom}{}% +\GM@JK@define@key{GM@JK}{getmap}{type}{map}% +\GM@JK@define@key{GM@JK}{getmap}{imagetype}{png}% +\GM@JK@define@key{GM@JK}{getmap}{color}{yellow_1}% +\GM@JK@define@key{GM@JK}{getmap}{number}{1}% +\GM@JK@define@key{GM@JK}{getmap}{file}{osmimage}% +\GM@JK@define@key{GM@JK}{getmap}{inputencoding}{}% +\GM@JK@define@key{GM@JK}{getmap}{overwrite}{true}% +\gdef\GM@JK@overwrite{false}% +\@ifpackageloaded{inputenc}% +{% + \gdef\GM@JK@inputencoding{\inputencodingname}% +}% +{% + \gdef\GM@JK@inputencoding{utf8}% +}% +\newif\ifGM@JK@writexviii\GM@JK@writexviiifalse% +\ExecuteOptionsX{key,xsize,ysize,scale,zoom,type,imagetype,color,number,file}% +\ProcessOptionsX\relax% +\ltx@IfUndefined{pdf@shellescape}% +{% + \PackageInfo{getmap}{\pdf@shellescape is undefined}% + \PackageInfo{getmap}{can not test if \write18 is available}% + \GM@JK@writexviiitrue% +}% +{% + \PackageInfo{getmap}{\pdf@shellescape is available}% + \ifnum\pdf@shellescape=1\relax% + \PackageInfo{getmap}{\write18 enabled}% + \GM@JK@writexviiitrue% + \else% + \GM@JK@writexviiifalse% + \fi% +}% +\newcommand*\GM@JK@shellescape% +{% + \ifGM@JK@writexviii% + \ifthenelse{\equal{\GM@JK@zoom}{}}% + {% + \immediate\write18{osmimage \space-l\space "\GM@JK@location@string"% + \space-k\space "\GM@JK@key@string"% + \space-x\space \GM@JK@xsize% + \space-y\space \GM@JK@ysize% + \space-s\space \GM@JK@scale% + \space-t\space \GM@JK@type% + \space-i\space \GM@JK@imagetype% + \space-c\space "\GM@JK@color"% + \space-n\space \GM@JK@number% + \space-o\space \GM@JK@file}% + }% + {% + \immediate\write18{osmimage \space-l\space "\GM@JK@location@string"% + \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-t\space \GM@JK@type% + \space-i\space \GM@JK@imagetype% + \space-c\space "\GM@JK@color"% + \space-n\space \GM@JK@number% + \space-o\space \GM@JK@file}% + }% + \else% + \PackageError{getmap}{\write18 disabled} + {\write18 disabled\MessageBreak% + Use -shell-escape (TeXLive)\MessageBreak% + or\space\space--enable-write18 (MiKTeX)}% + \fi% +}% +\newcommand*\getmap[2][]% +{% + \begingroup% + \setkeys{getmap}{#1}% + \PackageInfo{getmap}{using \GM@JK@inputencoding\space encoding}% + \def\GM@JK@location{#2}% + \StringEncodingConvert% + {\GM@JK@location@string}% + {\detokenize\expandafter{\GM@JK@location}}% + {\GM@JK@inputencoding}{utf-8}% + \StringEncodingSuccessFailure% + {% + %success + }% + {% failure + \errmessage{Converting to UTF-8 failed}% + }% + \StringEncodingConvert% + {\GM@JK@key@string}% + {\detokenize\expandafter{\GM@JK@key}}% + {\GM@JK@inputencoding}{utf-8}% + \StringEncodingSuccessFailure% + {% + %success + }% + {% failure + \errmessage{Converting to UTF-8 failed}% + }% + \ifthenelse{\equal{\GM@JK@overwrite}{true}}% + {% + \GM@JK@shellescape% + }% + {% + \IfFileExists{\GM@JK@file.\GM@JK@imagetype}% + {% + \PackageInfo{getmap}{overwrite=false; (\GM@JK@file.\GM@JK@imagetype)% + using existing file!}% + }% + {% + \PackageInfo{getmap}{overwrite=false; (\GM@JK@file.\GM@JK@imagetype)% + file does not exist! downloading ...}% + \GM@JK@shellescape% + }% + }% + \endgroup% +}% +\endinput +%% +%% End of file `getmap.sty'. diff --git a/Master/tlpkg/libexec/ctan2tds b/Master/tlpkg/libexec/ctan2tds index a76718ed358..d3a8185c220 100755 --- a/Master/tlpkg/libexec/ctan2tds +++ b/Master/tlpkg/libexec/ctan2tds @@ -2493,6 +2493,7 @@ $standardxmt='\.xmt'; 'findhyph' => 'findhyph$', 'fragmaster' => 'fragmaster\.pl$', 'fontools' => '(afm2afm|autoinst|ot2kpx)$', + 'getmap', => 'osmimage.lua', 'installfont' => 'installfont-tl', 'kotex-utils' => '\.pl', 'latex-git-log' => 'latex-git-log$', @@ -3284,7 +3285,7 @@ sub doscripts { # # We need to change this to match texmf_dist_shell_scripts in # linked_scripts/Makefile.am. - next if $s =~ /dtx(file)?gen|ltxfileinfo/; + next if $s =~ /dtx(file)?gen|latexfileversion|ltxfileinfo|osmimage$/; # if ($s eq "lua2dox_filter") { # handwritten .bat &SYSTEM ("$MV $s.bat $platdir/"); diff --git a/Master/tlpkg/tlpsrc/collection-pictures.tlpsrc b/Master/tlpkg/tlpsrc/collection-pictures.tlpsrc index f760c4fff44..e10730b60e5 100644 --- a/Master/tlpkg/tlpsrc/collection-pictures.tlpsrc +++ b/Master/tlpkg/tlpsrc/collection-pictures.tlpsrc @@ -38,6 +38,7 @@ depend fast-diagram depend fig4latex depend flowchart depend forest +depend getmap depend gincltex depend gnuplottex depend gradientframe diff --git a/Master/tlpkg/tlpsrc/getmap.tlpsrc b/Master/tlpkg/tlpsrc/getmap.tlpsrc new file mode 100644 index 00000000000..dfe3618f9cd --- /dev/null +++ b/Master/tlpkg/tlpsrc/getmap.tlpsrc @@ -0,0 +1 @@ +binpattern f bin/${ARCH}/osmimage |