X-Git-Url: https://git.openstreetmap.org/nominatim.git/blobdiff_plain/6867b240d5d23c22ae04c57d65881d54d793da73..a83424fee50c6837bcadad44ae374de98e4bb1f1:/utils/setup.php diff --git a/utils/setup.php b/utils/setup.php index 0814794f..6f1ce41d 100755 --- a/utils/setup.php +++ b/utils/setup.php @@ -360,16 +360,20 @@ if ($aCMDResult['load-data'] || $aCMDResult['all']) { } echo "Load Data\n"; + $sColumns = 'osm_type, osm_id, class, type, name, admin_level, address, extratags, geometry'; + $aDBInstances = array(); $iLoadThreads = max(1, $iInstances - 1); for ($i = 0; $i < $iLoadThreads; $i++) { $aDBInstances[$i] =& getDB(true); - $sSQL = 'insert into placex (osm_type, osm_id, class, type, name, admin_level, '; - $sSQL .= ' address, extratags, geometry) '; - $sSQL .= 'select * from place where osm_id % '.$iLoadThreads.' = '.$i; - $sSQL .= " and not (class='place' and type='houses' and osm_type='W' and ST_GeometryType(geometry) = 'ST_LineString')"; + $sSQL = "INSERT INTO placex ($sColumns) SELECT $sColumns FROM place WHERE osm_id % $iLoadThreads = $i"; + $sSQL .= " and not (class='place' and type='houses' and osm_type='W'"; + $sSQL .= " and ST_GeometryType(geometry) = 'ST_LineString')"; + $sSQL .= " and ST_IsValid(geometry)"; if ($aCMDResult['verbose']) echo "$sSQL\n"; - if (!pg_send_query($aDBInstances[$i]->connection, $sSQL)) fail(pg_last_error($oDB->connection)); + if (!pg_send_query($aDBInstances[$i]->connection, $sSQL)) { + fail(pg_last_error($aDBInstances[$i]->connection)); + } } // last thread for interpolation lines $aDBInstances[$iLoadThreads] =& getDB(true); @@ -378,7 +382,9 @@ if ($aCMDResult['load-data'] || $aCMDResult['all']) { $sSQL .= ' SELECT osm_id, address, geometry from place where '; $sSQL .= "class='place' and type='houses' and osm_type='W' and ST_GeometryType(geometry) = 'ST_LineString'"; if ($aCMDResult['verbose']) echo "$sSQL\n"; - if (!pg_send_query($aDBInstances[$i]->connection, $sSQL)) fail(pg_last_error($oDB->connection)); + if (!pg_send_query($aDBInstances[$iLoadThreads]->connection, $sSQL)) { + fail(pg_last_error($aDBInstances[$iLoadThreads]->connection)); + } $bAnyBusy = true; while ($bAnyBusy) {