]> git.openstreetmap.org Git - nominatim.git/blobdiff - utils/setup.php
Merge remote-tracking branch 'upstream/master'
[nominatim.git] / utils / setup.php
index 8cbb29781729d46bdee0d9f5407389ef845453d3..45b40fedfc463bb7b0f3d32183628958e5953670 100755 (executable)
@@ -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'])
                // 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) {
                } 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');
                        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);
 
                $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) ";
                @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');