aboutsummaryrefslogtreecommitdiffstats
path: root/osm/main.sh
blob: 07e2725e28c6113bcb7e50d2456fbc1b2b14e16a (plain)
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
#!/bin/bash
#set -x

#configuration
config_file=/home/osm/convert/scripts/config.cfg

# source a specified section from config
function source_section {
   section_name="$1"
   section_start="^\[$section_name\]$"
   section_end="^\[/$section_name\]$"

   line_start=$(grep -n "$section_start" "$config_file" | cut -d: -f1)
   line_end=$(expr $(grep -n "$section_end" "$config_file" | cut -d: -f1) - 1)
   line_diff=$(expr $line_end - $line_start)

   tmpfile=$(mktemp)
   head -n $line_end "$config_file" | tail -n $line_diff > "$tmpfile"
   source "$tmpfile"
   rm -f "$tmpfile"
}

# general section from config
source_section "general"

export osmosis_executable dir_maps dir_output dir_stage dir_poly filetype_osm filetype_map filetype_poly wget_limit_rate

params_for_xarg_call=""

#loop over the maps we want to generate
for act_country in $maps_to_generate
do
   # reset defaults
   wm_type="$default_type"
   start_zoom="$default_start_zoom"
   language="$default_language"
   use_poly="$default_use_poly"

   source_section "$act_country"

   if [ "X$output_subdir" == "X" ]
   then
      output_subdir="."
   fi

   params_for_xarg_call="$params_for_xarg_call \"$download_base_url/$download_map_path/$download_map_file.$filetype_osm\" \"$download_base_url/$download_poly_path/$download_poly_file.$filetype_poly\" \"$act_country.$filetype_map\" \"$wm_type\" \"$start_zoom\" \"$language\" \"$use_poly\" \"$output_subdir\""
done

#echo "$params_for_xarg_call" | xargs -n 8 -P $threads_to_start echo
echo "$params_for_xarg_call" | xargs -n 8 -P $threads_to_start $download_and_convert_script