diff options
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | htdocs/index.html | 4 | ||||
-rw-r--r-- | htdocs/tiles/index.php | 3 | ||||
-rwxr-xr-x | scripts/convert_maps.1.sh | 64 | ||||
-rwxr-xr-x | scripts/getassets.sh | 3 |
5 files changed, 72 insertions, 6 deletions
@@ -1 +1,3 @@ -htdocs/tiles/**/ +htdocs/tiles/ +htdocs/geojson/ +htdocs/fa/ diff --git a/htdocs/index.html b/htdocs/index.html index 2d77687..acc5254 100644 --- a/htdocs/index.html +++ b/htdocs/index.html @@ -5,10 +5,10 @@ <meta charset="utf-8"/> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="fa/css/all.css"> - <link rel="stylesheet" href="awesomemarkers/leaflet.awesome-markers.css"> + <link rel="stylesheet" href="https://unpkg.com/leaflet.awesome-markers@2.0.5/dist/leaflet.awesome-markers.css" integrity="sha512-boUmbsf2HYx73lupnu+hMGOCttEtpt6FWQDcpHFmTIsY+lXPiP3iefbxrAvCNa6bt5TbdoO3zza2a2kxAm8HTg==" crossorigin=""> <link rel="stylesheet" href="https://unpkg.com/leaflet@1.6.0/dist/leaflet.css" integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ==" crossorigin=""/> <script src="https://unpkg.com/leaflet@1.6.0/dist/leaflet.js" integrity="sha512-gZwIG9x3wUXg2hdXF6+rVkLF/0Vi9U8D2Ntg4Ga5I5BZpVkVxlJWbSQtXPSiUTtC0TjtGOmxa1AJPuV0CPthew==" crossorigin=""></script> - <script src="awesomemarkers/leaflet.awesome-markers.js"></script> + <script src="https://unpkg.com/leaflet.awesome-markers@2.0.5/dist/leaflet.awesome-markers.js" integrity="sha512-Oj9plGLST4IMXFXDfqMdTP+gSInbodkyno117PSjo5R08eu6TdzY9WPnnwQZGx2O2lG/kN0MzQk95ulWsRFuLA==" crossorigin=""></script> <!-- Streets --> <script src='leafletjs/ctxtextpath.js'></script> <script src='leafletjs/L.LabelTextCollision.js'></script> diff --git a/htdocs/tiles/index.php b/htdocs/tiles/index.php deleted file mode 100644 index 62a2de0..0000000 --- a/htdocs/tiles/index.php +++ /dev/null @@ -1,3 +0,0 @@ -<?php - -?> diff --git a/scripts/convert_maps.1.sh b/scripts/convert_maps.1.sh new file mode 100755 index 0000000..0c78c8f --- /dev/null +++ b/scripts/convert_maps.1.sh @@ -0,0 +1,64 @@ +#!/bin/bash +# Convert a huge .png file into smaller chunks for LeafletJS. +# +# Copyright (C) 2020 Y. Wang <ywang@forksworld.de> +# Copyright (C) 2020 Markus Koch <markus@notsyncing.net> +# +# This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. +# You can obtain a copy of the license at https://mozilla.org/MPL/2.0/. + +TILESIZE=256 +MAPFILE="$1" +MAPNAME="${1/.png/}" + +width=`file "$MAPFILE" | sed -n "s/.* \([0-9]\+\) x \([0-9]\+\).*/\1/p"` +crop=$TILESIZE +zoom=0 + +# Enabled because my VPS +IMFLAGS="-limit area 0" +#IMFLAGS="" + +echo -n "Getting highest zoomlevel... "; +while [ $crop -lt $width ]; do + crop=$(($crop * 2)); + zoom=$(($zoom + 1)); +done; +echo "$zoom"; + +echo "Extending map for maptile generation..." +extended=$(mktemp) +echo " The extended map is temporarily saved to $extended." +convert $MAPFILE -extent ${crop}x${crop} png:$extended + +while [ $zoom -ge 0 ]; do + out="$MAPNAME/$zoom" + tempfile=$out/temp.png + + echo "Generating maps for zoomlevel $zoom to $out..." + + mkdir -p $out; + + echo " Scaling image..." + convert png:$extended -resize ${crop}x${crop} $tempfile + + echo " Generating tiles..." + convert $tempfile -crop ${TILESIZE}x${TILESIZE} +adjoin $out/%d.png + + rm $tempfile + + echo " Creating symlinks..." + n=$(($crop / $TILESIZE)) + for i in $(seq 0 $(($n-1))); do + rm -rf $out/$i >/dev/null 2>/dev/null # Nobody cares if this fails ... + mkdir $out/$i + for j in $(seq 0 $(($n-1))); do + ln -s ../$(($j*$n+$i)).png $out/$i/${j}.png + done + done + + crop=$(($crop / 2)) + zoom=$(($zoom - 1)) +done; + +rm $extended diff --git a/scripts/getassets.sh b/scripts/getassets.sh new file mode 100755 index 0000000..34dde08 --- /dev/null +++ b/scripts/getassets.sh @@ -0,0 +1,3 @@ +#!/bin/bash +# This script fetches all necessary files to run the map server +git clone https://github.com/FortAwesome/Font-Awesome.git --depth 1 ../htdocs/fa |