diff options
author | ywang <yw05@forksworld.de> | 2020-06-07 14:22:19 +0200 |
---|---|---|
committer | ywang <yw05@forksworld.de> | 2020-06-07 14:22:19 +0200 |
commit | 8eb50eddb9733b01f19d19a2bbb68bac9d64c8d4 (patch) | |
tree | fe643164c033480b804727819cd38738ca2957b6 /scripts | |
parent | be16cf2f6e4548d3ba6f0554202c921b0c90b5a5 (diff) | |
download | lifomapserver-8eb50eddb9733b01f19d19a2bbb68bac9d64c8d4.tar.gz lifomapserver-8eb50eddb9733b01f19d19a2bbb68bac9d64c8d4.tar.bz2 lifomapserver-8eb50eddb9733b01f19d19a2bbb68bac9d64c8d4.zip |
Use unpkg when possible; update map tile generatorywang-patch
- Moved most sources to unpkg.
- Add scripts/getassets to fetch files that need to be hosted locally.
- Added a new map tile generator that uses symlinks instead of PHP.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/convert_maps.1.sh | 64 | ||||
-rwxr-xr-x | scripts/getassets.sh | 3 |
2 files changed, 67 insertions, 0 deletions
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 |