Update documentation - increase Doxygen usage
[geeqie.git] / scripts / zonedetect / create_timezone_database.sh
1 #! /bin/sh
2
3 ## @file
4 ## @brief  This script will generate the timezone database file used to
5 ## correct exif time and date for UTC offset and Daylight Saving Time.
6 ##
7 ## The Preferences/General tab of Geeqie gives the user the option to
8 ## download the database from a defined location on geeqie.org.
9 ##
10 ## If the generated file differs from that on geeqie.org you should
11 ## upload the new version. You will need write privileges to do this.
12 ##
13 ## Refer to https://github.com/BertoldVdb/ZoneDetect for the
14 ## origin of files builder.cpp and zoneToAlpha.h
15 ##
16
17 timezone_boundary_builder_default_release="2019a"
18
19 cd "$(dirname "$0")"
20 current_dir=$PWD
21
22 xdg-open https://github.com/evansiroky/timezone-boundary-builder/releases/
23
24 if [ -f timezone_boundary_builder_release.txt ]
25 then
26         timezone_boundary_builder_release=$(cat timezone_boundary_builder_release.txt)
27 else
28         timezone_boundary_builder_release=$timezone_boundary_builder_default_release
29 fi
30
31 timezone_boundary_builder_release=$(zenity --entry --entry-text="$timezone_boundary_builder_release" --title "Geeqie generate timezone database" --text="Which timezone boundary builder\nrelease should be used?\n" --width=350 --window-icon="$current_dir/../../geeqie.png")
32
33 if [ -n "$timezone_boundary_builder_release" ]
34 then
35         echo "$timezone_boundary_builder_release" > "timezone_boundary_builder_release.txt"
36 else
37         exit
38 fi
39
40 rm -rf naturalearth
41 rm -rf timezone
42 rm -rf geeqie_org
43 rm -f timezone21.bin
44
45 g++ builder.cpp -o builder -lshp
46
47 mkdir naturalearth
48 cd naturalearth
49 wget https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_admin_0_countries_lakes.zip
50 if [ "$?" -ne 0 ]
51 then
52         zenity --error --text="Download of naturalearthdata failed" --title="Generate Geeqie timezone database" --width=300 --window-icon="$current_dir/../../geeqie.png"
53         exit
54 fi
55
56 unzip ne_10m_admin_0_countries_lakes.zip
57 cd ..
58
59 mkdir timezone
60 cd timezone
61 wget "https://github.com/evansiroky/timezone-boundary-builder/releases/download/$timezone_boundary_builder_release/timezones.shapefile.zip"
62 if [ "$?" -ne 0 ]
63 then
64         zenity --error --text="Download of timezone-boundary-builder failed" --title="Generate Geeqie timezone database" --width=300 --window-icon="$current_dir/../../geeqie.png"
65         exit
66 fi
67
68 unzip timezones.shapefile.zip
69 cd ..
70
71
72 ./builder T timezone/dist/combined-shapefile timezone21.bin 21 "Contains data from Natural Earth, placed in the Public Domain. Contains information from https://github.com/evansiroky/timezone-boundary-builder, which is made available here under the Open Database License (ODbL)."
73
74 mkdir geeqie_org
75 cd geeqie_org
76 wget http://www.geeqie.org/downloads/timezone21.bin
77 if [ "$?" -ne 0 ]
78 then
79         zenity --error --text="Download of timezone database from geeqie.org failed" --title="Generate Geeqie timezone database" --width=300 --window-icon="$current_dir/../../geeqie.png"
80         exit
81 fi
82 cd ..
83
84 diff ./geeqie_org/timezone21.bin timezone21.bin
85
86 if [ "$?" -ne 0 ]
87 then
88         zenity --info --title="Generate Geeqie timezone database" --text="Generated file differs from that on geeqie.org\n\nUpload timezone21.bin to:\ngeeqie.org/downloads/" --width=300 --window-icon="$current_dir/../../geeqie.png"
89 else
90         zenity --info --title="Generate Geeqie timezone database" --text="Generated file is the same as on geeqie.org" --width=300 --window-icon="$current_dir/../../geeqie.png"
91         rm timezone21.bin
92 fi
93
94 rm -f builder
95 rm -rf naturalearth
96 rm -rf timezone
97 rm -rf geeqie_org