From: Sarah Hoffmann Date: Fri, 16 Nov 2018 23:11:29 +0000 (+0100) Subject: Merge remote-tracking branch 'upstream/master' X-Git-Tag: deploy~307 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/0df5f77bc4c92e2f8f635105441779277435da67?ds=inline;hp=-c Merge remote-tracking branch 'upstream/master' --- 0df5f77bc4c92e2f8f635105441779277435da67 diff --combined CMakeLists.txt index 0c6d4094,d6f7d2cb..7c5763fd --- a/CMakeLists.txt +++ b/CMakeLists.txt @@@ -103,17 -103,8 +103,16 @@@ set(CUSTOMFILE website/reverse.php website/search.php website/status.php + website/403.html + website/509.html + website/crossdomain.xml + website/favicon.ico + website/last_update.php + website/nominatim.xml + website/robots.txt + website/taginfo.json utils/blocks.php utils/country_languages.php - utils/imports.php utils/importWikipedia.php utils/export.php utils/query.php diff --combined lib/Geocode.php index 1dd5a0e5,e2fd7272..5343873f --- a/lib/Geocode.php +++ b/lib/Geocode.php @@@ -18,7 -18,7 +18,7 @@@ class Geocod protected $aLangPrefOrder = array(); protected $aExcludePlaceIDs = array(); - protected $bReverseInPlan = false; + protected $bReverseInPlan = true; protected $iLimit = 20; protected $iFinalLimit = 10; @@@ -546,7 -546,6 +546,6 @@@ // Do we have anything that looks like a lat/lon pair? $sQuery = $oCtx->setNearPointFromQuery($sQuery); - $aResults = array(); if ($sQuery || $this->aStructuredQuery) { // Start with a single blank search $aSearches = array(new SearchDescription($oCtx)); @@@ -746,8 -745,10 +745,10 @@@ // Start the search process $iGroupLoop = 0; $iQueryLoop = 0; + $aNextResults = array(); foreach ($aGroupedSearches as $iGroupedRank => $aSearches) { $iGroupLoop++; + $aResults = $aNextResults; foreach ($aSearches as $oSearch) { $iQueryLoop++; @@@ -767,6 -768,23 +768,23 @@@ if ($iQueryLoop > 20) break; } + if (!empty($aResults)) { + $aSplitResults = Result::splitResults($aResults); + Debug::printVar('Split results', $aSplitResults); + if ($iGroupLoop <= 4 && empty($aSplitResults['tail']) + && reset($aSplitResults['head'])->iResultRank > 0) { + // Haven't found an exact match for the query yet. + // Therefore add result from the next group level. + $aNextResults = $aSplitResults['head']; + foreach ($aNextResults as $oRes) { + $oRes->iResultRank--; + } + $aResults = array(); + } else { + $aResults = $aSplitResults['head']; + } + } + if (!empty($aResults) && ($this->iMinAddressRank != 0 || $this->iMaxAddressRank != 30)) { // Need to verify passes rank limits before dropping out of the loop (yuk!) // reduces the number of place ids, like a filter diff --combined lib/lib.php index 0f87c37e,cd23b068..37ef5e19 --- a/lib/lib.php +++ b/lib/lib.php @@@ -61,6 -61,13 +61,13 @@@ function byImportance($a, $b function javascript_renderData($xVal, $iOptions = 0) { + $sCallback = isset($_GET['json_callback']) ? $_GET['json_callback'] : ''; + if ($sCallback && !preg_match('/^[$_\p{L}][$_\p{L}\p{Nd}.[\]]*$/u', $sCallback)) { + // Unset, we call javascript_renderData again during exception handling + unset($_GET['json_callback']); + throw new Exception('Invalid json_callback value', 400); + } + $iOptions |= JSON_UNESCAPED_UNICODE; if (isset($_GET['pretty']) && in_array(strtolower($_GET['pretty']), array('1', 'true'))) { $iOptions |= JSON_PRETTY_PRINT; @@@ -68,16 -75,12 +75,12 @@@ $jsonout = json_encode($xVal, $iOptions); - if (!isset($_GET['json_callback'])) { + if ($sCallback) { + header('Content-Type: application/javascript; charset=UTF-8'); + echo $_GET['json_callback'].'('.$jsonout.')'; + } else { header('Content-Type: application/json; charset=UTF-8'); echo $jsonout; - } else { - if (preg_match('/^[$_\p{L}][$_\p{L}\p{Nd}.[\]]*$/u', $_GET['json_callback'])) { - header('Content-Type: application/javascript; charset=UTF-8'); - echo $_GET['json_callback'].'('.$jsonout.')'; - } else { - header('HTTP/1.0 400 Bad Request'); - } } } @@@ -174,10 -177,10 +177,10 @@@ function geometryText2Points($geometry_ // preg_match_all('/(-?[0-9.]+) (-?[0-9.]+)/', $aMatch[1], $aPolyPoints, PREG_SET_ORDER); // - } elseif (preg_match('#MULTIPOLYGON\\(\\(\\(([- 0-9.,]+)#', $geometry_as_text, $aMatch)) { +/* } elseif (preg_match('#MULTIPOLYGON\\(\\(\\(([- 0-9.,]+)#', $geometry_as_text, $aMatch)) { // preg_match_all('/(-?[0-9.]+) (-?[0-9.]+)/', $aMatch[1], $aPolyPoints, PREG_SET_ORDER); - // + */ } elseif (preg_match('#POINT\\((-?[0-9.]+) (-?[0-9.]+)\\)#', $geometry_as_text, $aMatch)) { // $aPolyPoints = createPointsAroundCenter($aMatch[1], $aMatch[2], $fRadius); diff --combined website/reverse.php index 5f9268c6,963f7500..075d4cf0 --- a/website/reverse.php +++ b/website/reverse.php @@@ -13,6 -13,7 +13,7 @@@ $oParams = new Nominatim\ParameterParse // Format for output $sOutputFormat = $oParams->getSet('format', array('html', 'xml', 'json', 'jsonv2', 'geojson', 'geocodejson'), 'xml'); + set_exception_handler_by_format($sOutputFormat); // Preferred language $aLangPrefOrder = $oParams->getPreferredLanguages(); @@@ -67,7 -68,6 +68,7 @@@ if (isset($aPlace)) $aPlace = array(); } +logEnd($oDB, $hLog, sizeof($aPlace)?1:0); if (CONST_Debug) { var_dump($aPlace);