private function normTerm($sTerm)
{
if ($this->oNormalizer === null) {
- return null;
+ return $sTerm;
}
return $this->oNormalizer->transliterate($sTerm);
} 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))) {
echo "<td>".$aRow['sPostcode']."</td>";
echo "<td>".$aRow['sHouseNumber']."</td>";
- echo "<td>".$aRow['oNear']->lat()."</td>";
- echo "<td>".$aRow['oNear']->lon()."</td>";
+ if ($aRow['oNear']) {
+ echo "<td>".$aRow['oNear']->lat()."</td>";
+ echo "<td>".$aRow['oNear']->lon()."</td>";
+ } else {
+ echo "<td></td><td></td>";
+ }
echo "<td>".$aRow['fRadius']."</td>";
echo "</tr>";
| jsonv2 |
| xml |
+ Scenario Outline: Coordinates must be floating-point numbers
+ When sending reverse coordinates <coords>
+ Then a HTTP 400 is returned
+
+ Examples:
+ | coords |
+ | -45.3,; |
+ | gkjd,50 |
+
Scenario Outline: Reverse Geocoding with extratags
When sending <format> reverse coordinates 10.776234290950017,106.70425325632095
| extratags |
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
| 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
--- /dev/null
+@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 |
+
<?php
require_once 'SebastianBergmann/CodeCoverage/autoload.php';
+
+function coverage_shutdown($oCoverage)
+{
+ $oCoverage->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']);
context.response = SearchResponse(outp, outfmt, status)
-@when(u'sending (?P<fmt>\S+ )?reverse coordinates (?P<lat>[0-9.-]+)?,(?P<lon>[0-9.-]+)?')
+@when(u'sending (?P<fmt>\S+ )?reverse coordinates (?P<lat>.+)?,(?P<lon>.+)?')
def website_reverse_request(context, fmt, lat, lon):
params = {}
if lat is not None: