]> git.openstreetmap.org Git - nominatim.git/commitdiff
Merge remote-tracking branch 'upstream/master' into cmake-port
authorSarah Hoffmann <lonvia@denofr.de>
Fri, 5 Aug 2016 19:18:42 +0000 (21:18 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Fri, 5 Aug 2016 19:18:42 +0000 (21:18 +0200)
1  2 
lib/Geocode.php
lib/init-website.php
lib/lib.php
sql/functions.sql
sql/tiger_import_finish.sql
tests/features/api/search_params.feature
tests/features/api/search_simple.feature
utils/setup.php
utils/update.php
website/reverse.php

diff --cc lib/Geocode.php
index 5c99919c46a940cb3c810343fa11e6389736bceb,9249b31474ef6900455ef697f3b9a5862be216ec..379a24f7a3b8827e39213715dd89af8ea35c412d
                                                                        }
                                                                        //$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);
Simple merge
diff --cc lib/lib.php
Simple merge
Simple merge
index a7d837f4c02a30927b93c77e63f3592c1b3e24c5,374c00b39bcaa5bfa37aa1a66b703c89e61583f1..09942bac48cffacf6dad971ac09ac3f023029602
@@@ -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 01bf11349ce750d60d130c5ca084b9689be62cee,992034c77943cbbe94e5603894cc73722b13a5a4..25e1435671b69b115c79d07c9e4b62717d6b0d2d
                $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
index c6de7af6f9d2f4ba94e770af211ba6d8c61fbdfb,82362b3119c174993583f38bc42904ec6f42efab..a05ad9e4e53bf7044e09037ce6bdb5d38baf2b39
                        $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";
index b1a7d77e8ded60c6a3d4f7a0724ea61c6ce1deda,f7c01860f0fb30438e1843937ac2721d7c06d88e..f37638665e1734a9ec6d11b4a67a4974dcd86366
                        $aPlace = array_merge($aPlace, $aOutlineResult);
                }
        }
-       else
-       {
-               $aPlace = null;
-       }
  
 +      logEnd($oDB, $hLog, sizeof($aPlace)?1:0);
  
        if (CONST_Debug)
        {