find_package(LibXml2 REQUIRED)
include_directories(${LIBXML2_INCLUDE_DIR})
+#-----------------------------------------------------------------------------
+#
+# Setup settings and paths
+#
+#-----------------------------------------------------------------------------
+
+configure_file(
+ ${PROJECT_SOURCE_DIR}/settings/settings.php
+ ${PROJECT_BINARY_DIR}/settings/settings.php
+)
+
+configure_file(
+ ${PROJECT_SOURCE_DIR}/settings/phrase_settings.php
+ ${PROJECT_BINARY_DIR}/settings/phrase_settings.php
+)
+
+execute_process(
+ COMMAND ln -s -t ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/utils
+)
+
#-----------------------------------------------------------------------------
add_subdirectory(module)
@define('CONST_BasePath', dirname(dirname(__FILE__)));
- require_once(CONST_BasePath.'/settings/settings.php');
+ require_once('settings/settings.php');
require_once(CONST_BasePath.'/lib/lib.php');
require_once(CONST_BasePath.'/lib/leakybucket.php');
require_once(CONST_BasePath.'/lib/db.php');
<?php
- if (file_exists(CONST_BasePath.'/settings/local.php')) require_once(CONST_BasePath.'/settings/local.php');
+ @define('CONST_InstallPath', dirname(dirname(__FILE__)));
+ if (file_exists(CONST_InstallPath.'/settings/local.php')) require_once(CONST_InstallPath.'/settings/local.php');
if (isset($_GET['debug']) && $_GET['debug']) @define('CONST_Debug', true);
// General settings
// Paths
@define('CONST_Path_Postgresql_Contrib', '/usr/share/postgresql/'.CONST_Postgresql_Version.'/contrib');
@define('CONST_Path_Postgresql_Postgis', CONST_Path_Postgresql_Contrib.'/postgis-'.CONST_Postgis_Version);
- @define('CONST_Osm2pgsql_Binary', CONST_BasePath.'/osm2pgsql/osm2pgsql');
+ @define('CONST_Osm2pgsql_Binary', CONST_InstallPath.'/osm2pgsql/osm2pgsql');
@define('CONST_Osmosis_Binary', '/usr/bin/osmosis');
@define('CONST_Tiger_Data_Path', CONST_BasePath.'/data/tiger');
);
getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
- include(CONST_BasePath.'/settings/phrase_settings.php');
+ include(CONST_InstallPath.'/settings/phrase_settings.php');
if (true)
{
{
echo "Functions\n";
$bDidSomething = true;
- if (!file_exists(CONST_BasePath.'/module/nominatim.so')) fail("nominatim module not built");
+ if (!file_exists(CONST_InstallPath.'/module/nominatim.so')) fail("nominatim module not built");
$sTemplate = file_get_contents(CONST_BasePath.'/sql/functions.sql');
- $sTemplate = str_replace('{modulepath}', CONST_BasePath.'/module', $sTemplate);
+ $sTemplate = str_replace('{modulepath}', CONST_InstallPath.'/module', $sTemplate);
if ($aCMDResult['enable-diff-updates']) $sTemplate = str_replace('RETURN NEW; -- @DIFFUPDATES@', '--', $sTemplate);
if ($aCMDResult['enable-debug-statements']) $sTemplate = str_replace('--DEBUG:', '', $sTemplate);
if (CONST_Limit_Reindexing) $sTemplate = str_replace('--LIMIT INDEXING:', '', $sTemplate);
echo "Functions\n";
$sTemplate = file_get_contents(CONST_BasePath.'/sql/functions.sql');
$sTemplate = str_replace('{modulepath}',
- CONST_BasePath.'/module', $sTemplate);
+ CONST_InstallPath.'/module', $sTemplate);
pgsqlRunScript($sTemplate);
}
}
else
{
- if (file_exists(CONST_BasePath.'/settings/configuration.txt'))
+ if (file_exists(CONST_InstallPath.'/settings/configuration.txt'))
{
echo "settings/configuration.txt already exists\n";
}
else
{
- passthru(CONST_Osmosis_Binary.' --read-replication-interval-init '.CONST_BasePath.'/settings');
+ passthru(CONST_Osmosis_Binary.' --read-replication-interval-init '.CONST_InstallPath.'/settings');
// update osmosis configuration.txt with our settings
- passthru("sed -i 's!baseUrl=.*!baseUrl=".CONST_Replication_Url."!' ".CONST_BasePath.'/settings/configuration.txt');
- passthru("sed -i 's:maxInterval = .*:maxInterval = ".CONST_Replication_MaxInterval.":' ".CONST_BasePath.'/settings/configuration.txt');
+ passthru("sed -i 's!baseUrl=.*!baseUrl=".CONST_Replication_Url."!' ".CONST_InstallPath.'/settings/configuration.txt');
+ passthru("sed -i 's:maxInterval = .*:maxInterval = ".CONST_Replication_MaxInterval.":' ".CONST_InstallPath.'/settings/configuration.txt');
}
// Find the last node in the DB
echo "Getting state file: $sRepURL\n";
$sStateFile = file_get_contents($sRepURL);
if (!$sStateFile || strlen($sStateFile) > 1000) fail("unable to obtain state file");
- file_put_contents(CONST_BasePath.'/settings/state.txt', $sStateFile);
+ file_put_contents(CONST_InstallPath.'/settings/state.txt', $sStateFile);
echo "Updating DB status\n";
pg_query($oDB->connection, 'TRUNCATE import_status');
$sSQL = "INSERT INTO import_status VALUES('".$aRepMatch[2]."')";
$bDidSomething = true;
$sOutputFile = '';
if (isset($aCMDResult['index-output'])) $sOutputFile = ' -F '.$aCMDResult['index-output'];
- $sBaseCmd = CONST_BasePath.'/nominatim/nominatim -i -d '.$aDSNInfo['database'].' -P '.$aDSNInfo['port'].' -t '.$iInstances.$sOutputFile;
+ $sBaseCmd = CONST_InstallPath.'/nominatim/nominatim -i -d '.$aDSNInfo['database'].' -P '.$aDSNInfo['port'].' -t '.$iInstances.$sOutputFile;
passthruCheckReturn($sBaseCmd.' -R 4');
if (!$aCMDResult['index-noanalyse']) pgsqlRunScript('ANALYSE');
passthruCheckReturn($sBaseCmd.' -r 5 -R 25');
);
getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
- include(CONST_BasePath.'/settings/phrase_settings.php');
+ include(CONST_InstallPath.'/settings/phrase_settings.php');
if ($aCMDResult['countries']) {
}
*/
- // Assume osm2pgsql is in the folder above
- $sBasePath = dirname(dirname(__FILE__));
-
date_default_timezone_set('Etc/UTC');
$oDB =& getDB();
if ($aResult['index'])
{
- passthru(CONST_BasePath.'/nominatim/nominatim -i -d '.$aDSNInfo['database'].' -P '.$aDSNInfo['port'].' -t '.$aResult['index-instances'].' -r '.$aResult['index-rank']);
+ passthru(CONST_InstallPath.'/nominatim/nominatim -i -d '.$aDSNInfo['database'].' -P '.$aDSNInfo['port'].' -t '.$aResult['index-instances'].' -r '.$aResult['index-rank']);
}
if ($aResult['import-osmosis'] || $aResult['import-osmosis-all'])
$sImportFile = CONST_BasePath.'/data/osmosischange.osc';
$sOsmosisCMD = CONST_Osmosis_Binary;
- $sOsmosisConfigDirectory = CONST_BasePath.'/settings';
+ $sOsmosisConfigDirectory = CONST_InstallPath.'/settings';
$sCMDDownload = $sOsmosisCMD.' --read-replication-interval workingDirectory='.$sOsmosisConfigDirectory.' --simplify-change --write-xml-change '.$sImportFile;
$sCMDCheckReplicationLag = $sOsmosisCMD.' -q --read-replication-lag workingDirectory='.$sOsmosisConfigDirectory;
$sCMDImport = $sOsm2pgsqlCmd.' '.$sImportFile;
- $sCMDIndex = $sBasePath.'/nominatim/nominatim -i -d '.$aDSNInfo['database'].' -P '.$aDSNInfo['port'].' -t '.$aResult['index-instances'];
+ $sCMDIndex = $sInstallPath.'/nominatim/nominatim -i -d '.$aDSNInfo['database'].' -P '.$aDSNInfo['port'].' -t '.$aResult['index-instances'];
if (!$aResult['no-npi']) {
$sCMDIndex .= '-F ';
}
var_dump($iNPIID);
exit(1);
}
- $sConfigDirectory = CONST_BasePath.'/settings';
- $sCMDImportTemplate = $sBasePath.'/nominatim/nominatim -d gazetteer -P 5433 -I -T '.$sBasePath.'/nominatim/partitionedtags.def -F ';
+ $sConfigDirectory = CONST_InstallPath.'/settings';
+ $sCMDImportTemplate = $sBasePath.'/nominatim/nominatim -d gazetteer -P 5433 -I -T '.CONST_BasePath.'/nominatim/partitionedtags.def -F ';
while(true)
{
$fStartTime = time();