X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/4f49ef07e653e91fae3a75976074833905c79aa8..bcbba1cb5a4e5a1df3b8f5c79e2a988221adf867:/utils/setup.php diff --git a/utils/setup.php b/utils/setup.php index 8cbb2978..45b40fed 100755 --- a/utils/setup.php +++ b/utils/setup.php @@ -95,7 +95,7 @@ { fail('database already exists ('.CONST_Database_DSN.')'); } - passthru('createdb -E UTF-8 '.$aDSNInfo['database']); + passthruCheckReturn('createdb -E UTF-8 '.$aDSNInfo['database']); } if ($aCMDResult['setup-db'] || $aCMDResult['all']) @@ -105,6 +105,15 @@ // TODO: path detection, detection memory, etc. $oDB =& getDB(); + + $sVersionString = $oDB->getOne('select version()'); + preg_match('#PostgreSQL ([0-9]+)[.]([0-9]+)[.]([0-9]+) #', $sVersionString, $aMatches); + if (CONST_Postgresql_Version != $aMatches[1].'.'.$aMatches[2]) + { + echo "ERROR: PostgreSQL version is not correct. Expected ".CONST_Postgresql_Version." found ".$aMatches[1].'.'.$aMatches[2]."\n"; + exit; + } + passthru('createlang plpgsql '.$aDSNInfo['database']); $pgver = (float) CONST_Postgresql_Version; if ($pgver < 9.1) { @@ -113,7 +122,16 @@ } else { pgsqlRunScript('CREATE EXTENSION hstore'); } + pgsqlRunScriptFile(CONST_Path_Postgresql_Postgis.'/postgis.sql'); + $sVersionString = $oDB->getOne('select postgis_full_version()'); + preg_match('#POSTGIS="([0-9]+)[.]([0-9]+)[.]([0-9]+)( r([0-9]+))?"#', $sVersionString, $aMatches); + if (CONST_Postgis_Version != $aMatches[1].'.'.$aMatches[2]) + { + echo "ERROR: PostGIS version is not correct. Expected ".CONST_Postgis_Version." found ".$aMatches[1].'.'.$aMatches[2]."\n"; + exit; + } + pgsqlRunScriptFile(CONST_Path_Postgresql_Postgis.'/spatial_ref_sys.sql'); pgsqlRunScriptFile(CONST_BasePath.'/data/country_name.sql'); pgsqlRunScriptFile(CONST_BasePath.'/data/country_naturalearthdata.sql'); @@ -136,8 +154,9 @@ echo "Please download and build osm2pgsql.\nIf it is already installed, check the path in your local settings (settings/local.php) file.\n"; fail("osm2pgsql not found in '$osm2pgsql'"); } + $osm2pgsql .= ' --tablespace-slim-index ssd --tablespace-main-index ssd --tablespace-main-data ssd --tablespace-slim-data data'; $osm2pgsql .= ' -lsc -O gazetteer --hstore'; - $osm2pgsql .= ' -C '.$iCacheMemory; + $osm2pgsql .= ' -C 16000'; $osm2pgsql .= ' -d '.$aDSNInfo['database'].' '.$aCMDResult['osm-file']; passthruCheckReturn($osm2pgsql); @@ -432,7 +451,7 @@ $sSQL .= "select 'P',nextval('seq_postcodes'),'place','postcode',postcode,calculated_country_code,"; $sSQL .= "ST_SetSRID(ST_Point(x,y),4326) as geometry from (select calculated_country_code,postcode,"; $sSQL .= "avg(st_x(st_centroid(geometry))) as x,avg(st_y(st_centroid(geometry))) as y "; - $sSQL .= "from placex where postcode is not null group by calculated_country_code,postcode) as x"; + $sSQL .= "from placex where postcode is not null and calculated_country_code not in ('ie') group by calculated_country_code,postcode) as x"; if (!pg_query($oDB->connection, $sSQL)) fail(pg_last_error($oDB->connection)); $sSQL = "insert into placex (osm_type,osm_id,class,type,postcode,calculated_country_code,geometry) "; @@ -568,6 +587,8 @@ @symlink(CONST_BasePath.'/website/reverse.php', $sTargetDir.'/reverse.php'); @symlink(CONST_BasePath.'/website/search.php', $sTargetDir.'/search.php'); @symlink(CONST_BasePath.'/website/search.php', $sTargetDir.'/index.php'); + @symlink(CONST_BasePath.'/website/deletable.php', $sTargetDir.'/deletable.php'); + @symlink(CONST_BasePath.'/website/polygons.php', $sTargetDir.'/polygons.php'); @symlink(CONST_BasePath.'/website/images', $sTargetDir.'/images'); @symlink(CONST_BasePath.'/website/js', $sTargetDir.'/js'); @symlink(CONST_BasePath.'/website/css', $sTargetDir.'/css');