$this->sType = $sType;
}
- /**
- * Check if this might be a full address search.
- *
- * @return bool True if the search contains name, address and housenumber.
- */
- public function looksLikeFullAddress()
- {
- return (!empty($this->aName))
- && (!empty($this->aAddress) || $this->sCountryCode)
- && preg_match('/[0-9]+/', $this->sHouseNumber);
- }
-
/**
* Check if any operator is set.
*
'Name terms (stop words)' => $this->aNameNonSearch,
'Address terms' => $this->aAddress,
'Address terms (stop words)' => $this->aAddressNonSearch,
- 'Address terms (full words)' => $this->aFullNameAddress,
+ 'Address terms (full words)' => $this->aFullNameAddress ?? '',
'Special search' => $this->iOperator,
'Class' => $this->sClass,
'Type' => $this->sType,
public function dumpAsHtmlTableRow(&$aWordIDs)
{
$kf = function ($k) use (&$aWordIDs) {
- return $aWordIDs[$k];
+ return $aWordIDs[$k] ?? '['.$k.']';
};
echo '<tr>';
| -45.3,; |
| gkjd,50 |
+ Scenario Outline: Zoom levels between 4 and 18 are allowed
+ When sending reverse coordinates 47.14122383,9.52169581334
+ | zoom |
+ | <zoom> |
+ Then exactly 1 result is returned
+ And result addresses contain
+ | country_code |
+ | li |
+
+ Examples:
+ | zoom |
+ | 4 |
+ | 5 |
+ | 6 |
+ | 7 |
+ | 8 |
+ | 9 |
+ | 10 |
+ | 11 |
+ | 12 |
+ | 13 |
+ | 14 |
+ | 15 |
+ | 16 |
+ | 17 |
+ | 18 |
+
+ Scenario: Non-numerical zoom levels return an error
+ When sending reverse coordinates 47.14122383,9.52169581334
+ | zoom |
+ | adfe |
+ Then a HTTP 400 is returned
+
Scenario Outline: Reverse Geocoding with extratags
When sending <format> reverse coordinates 47.1395013150811,9.522098077031046
| extratags |
| 48.966 | 8.448.2 |
| Nan | 8.448 |
| 48.966 | Nan |
+
+ Scenario: Reverse Debug output returns no errors
+ When sending debug reverse coordinates 47.11,9.57
+ Then a HTTP 200 is returned
| class | type |
| amenity | restaurant |
+ Scenario: Search with specific amenity also work in country
+ When sending json search query "restaurants in liechtenstein" with address
+ Then result addresses contain
+ | country |
+ | Liechtenstein |
+ And results contain
+ | class | type |
+ | amenity | restaurant |
+
Scenario: Search with key-value amenity
When sending json search query "[club=scout] Vaduz"
Then results contain
| class | type |
| leisure | firepit |
+ Scenario Outline: Key/value search near given coordinate can be restricted to country
+ When sending json search query "[natural=peak] 47.06512,9.53965" with address
+ | countrycodes |
+ | <cc> |
+ Then result addresses contain
+ | country_code |
+ | <cc> |
+
+ Examples:
+ | cc |
+ | li |
+ | ch |
+
Scenario: Name search near given coordinate
When sending json search query "sporry" with address
Then result addresses contain
| li |
Then exactly 0 results are returned
+ Scenario: Country searches only return results for the given country
+ When sending search query "Ans Trail" with address
+ | countrycodes |
+ | li |
+ Then result addresses contain
+ | country_code |
+ | li |
+
# https://trac.openstreetmap.org/ticket/5094
Scenario: housenumbers are ordered by complete match first
When sending json search query "Austrasse 11, Vaduz" with address
Then result addresses contain
| ID | town |
| 0 | Vaduz |
+
+ Scenario: Search can handle complex query word sets
+ When sending search query "aussenstelle universitat lichtenstein wachterhaus aussenstelle universitat lichtenstein wachterhaus aussenstelle universitat lichtenstein wachterhaus aussenstelle universitat lichtenstein wachterhaus"
+ Then a HTTP 200 is returned
Then result header contains
| attr | value |
| more_url | .*&countrycodes=pl%2Cbo&.* |
+
+ Scenario Outline: Search debug output does not return errors
+ When sending debug search query "<query>"
+ Then a HTTP 200 is returned
+
+ Examples:
+ | query |
+ | Liechtenstein |
+ | Triesen |
+ | Pfarrkirche |
+ | Landstr 27 Steinort, Triesenberg, 9495 |
+ | 9497 |
+ | restaurant in triesen |
self.result = []
self.header = dict()
- if errorcode == 200:
+ if errorcode == 200 and fmt != 'debug':
getattr(self, '_parse_' + fmt)()
def _parse_json(self):
context.response = SearchResponse(outp, 'json')
def send_api_query(endpoint, params, fmt, context):
- if fmt is not None:
+ if fmt is not None and fmt.strip() != 'debug':
params['format'] = fmt.strip()
if context.table:
if context.table.headings[0] == 'param':
params['q'] = query
if addr is not None:
params['addressdetails'] = '1'
+ if fmt and fmt.strip() == 'debug':
+ params['debug'] = '1'
outp, status = send_api_query('search', params, fmt, context)
params['lat'] = lat
if lon is not None:
params['lon'] = lon
+ if fmt and fmt.strip() == 'debug':
+ params['debug'] = '1'
outp, status = send_api_query('reverse', params, fmt, context)
@then(u'a HTTP (?P<status>\d+) is returned')
def check_http_return_status(context, status):
- assert context.response.errorcode == int(status)
+ assert context.response.errorcode == int(status), \
+ "Return HTTP status is {}.".format(context.response.errorcode)
@then(u'the page contents equals "(?P<text>.+)"')
def check_page_content_equals(context, text):