From: Sarah Hoffmann Date: Fri, 5 Aug 2016 19:18:42 +0000 (+0200) Subject: Merge remote-tracking branch 'upstream/master' into cmake-port X-Git-Tag: deploy~427 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/1d4dcd914fd277aebf242037064612224f4dde54 Merge remote-tracking branch 'upstream/master' into cmake-port --- 1d4dcd914fd277aebf242037064612224f4dde54 diff --cc lib/Geocode.php index 5c99919c,9249b314..379a24f7 --- a/lib/Geocode.php +++ b/lib/Geocode.php @@@ -1428,16 -1440,24 +1441,25 @@@ } //$sSQL .= " limit $this->iLimit"; if (CONST_Debug) var_dump($sSQL); - $aPlaceIDs = $this->oDB->getCol($sSQL); + $aPlaceIDs = chksql($this->oDB->getCol($sSQL)); } + */ - if (!sizeof($aPlaceIDs)) + //if nothing was found in placex or location_property_aux, then search in Tiger data for this housenumber(location_property_tiger) + if (CONST_Use_US_Tiger_Data && !sizeof($aPlaceIDs)) { - $sSQL = "select place_id from location_property_tiger where parent_place_id in (".$sPlaceIDs.") and housenumber = '".pg_escape_string($aSearch['sHouseNumber'])."'"; + //new query for lines, not housenumbers anymore + if($searchedHousenumber%2 == 0){ + //if housenumber is even, look for housenumber in streets with interpolationtype even or all + $sSQL = "select distinct place_id from location_property_tiger where parent_place_id in (".$sPlaceIDs.") and (interpolationtype='even' or interpolationtype='all') and ".$searchedHousenumber.">=startnumber and ".$searchedHousenumber."<=endnumber"; + }else{ + //look for housenumber in streets with interpolationtype odd or all + $sSQL = "select distinct place_id from location_property_tiger where parent_place_id in (".$sPlaceIDs.") and (interpolationtype='odd' or interpolationtype='all') and ".$searchedHousenumber.">=startnumber and ".$searchedHousenumber."<=endnumber"; + } + if (sizeof($this->aExcludePlaceIDs)) { - $sSQL .= " and place_id not in (".join(',',$this->aExcludePlaceIDs).")"; + $sSQL .= " and place_id not in (".join(',', $this->aExcludePlaceIDs).")"; } //$sSQL .= " limit $this->iLimit"; if (CONST_Debug) var_dump($sSQL); diff --cc sql/tiger_import_finish.sql index a7d837f4,374c00b3..09942bac --- a/sql/tiger_import_finish.sql +++ b/sql/tiger_import_finish.sql @@@ -3,10 -4,10 +4,10 @@@ CREATE UNIQUE INDEX idx_location_proper GRANT SELECT ON location_property_tiger_import TO "{www-user}"; -DROP TABLE IF EXISTS location_property_tiger; -ALTER TABLE location_property_tiger_import RENAME TO location_property_tiger; +--DROP TABLE IF EXISTS location_property_tiger; +--ALTER TABLE location_property_tiger_import RENAME TO location_property_tiger; - --ALTER INDEX idx_location_property_tiger_housenumber_parent_place_id_imp RENAME TO idx_location_property_tiger_housenumber_parent_place_id; -ALTER INDEX idx_location_property_tiger_parent_place_id_imp RENAME TO idx_location_property_tiger_housenumber_parent_place_id; -ALTER INDEX idx_location_property_tiger_place_id_imp RENAME TO idx_location_property_tiger_place_id; ++--ALTER INDEX idx_location_property_tiger_parent_place_id_imp RENAME TO idx_location_property_tiger_housenumber_parent_place_id; +--ALTER INDEX idx_location_property_tiger_place_id_imp RENAME TO idx_location_property_tiger_place_id; - DROP FUNCTION tigger_create_interpolation (linegeo geometry, in_startnumber integer, in_endnumber integer, interpolationtype text, in_street text, in_isin text, in_postcode text); + DROP FUNCTION tiger_line_import (linegeo geometry, in_startnumber integer, in_endnumber integer, interpolationtype text, in_street text, in_isin text, in_postcode text); diff --cc utils/setup.php index 01bf1134,992034c7..25e14356 --- a/utils/setup.php +++ b/utils/setup.php @@@ -549,13 -466,16 +466,16 @@@ $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) "; - $sSQL .= "select 'P',nextval('seq_postcodes'),'place','postcode',postcode,'us',"; - $sSQL .= "ST_SetSRID(ST_Point(x,y),4326) as geometry from us_postcode"; - if (!pg_query($oDB->connection, $sSQL)) fail(pg_last_error($oDB->connection)); + if (CONST_Use_Extra_US_Postcodes) + { + $sSQL = "insert into placex (osm_type,osm_id,class,type,postcode,calculated_country_code,geometry) "; + $sSQL .= "select 'P',nextval('seq_postcodes'),'place','postcode',postcode,'us',"; + $sSQL .= "ST_SetSRID(ST_Point(x,y),4326) as geometry from us_postcode"; + if (!pg_query($oDB->connection, $sSQL)) fail(pg_last_error($oDB->connection)); + } } if ($aCMDResult['osmosis-init'] || ($aCMDResult['all'] && !$aCMDResult['drop'])) // no use doing osmosis-init when dropping update tables diff --cc utils/update.php index c6de7af6,82362b31..a05ad9e4 --- a/utils/update.php +++ b/utils/update.php @@@ -450,43 -329,9 +329,18 @@@ $sBatchEnd = getosmosistimestamp($sOsmosisConfigDirectory); // Index file - $sThisIndexCmd = $sCMDIndex; + if (!isset($aResult['index-instances'])) + { + if (getLoadAverage() < 24) + $iIndexInstances = 2; + else + $iIndexInstances = 1; + } else + $iIndexInstances = $aResult['index-instances']; + + $sThisIndexCmd = $sCMDIndex.' -t '.$iIndexInstances; $fCMDStartTime = time(); - if (!$aResult['no-npi']) - { - $iFileID = $oDB->getOne('select nextval(\'file\')'); - if (PEAR::isError($iFileID)) - { - echo $iFileID->getMessage()."\n"; - exit(-1); - } - $sFileDir = CONST_BasePath.'/export/diff/'; - $sFileDir .= str_pad(floor($iFileID/1000000), 3, '0', STR_PAD_LEFT); - $sFileDir .= '/'.str_pad(floor($iFileID/1000) % 1000, 3, '0', STR_PAD_LEFT); - - if (!is_dir($sFileDir)) mkdir($sFileDir, 0777, true); - $sThisIndexCmd .= $sFileDir; - $sThisIndexCmd .= '/'.str_pad($iFileID % 1000, 3, '0', STR_PAD_LEFT); - $sThisIndexCmd .= ".npi.out"; - - preg_match('#^([0-9]{4})-([0-9]{2})-([0-9]{2})#', $sBatchEnd, $aBatchMatch); - $sFileDir = CONST_BasePath.'/export/index/'; - $sFileDir .= $aBatchMatch[1].'/'.$aBatchMatch[2]; - - if (!is_dir($sFileDir)) mkdir($sFileDir, 0777, true); - file_put_contents($sFileDir.'/'.$aBatchMatch[3].'.idx', "$sBatchEnd\t$iFileID\n", FILE_APPEND); - } - if (!$aResult['no-index']) { echo "$sThisIndexCmd\n"; diff --cc website/reverse.php index b1a7d77e,f7c01860..f3763866 --- a/website/reverse.php +++ b/website/reverse.php @@@ -96,12 -92,7 +92,8 @@@ $aPlace = array_merge($aPlace, $aOutlineResult); } } - else - { - $aPlace = null; - } + logEnd($oDB, $hLog, sizeof($aPlace)?1:0); if (CONST_Debug) {