2018-08-31 22:31:38 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
function checkInFile($sOSMFile)
|
|
|
|
{
|
|
|
|
if (!isset($sOSMFile)) {
|
|
|
|
fail('missing --osm-file for data import');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!file_exists($sOSMFile)) {
|
|
|
|
fail('the path supplied to --osm-file does not exist');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!is_readable($sOSMFile)) {
|
|
|
|
fail('osm-file "' . $aCMDResult['osm-file'] . '" not readable');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkModulePresence()
|
|
|
|
{
|
|
|
|
// Try accessing the C module, so we know early if something is wrong
|
|
|
|
// and can simply error out.
|
|
|
|
$sModulePath = CONST_Database_Module_Path;
|
|
|
|
$sSQL = "CREATE FUNCTION nominatim_test_import_func(text) RETURNS text AS '";
|
|
|
|
$sSQL .= $sModulePath . "/nominatim.so', 'transliteration' LANGUAGE c IMMUTABLE STRICT";
|
|
|
|
$sSQL .= ';DROP FUNCTION nominatim_test_import_func(text);';
|
|
|
|
|
2019-02-24 18:14:36 +03:00
|
|
|
$oDB = new \Nominatim\DB();
|
|
|
|
$oDB->connect();
|
2018-08-31 22:31:38 +03:00
|
|
|
|
|
|
|
$bResult = true;
|
2019-02-24 18:14:36 +03:00
|
|
|
try {
|
|
|
|
$oDB->exec($sSQL);
|
|
|
|
} catch (\Nominatim\DatabaseError $e) {
|
2018-08-31 22:31:38 +03:00
|
|
|
echo "\nERROR: Failed to load nominatim module. Reason:\n";
|
2019-02-24 18:14:36 +03:00
|
|
|
echo $oDB->getLastError()[2] . "\n\n";
|
2018-08-31 22:31:38 +03:00
|
|
|
$bResult = false;
|
|
|
|
}
|
2019-02-24 18:14:36 +03:00
|
|
|
|
2018-08-31 22:31:38 +03:00
|
|
|
return $bResult;
|
|
|
|
}
|