]> git.openstreetmap.org Git - nominatim.git/blob - lib/setup_functions.php
increase weight for country tokens
[nominatim.git] / lib / setup_functions.php
1 <?php
2
3 function checkInFile($sOSMFile)
4 {
5     if (!isset($sOSMFile)) {
6         fail('missing --osm-file for data import');
7     }
8
9     if (!file_exists($sOSMFile)) {
10         fail('the path supplied to --osm-file does not exist');
11     }
12
13     if (!is_readable($sOSMFile)) {
14         fail('osm-file "' . $aCMDResult['osm-file'] . '" not readable');
15     }
16 }
17
18 function checkModulePresence()
19 {
20     // Try accessing the C module, so we know early if something is wrong.
21     // Raises Nominatim\DatabaseError on failure
22
23     $sModulePath = CONST_Database_Module_Path;
24     $sSQL = "CREATE FUNCTION nominatim_test_import_func(text) RETURNS text AS '";
25     $sSQL .= $sModulePath . "/nominatim.so', 'transliteration' LANGUAGE c IMMUTABLE STRICT";
26     $sSQL .= ';DROP FUNCTION nominatim_test_import_func(text);';
27
28     $oDB = new \Nominatim\DB();
29     $oDB->connect();
30     $oDB->exec($sSQL, null, 'Database server failed to load '.$sModulePath.'/nominatim.so module');
31 }