]> git.openstreetmap.org Git - nominatim.git/blob - utils/check_import_finished.php
new script utils/check_import_finished.php
[nominatim.git] / utils / check_import_finished.php
1 <?php
2
3 require_once(CONST_BasePath.'/lib/init-cmd.php');
4
5 $term_colors = array(
6                 'green' => "\033[92m",
7                 'red' => "\x1B[31m",
8                 'normal' => "\033[0m"
9 );
10
11 $print_success = function ($message = 'OK') use ($term_colors) {
12     echo $term_colors['green'].$message.$term_colors['normal']."\n";
13 };
14
15 $print_fail = function ($message = 'Failed') use ($term_colors) {
16     echo $term_colors['red'].$message.$term_colors['normal']."\n";
17 };
18
19
20 $oDB = new Nominatim\DB;
21
22
23 echo 'Checking database got created ... ';
24 if ($oDB->databaseExists()) {
25     $print_success();
26 } else {
27     $print_fail();
28     echo <<< END
29     Hints:
30     * Is the database server started?
31     * Check the CONST_Database_DSN variable in build/settings/local.php
32     * Try connecting to the database with the same settings
33
34 END;
35     exit(1);
36 }
37
38
39 echo 'Checking nominatim.so module installed ... ';
40 $sStandardWord = $oDB->getOne("SELECT make_standard_name('a')");
41 if ($sStandardWord === 'a') {
42     $print_success();
43 } else {
44     $print_fail();
45     echo <<< END
46     The Postgresql extension nominatim.so was not found in the database.
47     Hints:
48     * Check the output of the CMmake/make installation step
49     * Does nominatim.so exist?
50     * Does nominatim.so exist on the database server?
51     * Can nominatim.so be accessed by the database user?
52
53 END;
54     exit(1);
55 }
56
57 echo 'Checking place table ... ';
58 if ($oDB->tableExists('place')) {
59     $print_success();
60 } else {
61     $print_fail();
62     echo <<< END
63     * The import didn't finish.
64     Hints:
65     * Check the output of the utils/setup.php you ran.
66     Usually the osm2pgsql step failed. Check for errors related to
67     * the file you imported not containing any places
68     * harddrive full
69     * out of memory (RAM)
70     * osm2pgsql killed by other scripts, for consuming to much memory
71
72 END;
73     exit(1);
74 }
75
76
77
78 echo 'Checking indexing status ... ';
79 $iUnindexed = $oDB->getOne('SELECT count(*) FROM placex WHERE indexed_status > 0');
80 if ($iUnindexed == 0) {
81     $print_success();
82 } else {
83     $print_fail();
84     echo <<< END
85     The indexing didn't finish. There is still $iUnindexed places. See the
86     question 'Can a stopped/killed import process be resumed?' in the
87     troubleshooting guide.
88
89 END;
90     exit(1);
91 }
92
93 echo "Search index creation\n";
94 $aExpectedIndices = array(
95     // sql/indices.src.sql
96     'idx_word_word_id',
97     'idx_place_addressline_address_place_id',
98     'idx_placex_rank_search',
99     'idx_placex_rank_address',
100     'idx_placex_pendingsector',
101     'idx_placex_parent_place_id',
102     'idx_placex_geometry_reverse_lookuppoint',
103     'idx_placex_geometry_reverse_lookuppolygon',
104     'idx_placex_geometry_reverse_placenode',
105     'idx_location_area_country_place_id',
106     'idx_osmline_parent_place_id',
107     'idx_osmline_parent_osm_id',
108     'idx_place_osm_unique',
109     'idx_postcode_id',
110     'idx_postcode_postcode',
111
112     // sql/indices_search.src.sql
113     'idx_search_name_nameaddress_vector',
114     'idx_search_name_name_vector',
115     'idx_search_name_centroid'
116 );
117
118 foreach ($aExpectedIndices as $sExpectedIndex) {
119     echo "Checking index $sExpectedIndex ... ";
120     if ($oDB->indexExists($sExpectedIndex)) {
121         $print_success();
122     } else {
123         $print_fail();
124         echo <<< END
125         Hints:
126         * Rerun the setup.php --create-search-indices step
127
128 END;
129         exit(1);
130     }
131 }
132
133 if (CONST_Use_US_Tiger_Data) {
134     echo 'Checking TIGER table exists ... ';
135     if ($oDB->tableExists('location_property_tiger')) {
136         $print_success();
137     } else {
138         $print_fail();
139         echo <<< END
140         Table 'location_property_tiger' does not exist. Run the TIGER data
141         import again.
142
143 END;
144         exit(1);
145     }
146 }
147
148
149
150
151 exit(0);