3 require_once(CONST_BasePath.'/lib/init-cmd.php');
11 $print_success = function ($message = 'OK') use ($term_colors) {
12 echo $term_colors['green'].$message.$term_colors['normal']."\n";
15 $print_fail = function ($message = 'Failed') use ($term_colors) {
16 echo $term_colors['red'].$message.$term_colors['normal']."\n";
20 $oDB = new Nominatim\DB;
23 echo 'Checking database got created ... ';
24 if ($oDB->databaseExists()) {
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
39 echo 'Checking nominatim.so module installed ... ';
40 $sStandardWord = $oDB->getOne("SELECT make_standard_name('a')");
41 if ($sStandardWord === 'a') {
46 The Postgresql extension nominatim.so was not found in the database.
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?
57 echo 'Checking place table ... ';
58 if ($oDB->tableExists('place')) {
63 * The import didn't finish.
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
70 * osm2pgsql killed by other scripts, for consuming to much memory
78 echo 'Checking indexing status ... ';
79 $iUnindexed = $oDB->getOne('SELECT count(*) FROM placex WHERE indexed_status > 0');
80 if ($iUnindexed == 0) {
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.
93 echo "Search index creation\n";
94 $aExpectedIndices = array(
95 // sql/indices.src.sql
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',
110 'idx_postcode_postcode',
112 // sql/indices_search.src.sql
113 'idx_search_name_nameaddress_vector',
114 'idx_search_name_name_vector',
115 'idx_search_name_centroid'
118 foreach ($aExpectedIndices as $sExpectedIndex) {
119 echo "Checking index $sExpectedIndex ... ";
120 if ($oDB->indexExists($sExpectedIndex)) {
126 * Rerun the setup.php --create-search-indices step
133 echo 'Checking search indices are valid ... ';
136 FROM pg_class, pg_index
137 WHERE pg_index.indisvalid = false
138 AND pg_index.indexrelid = pg_class.oid;
140 $aInvalid = $oDB->getCol($sSQL);
141 if (empty($aInvalid)) {
146 At least one index is invalid. That can happen, e.g. when index creation was
147 disrupted and later restarted. You should run the index stage of setup again.
148 See the question 'Can a stopped/killed import process be resumed?' in the
149 troubleshooting guide.
152 echo join(', ', $aInvalid) . "\n";
158 if (CONST_Use_US_Tiger_Data) {
159 echo 'Checking TIGER table exists ... ';
160 if ($oDB->tableExists('location_property_tiger')) {
165 Table 'location_property_tiger' does not exist. Run the TIGER data