From 58ded3c00a780a49c9e7f0f3d9e66e2619a03056 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Wed, 16 Jul 2014 22:37:21 +0000 Subject: getmap (16jul14) git-svn-id: svn://tug.org/texlive/trunk@34634 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/scripts/getmap/getmapdl.lua | 381 ++++++++++++++++++++++++++ Master/texmf-dist/scripts/getmap/osmimage | 224 --------------- Master/texmf-dist/scripts/getmap/osmimage.lua | 261 ------------------ 3 files changed, 381 insertions(+), 485 deletions(-) create mode 100644 Master/texmf-dist/scripts/getmap/getmapdl.lua delete mode 100644 Master/texmf-dist/scripts/getmap/osmimage delete mode 100755 Master/texmf-dist/scripts/getmap/osmimage.lua (limited to 'Master/texmf-dist/scripts/getmap') 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 - -- cgit v1.2.3