From: Sarah Hoffmann Date: Sun, 1 Oct 2017 20:42:24 +0000 (+0200) Subject: Merge pull request #802 from mtmail/coordinate-extract-missing-first-minus-sign X-Git-Tag: v3.1.0~70 X-Git-Url: https://git.openstreetmap.org/nominatim.git/commitdiff_plain/28810e6ce0411870a8fff3ffc00d5abefe556390?hp=06657b3e10ed2d7fbc7d469c3672ca3962502111 Merge pull request #802 from mtmail/coordinate-extract-missing-first-minus-sign NearPoint::extractFromQuery - greedy-match optional quote sign --- diff --git a/lib/Geocode.php b/lib/Geocode.php index a5b9d485..a7987d24 100644 --- a/lib/Geocode.php +++ b/lib/Geocode.php @@ -63,7 +63,7 @@ class Geocode private function normTerm($sTerm) { if ($this->oNormalizer === null) { - return null; + return $sTerm; } return $this->oNormalizer->transliterate($sTerm); @@ -752,7 +752,7 @@ class Geocode } elseif ($sPhraseType == 'postalcode' || ($aSearchTerm['class'] == 'place' && $aSearchTerm['type'] == 'postcode')) { // We need to try the case where the postal code is the primary element (i.e. no way to tell if it is (postalcode, city) OR (city, postalcode) so try both if ($aSearch['sPostcode'] === '' && $aSearch['sHouseNumber'] === '' && - isset($aSearchTerm['word_id']) && $aSearchTerm['word_id'] && strpos($sNormQuery, $this->normTerm($aSearchTerm['word'])) !== false) { + isset($aSearchTerm['word']) && $aSearchTerm['word'] && strpos($sNormQuery, $this->normTerm($aSearchTerm['word'])) !== false) { // If we have structured search or this is the first term, // make the postcode the primary search element. if ($aSearch['sOperator'] === '' && ($sPhraseType == 'postalcode' || ($iToken == 0 && $iPhrase == 0))) { diff --git a/lib/lib.php b/lib/lib.php index a5439ef2..fb89c48b 100644 --- a/lib/lib.php +++ b/lib/lib.php @@ -545,8 +545,12 @@ function _debugDumpGroupedSearches($aData, $aTokens) echo "".$aRow['sPostcode'].""; echo "".$aRow['sHouseNumber'].""; - echo "".$aRow['oNear']->lat().""; - echo "".$aRow['oNear']->lon().""; + if ($aRow['oNear']) { + echo "".$aRow['oNear']->lat().""; + echo "".$aRow['oNear']->lon().""; + } else { + echo ""; + } echo "".$aRow['fRadius'].""; echo ""; diff --git a/test/bdd/api/reverse/params.feature b/test/bdd/api/reverse/params.feature index 765c91c3..1de31c9d 100644 --- a/test/bdd/api/reverse/params.feature +++ b/test/bdd/api/reverse/params.feature @@ -15,6 +15,15 @@ Feature: Parameters for Reverse API | jsonv2 | | xml | + Scenario Outline: Coordinates must be floating-point numbers + When sending reverse coordinates + Then a HTTP 400 is returned + + Examples: + | coords | + | -45.3,; | + | gkjd,50 | + Scenario Outline: Reverse Geocoding with extratags When sending reverse coordinates 10.776234290950017,106.70425325632095 | extratags | diff --git a/test/bdd/api/search/params.feature b/test/bdd/api/search/params.feature index d8423592..b184fd86 100644 --- a/test/bdd/api/search/params.feature +++ b/test/bdd/api/search/params.feature @@ -19,6 +19,12 @@ Feature: Search queries And result 0 has not attributes address And result 0 has bounding box in 46.5,47.5,9,10 + Scenario: Unknown formats returns a user error + When sending search query "Vaduz" + | format | + | x45 | + Then a HTTP 400 is returned + Scenario: JSON search with addressdetails When sending json search query "Montevideo" with address Then address of result 0 is @@ -165,6 +171,12 @@ Feature: Search queries | 4 | Then exactly 4 results are returned + Scenario: Limit parameter must be a number + When sending search query "Blue Laguna" + | limit | + | ); | + Then a HTTP 400 is returned + Scenario: Restrict to feature type country When sending xml search query "Uruguay" Then results contain diff --git a/test/bdd/api/search/postcode.feature b/test/bdd/api/search/postcode.feature new file mode 100644 index 00000000..f92aff3c --- /dev/null +++ b/test/bdd/api/search/postcode.feature @@ -0,0 +1,20 @@ +@APIDB +Feature: Searches with postcodes + Various searches involving postcodes + + Scenario: US 5+4 ZIP codes are shortened to 5 ZIP codes if not found + When sending json search query "57701 1111, us" with address + Then result addresses contain + | postcode | + | 57701 | + + Scenario: Postcode search with address + When sending json search query "9486, mauren" + Then at least 1 result is returned + + Scenario: Postcode search with country + When sending json search query "9486, li" with address + Then result addresses contain + | country_code | + | li | + diff --git a/test/bdd/steps/cgi-with-coverage.php b/test/bdd/steps/cgi-with-coverage.php index 17104d47..165a1b0c 100644 --- a/test/bdd/steps/cgi-with-coverage.php +++ b/test/bdd/steps/cgi-with-coverage.php @@ -1,13 +1,20 @@ stop(); + $writer = new \SebastianBergmann\CodeCoverage\Report\PHP; + $writer->process($oCoverage, $_SERVER['PHP_CODE_COVERAGE_FILE']); +} + $covfilter = new SebastianBergmann\CodeCoverage\Filter(); $covfilter->addDirectoryToWhitelist($_SERVER['COV_PHP_DIR']); $coverage = new SebastianBergmann\CodeCoverage\CodeCoverage(null, $covfilter); $coverage->start($_SERVER['COV_TEST_NAME']); +register_shutdown_function('coverage_shutdown', $coverage); + include $_SERVER['COV_SCRIPT_FILENAME']; -$coverage->stop(); -$writer = new \SebastianBergmann\CodeCoverage\Report\PHP; -$writer->process($coverage, $_SERVER['PHP_CODE_COVERAGE_FILE']); diff --git a/test/bdd/steps/queries.py b/test/bdd/steps/queries.py index 443342b0..963aad4d 100644 --- a/test/bdd/steps/queries.py +++ b/test/bdd/steps/queries.py @@ -349,7 +349,7 @@ def website_search_request(context, fmt, query, addr): context.response = SearchResponse(outp, outfmt, status) -@when(u'sending (?P\S+ )?reverse coordinates (?P[0-9.-]+)?,(?P[0-9.-]+)?') +@when(u'sending (?P\S+ )?reverse coordinates (?P.+)?,(?P.+)?') def website_reverse_request(context, fmt, lat, lon): params = {} if lat is not None: