better stats for touching files
[osmrrze.git] / scripts / deleteseatiles.sh
... / ...
CommitLineData
1#!/bin/bash
2
3# Script to delete tiles that only contain water (usually in the
4# middle of an ocean) in the higher numbered zoomlevels. These
5# are trivial to regenerate (far less than one second) at any
6# time.
7
8# Some settings
9# Minimum Zoom in which we delete
10MINZ=10
11
12# Maximum Zoom in which we delete
13MAXZ=20
14
15# Age in days after which we delete
16AGE=3
17
18declare -A TMD5
19# the md5sum of a metatile containing only water?
20TMD5[osmde]="c6501cefd852a2c5b16f297948ca309c"
21TMD5[osmorg]="9d7ceeb7ab3a0905abf200f1a7608f92"
22TMD5[osmhd]="d47bd18df80dbefb2f89b81a672cae92"
23
24declare -A TSIZE
25# the size of a metatile containing only water?
26TSIZE[osmde]=7124
27TSIZE[osmorg]=7124
28TSIZE[osmhd]=8596
29
30declare -A TDIR
31# Directory that contains the tiles? (with trailing slash!)
32TDIR[osmde]="/mnt/tiles/tiles/osmde/"
33TDIR[osmorg]="/mnt/tiles/tiles/osm/"
34TDIR[osmhd]="/mnt/tiles/tiles/osmhd/"
35
36NDELETED=0
37for style in "osmde" "osmorg" "osmhd"
38do
39 echo "Handling style: $style - looking for files with size ${TSIZE[$style]} and md5sum ${TMD5[$style]} in ${TDIR[$style]}"
40 for z in `seq $MINZ $MAXZ`
41 do
42 if [ ! -d "${TDIR[$style]}${z}" ] ; then
43 continue
44 fi
45 for tiles in `find ${TDIR[$style]}${z} -xdev -type f -name '*.meta' -size ${TSIZE[$style]}c -mtime +${AGE} -print`
46 do
47 # We need to skip the first 20 bytes of the file as they contain the metafile
48 # header that contains the x/y location of the tile.
49 TILEMD5=`tail -c +20 $tiles | md5sum -b | sed -e 's/ .*//g'`
50 if [ "$TILEMD5" == "${TMD5[$style]}" ] ; then
51 echo "Deleting $tiles"
52 rm $tiles
53 if [ $? -ne 0 ] ; then
54 echo "There was an error deleting $tiles."
55 echo "Aborting after deleting $NDELETED files."
56 exit 1
57 fi
58 let "NDELETED=NDELETED+1"
59 #else
60 # echo "$tiles is not a water tile."
61 fi
62 done
63 done
64done
65
66echo "$NDELETED files deleted."
67
This page took 0.116235 seconds and 4 git commands to generate.