Commit | Line | Data |
---|---|---|
cc9b12f0 UO |
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 | |
10 | MINZ=11 | |
11 | ||
12 | # Maximum Zoom in which we delete | |
13 | MAXZ=20 | |
14 | ||
15 | # Age in days after which we delete | |
16 | AGE=3 | |
17 | ||
18 | # the md5sum of a metatile containing only water? | |
19 | MD5OSMDE="c6501cefd852a2c5b16f297948ca309c" | |
20 | MD5OSMORG="9d7ceeb7ab3a0905abf200f1a7608f92" | |
21 | ||
22 | # the size of a metatile containing only water? | |
23 | SIZEOSMDE=7124 | |
24 | SIZEOSMORG=7124 | |
25 | ||
26 | # Directory that contains the tiles? (with trailing slash!) | |
27 | OSMDEDIR="/mnt/tiles/tiles/osmde/" | |
28 | OSMORGDIR="/mnt/tiles/tiles/osm/" | |
29 | ||
30 | NDELETED=0 | |
31 | for z in `seq $MINZ $MAXZ` | |
32 | do | |
33 | if [ ! -d "${OSMDEDIR}${z}" ] ; then | |
34 | continue | |
35 | fi | |
36 | for tiles in `find ${OSMDEDIR}${z} -xdev -type f -name '*.meta' -size ${SIZEOSMDE}c -mtime +${AGE} -print` | |
37 | do | |
38 | # We need to skip the first 20 bytes of the file as they contain the metafile | |
39 | # header that contains the x/y location of the tile. | |
40 | TILEMD5=`tail -c +20 $tiles | md5sum -b | sed -e 's/ .*//g'` | |
41 | if [ "$TILEMD5" == "$MD5OSMDE" ] ; then | |
42 | echo "Deleting $tiles" | |
43 | rm $tiles | |
44 | if [ $? -ne 0 ] ; then | |
45 | echo "There was an error deleting $tiles." | |
46 | echo "Aborting after deleting $NDELETED files." | |
47 | exit 1 | |
48 | fi | |
49 | let "NDELETED=NDELETED+1" | |
50 | #else | |
51 | # echo "$tiles is not a water tile." | |
52 | fi | |
53 | done | |
54 | done | |
55 | ||
56 | for z in `seq $MINZ $MAXZ` | |
57 | do | |
58 | if [ ! -d "${OSMORGDIR}${z}" ] ; then | |
59 | continue | |
60 | fi | |
61 | for tiles in `find ${OSMORGDIR}${z} -xdev -type f -name '*.meta' -size ${SIZEOSMORG}c -mtime +${AGE} -print` | |
62 | do | |
63 | # We need to skip the first 20 bytes of the file as they contain the metafile | |
64 | # header that contains the x/y location of the tile. | |
65 | TILEMD5=`tail -c +20 $tiles | md5sum -b | sed -e 's/ .*//g'` | |
66 | if [ "$TILEMD5" == "$MD5OSMORG" ] ; then | |
67 | echo "Deleting $tiles" | |
68 | #rm $tiles | |
69 | if [ $? -ne 0 ] ; then | |
70 | echo "There was an error deleting $tiles." | |
71 | echo "Aborting after deleting $NDELETED files." | |
72 | exit 1 | |
73 | fi | |
74 | let "NDELETED=NDELETED+1" | |
75 | #else | |
76 | # echo "$tiles is not a water tile." | |
77 | fi | |
78 | done | |
79 | done | |
80 | ||
81 | echo "$NDELETED files deleted." | |
82 |