From f17bf1ebb0a23206bc37de93dfd49c7b254b6705 Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Sat, 25 Apr 2020 16:43:55 +0200 Subject: [PATCH] Remove necessity for php tile resolution script The conversion script now generates a proper directory structure with z/y/x coords in the path. --- htdocs/mapscript.js | 2 +- htdocs/tiles/index.php | 14 -------------- scripts/convert_maps.sh | 15 ++++++++++++++- 3 files changed, 15 insertions(+), 16 deletions(-) delete mode 100644 htdocs/tiles/index.php diff --git a/htdocs/mapscript.js b/htdocs/mapscript.js index d83b057..abe85a6 100644 --- a/htdocs/mapscript.js +++ b/htdocs/mapscript.js @@ -132,7 +132,7 @@ function load_svg(name, url, active=1) { } function load_tiles(name, id) { - var satellite = L.tileLayer('https://notsyncing.net/maps.linux-forks.de/tiles/?id={id}&z={z}&x={x}&y={y}', { + var satellite = L.tileLayer('https://notsyncing.net/maps.linux-forks.de/tiles/{id}/{z}/{y}/{x}.png', { maxZoom: 14 /*8*/, maxNativeZoom: 6, minNativeZoom: 0, diff --git a/htdocs/tiles/index.php b/htdocs/tiles/index.php deleted file mode 100644 index 7e0a89b..0000000 --- a/htdocs/tiles/index.php +++ /dev/null @@ -1,14 +0,0 @@ - 30) die(); - - $hdr = "Location: /maps.linux-forks.de/tiles/$id/$z/" . str_pad($y * (2**$z) + $x, 5, "0", STR_PAD_LEFT) . ".png"; - if (isset($_GET["debug"])) { - echo $hdr; - } else { - header($hdr); - } -?> diff --git a/scripts/convert_maps.sh b/scripts/convert_maps.sh index 32ef029..faeea22 100755 --- a/scripts/convert_maps.sh +++ b/scripts/convert_maps.sh @@ -41,7 +41,7 @@ while true; do fi echo " Generating tiles..." - convert $tempfile -crop ${TILESIZE}x${TILESIZE} +adjoin $out/%05d.png + convert $tempfile -crop ${TILESIZE}x${TILESIZE} +adjoin $out/%d.png rm $tempfile @@ -51,3 +51,16 @@ while true; do crop=$(($crop * 2)) zoom=$(($zoom + 1)) done; + +echo "Renaming files..." +for (( z=0; z<=$zoom; z++ )) { + echo "Zoom level $z" + fac=$((2**$z)) + for (( y=0; y<$fac; y++ )) { + outdir="$MAPNAME/$z/$y" + mkdir $outdir + for (( x=0; x<$fac; x++ )) { + mv $MAPNAME/$z/$(($fac * y + $x)).png $outdir/$x.png + } + } +}