From: Sarah Hoffmann Date: Sun, 18 May 2014 19:42:45 +0000 (+0200) Subject: Merge remote-tracking branch 'upstream/master' X-Git-Tag: deploy~530 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/6b1f2cb2bc9771f2c65ff3f44855e6bfdf778d90?hp=676f7c86705ae9d1ccdfdef6f6574cb491006e63 Merge remote-tracking branch 'upstream/master' --- diff --git a/lib/PlaceLookup.php b/lib/PlaceLookup.php index ed2f494d..e0016337 100644 --- a/lib/PlaceLookup.php +++ b/lib/PlaceLookup.php @@ -124,7 +124,7 @@ { $sTypeLabel = strtolower(isset($aTypeLabel['simplelabel'])?$aTypeLabel['simplelabel']:$aTypeLabel['label']); $sTypeLabel = str_replace(' ','_',$sTypeLabel); - if (!isset($aAddress[$sTypeLabel]) || (isset($aFallback[$sTypeLabel]) && $aFallback[$sTypeLabel])) + if (!isset($aAddress[$sTypeLabel]) || (isset($aFallback[$sTypeLabel]) && $aFallback[$sTypeLabel]) || $aLine['class'] == 'place') { $aAddress[$sTypeLabel] = $aLine['localname']?$aLine['localname']:$aLine['housenumber']; } diff --git a/lib/lib.php b/lib/lib.php index 12f7e57e..b26038d8 100644 --- a/lib/lib.php +++ b/lib/lib.php @@ -789,7 +789,7 @@ { $sTypeLabel = strtolower(isset($aTypeLabel['simplelabel'])?$aTypeLabel['simplelabel']:$aTypeLabel['label']); $sTypeLabel = str_replace(' ','_',$sTypeLabel); - if (!isset($aAddress[$sTypeLabel]) || (isset($aFallback[$sTypeLabel]) && $aFallback[$sTypeLabel])) + if (!isset($aAddress[$sTypeLabel]) || (isset($aFallback[$sTypeLabel]) && $aFallback[$sTypeLabel]) || $aLine['class'] == 'place') { $aAddress[$sTypeLabel] = $aLine['localname']?$aLine['localname']:$aLine['housenumber']; } diff --git a/osm2pgsql b/osm2pgsql index 49089cb1..b59765e3 160000 --- a/osm2pgsql +++ b/osm2pgsql @@ -1 +1 @@ -Subproject commit 49089cb1a3c72ad97b57db21716a5fa07d4f2f8a +Subproject commit b59765e3ac591ff84f21f4a1153e7c18a2d2b855 diff --git a/sql/functions.sql b/sql/functions.sql index 9cf1bd40..a6fa20ea 100644 --- a/sql/functions.sql +++ b/sql/functions.sql @@ -2534,7 +2534,9 @@ BEGIN FOR location IN select placex.place_id, osm_type, osm_id, CASE WHEN class = 'place' and type = 'postcode' THEN hstore('name', postcode) ELSE name END as name, - class, type, admin_level, fromarea, isaddress, + CASE WHEN extratags ? 'place' THEN 'place' ELSE class END as class, + CASE WHEN extratags ? 'place' THEN extratags->'place' ELSE type END as type, + admin_level, fromarea, isaddress, CASE WHEN address_place_id = for_place_id AND rank_address = 0 THEN 100 WHEN rank_address = 11 THEN 5 ELSE rank_address END as rank_address, distance,calculated_country_code,postcode from place_addressline join placex on (address_place_id = placex.place_id) diff --git a/sql/partition-functions.src.sql b/sql/partition-functions.src.sql index 8857e766..a0181c0a 100644 --- a/sql/partition-functions.src.sql +++ b/sql/partition-functions.src.sql @@ -60,6 +60,9 @@ create or replace function insertLocationAreaLarge( in_centroid GEOMETRY, in_geometry GEOMETRY) RETURNS BOOLEAN AS $$ DECLARE BEGIN + IF in_rank_address = 0 THEN + RETURN TRUE; + END IF; IF in_rank_search <= 4 THEN INSERT INTO location_area_country values (in_partition, in_place_id, in_country_code, in_keywords, in_rank_search, in_rank_address, in_estimate, in_centroid, in_geometry); @@ -205,16 +208,20 @@ BEGIN IF in_rank_search <= 4 THEN DELETE FROM search_name_country WHERE place_id = in_place_id; - INSERT INTO search_name_country values (in_place_id, in_rank_search, in_rank_address, - in_name_vector, in_geometry); + IF in_rank_address > 0 THEN + INSERT INTO search_name_country values (in_place_id, in_rank_search, in_rank_address, + in_name_vector, in_geometry); + END IF; RETURN TRUE; END IF; -- start IF in_partition = -partition- THEN DELETE FROM search_name_-partition- values WHERE place_id = in_place_id; - INSERT INTO search_name_-partition- values (in_place_id, in_rank_search, in_rank_address, - in_name_vector, in_geometry); + IF in_rank_address > 0 THEN + INSERT INTO search_name_-partition- values (in_place_id, in_rank_search, in_rank_address, + in_name_vector, in_geometry); + END IF; RETURN TRUE; END IF; -- end diff --git a/utils/setup.php b/utils/setup.php index edf0b14d..734f669f 100755 --- a/utils/setup.php +++ b/utils/setup.php @@ -22,6 +22,7 @@ array('create-functions', '', 0, 1, 0, 0, 'bool', 'Create functions'), array('enable-diff-updates', '', 0, 1, 0, 0, 'bool', 'Turn on the code required to make diff updates work'), array('enable-debug-statements', '', 0, 1, 0, 0, 'bool', 'Include debug warning statements in pgsql commands'), + array('ignore-errors', '', 0, 1, 0, 0, 'bool', 'Continue import even when errors in SQL are present (EXPERT)'), array('create-minimal-tables', '', 0, 1, 0, 0, 'bool', 'Create minimal main tables'), array('create-tables', '', 0, 1, 0, 0, 'bool', 'Create main tables'), array('create-partition-tables', '', 0, 1, 0, 0, 'bool', 'Create required partition tables'), @@ -746,11 +747,13 @@ function pgsqlRunScript($sScript) { + global $aCMDResult; // Convert database DSN to psql parameters $aDSNInfo = DB::parseDSN(CONST_Database_DSN); if (!isset($aDSNInfo['port']) || !$aDSNInfo['port']) $aDSNInfo['port'] = 5432; $sCMD = 'psql -p '.$aDSNInfo['port'].' -d '.$aDSNInfo['database']; - $sCMD .= ' -v ON_ERROR_STOP=1'; + if (!$aCMDResult['ignore-errors']) + $sCMD .= ' -v ON_ERROR_STOP=1'; $aDescriptors = array( 0 => array('pipe', 'r'), 1 => STDOUT, @@ -763,6 +766,7 @@ while(strlen($sScript)) { $written = fwrite($ahPipes[0], $sScript); + if ($written <= 0) break; $sScript = substr($sScript, $written); } fclose($ahPipes[0]);