-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathzxyfiles
61 lines (54 loc) · 1.64 KB
/
zxyfiles
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env bash
PROGRAM_NAME=$(basename "$0")
function usage {
echo "Generate list of tiles per zoomlevel (only EPSG:28992)"
echo "usage: $PROGRAM_NAME <z>"
echo " - <z>: zoomlevel"
exit 1
}
if test "$#" -lt 1; then
usage
fi
set -eu
Z="$1"
RESOLUTIONS_RD_0=3440.640
EXTENT_RD=-285401.920,22598.080,595401.920,903401.920
TILESIZE_PIXELS=256
function get_resolution_for_z(){
local z resolution resolution_z
z="$1"
resolution=$RESOLUTIONS_RD_0
resolution_z=$(echo "$resolution*(2^-$z)" | bc -l)
echo "$resolution_z"
}
function get_files_for_z(){
local resolution_z z x y origin_x origin_y
z="$1"
resolution_z=$(get_resolution_for_z "$z")
x=0
while true;do
y=0
while true; do
echo "${z}/${x}/${y}.pbf"
y=$((y+1))
# check if y coord is still within proj extent based on y
height=$(echo "$TILESIZE_PIXELS*$y*$resolution_z" | bc -l)
origin_y=$(echo $EXTENT_RD | cut -d "," -f4)
end_y=$(echo $EXTENT_RD | cut -d "," -f2)
current_y=$(echo "$origin_y-$height" | bc -l)
if (( $(echo "$current_y < $end_y" |bc -l) ));then
break
fi
done
x=$((x+1))
# check if x coord is still within proj extent based on x
width=$(echo "$TILESIZE_PIXELS*$x*$resolution_z" | bc -l)
origin_x=$(echo $EXTENT_RD | cut -d "," -f1)
end_x=$(echo $EXTENT_RD | cut -d "," -f3)
current_x=$(echo "$width+$origin_x" | bc -l)
if (( $(echo "$current_x > $end_x" |bc -l) ));then
break
fi
done
}
get_files_for_z "$Z"