From cc9b12f07d2758e066868f4cb313003167e09464 Mon Sep 17 00:00:00 2001 From: User for running Openstreetmap-things Date: Fri, 12 Sep 2014 13:42:29 +0200 Subject: [PATCH] einfaches script um sea-tiles (also tiles die nur "blau" sind weil sie komplett im Meer liegen) zu loeschen. Die koennen in Sekundenbruchteilen neu gerendert werden falls sie angefragt werden. --- scripts/deleteseatiles.sh | 82 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100755 scripts/deleteseatiles.sh diff --git a/scripts/deleteseatiles.sh b/scripts/deleteseatiles.sh new file mode 100755 index 0000000..d7eada6 --- /dev/null +++ b/scripts/deleteseatiles.sh @@ -0,0 +1,82 @@ +#!/bin/bash + +# Script to delete tiles that only contain water (usually in the +# middle of an ocean) in the higher numbered zoomlevels. These +# are trivial to regenerate (far less than one second) at any +# time. + +# Some settings +# Minimum Zoom in which we delete +MINZ=11 + +# Maximum Zoom in which we delete +MAXZ=20 + +# Age in days after which we delete +AGE=3 + +# the md5sum of a metatile containing only water? +MD5OSMDE="c6501cefd852a2c5b16f297948ca309c" +MD5OSMORG="9d7ceeb7ab3a0905abf200f1a7608f92" + +# the size of a metatile containing only water? +SIZEOSMDE=7124 +SIZEOSMORG=7124 + +# Directory that contains the tiles? (with trailing slash!) +OSMDEDIR="/mnt/tiles/tiles/osmde/" +OSMORGDIR="/mnt/tiles/tiles/osm/" + +NDELETED=0 +for z in `seq $MINZ $MAXZ` +do + if [ ! -d "${OSMDEDIR}${z}" ] ; then + continue + fi + for tiles in `find ${OSMDEDIR}${z} -xdev -type f -name '*.meta' -size ${SIZEOSMDE}c -mtime +${AGE} -print` + do + # We need to skip the first 20 bytes of the file as they contain the metafile + # header that contains the x/y location of the tile. + TILEMD5=`tail -c +20 $tiles | md5sum -b | sed -e 's/ .*//g'` + if [ "$TILEMD5" == "$MD5OSMDE" ] ; then + echo "Deleting $tiles" + rm $tiles + if [ $? -ne 0 ] ; then + echo "There was an error deleting $tiles." + echo "Aborting after deleting $NDELETED files." + exit 1 + fi + let "NDELETED=NDELETED+1" + #else + # echo "$tiles is not a water tile." + fi + done +done + +for z in `seq $MINZ $MAXZ` +do + if [ ! -d "${OSMORGDIR}${z}" ] ; then + continue + fi + for tiles in `find ${OSMORGDIR}${z} -xdev -type f -name '*.meta' -size ${SIZEOSMORG}c -mtime +${AGE} -print` + do + # We need to skip the first 20 bytes of the file as they contain the metafile + # header that contains the x/y location of the tile. + TILEMD5=`tail -c +20 $tiles | md5sum -b | sed -e 's/ .*//g'` + if [ "$TILEMD5" == "$MD5OSMORG" ] ; then + echo "Deleting $tiles" + #rm $tiles + if [ $? -ne 0 ] ; then + echo "There was an error deleting $tiles." + echo "Aborting after deleting $NDELETED files." + exit 1 + fi + let "NDELETED=NDELETED+1" + #else + # echo "$tiles is not a water tile." + fi + done +done + +echo "$NDELETED files deleted." + -- 2.25.1