added gen_map to have the source complete
[osm-map-evolution.git] / gen_dated_maps
blobdb9b68cc016e4f09501a049acecc2831f6d17e56
1 #!/bin/sh
3 is_master_branch ()
5 git branch | grep '^\*' | grep -q '^\* master$' && return 0 || return 1
8 emsg ()
10 echo "E: $*" >&2
13 limit_not_reached ()
15 local method="$1"
16 local limit="$2"
17 local current="$3"
19 if [ "$method" = "count" ] ; then
20 [ "$limit" -ge "$current" ] && return 0 || return 1
23 if [ "$method" = "date" ] ; then
24 [ "$limit" != "$current" ] && return 0 || return 1
28 pad_to_10_chars ()
30 echo "0000000000$1" | sed 's#.*\(..........\)$#\1#g'
33 get_current_date ()
35 git log --pretty=oneline --max-count=1 | sed 's#^.*\([0-9]...-..-..\)$#\1#'
38 update_current ()
40 [ "$1" = "count" ] && echo "$(pad_to_10_chars $(expr $2 + 1 ))" && return 0
41 [ "$1" = "date" ] && echo "$(get_current_date)" && return 0
44 if is_master_branch ; then
45 emsg "Refusing to alter the master branch as you might loose the repo"
46 emsg "please create a waste branch with 'git checkout -b wastebranchformaps' and try again"
47 exit 3
50 [ "$#" -lt 2 ] && emsg "no limitation method was specified" && exit 1
52 if [ "$1" = "-c" ] ; then
53 [ "$#" -eq 1 ] && emsg "Parameter missing for -c option" && exit 2
54 METHOD='count'
55 LIMIT="$2"
56 CURRENT="$(pad_to_10_chars 1)"
57 elif [ "$1" = "-d" ] ; then
58 [ "$#" -eq 1 ] && emsg "Parameter missing for -d option" && exit 2
59 METHOD='date'
60 LIMIT="$2"
61 CURRENT="$(get_current_date)"
64 shift && shift
66 while limit_not_reached $METHOD $LIMIT $CURRENT ; do
67 gen_map "$CURRENT" $@
68 git reset --hard HEAD^
69 osm2pgsql -b 24.2,43.9,24.5,44.3 -d gis -m -U osm planet-rom.osm
70 CURRENT="$(update_current "$METHOD" "$CURRENT")"
71 done