+++ /dev/null
-<?php
-@define('CONST_LibDir', dirname(dirname(__FILE__)));
-
-require_once(CONST_LibDir.'/init-cmd.php');
-require_once(CONST_LibDir.'/ParameterParser.php');
-ini_set('memory_limit', '800M');
-
-$aCMDOptions
-= array(
- 'Query database from command line. Returns search result as JSON.',
- array('help', 'h', 0, 1, 0, 0, false, 'Show Help'),
- array('quiet', 'q', 0, 1, 0, 0, 'bool', 'Quiet output'),
- array('verbose', 'v', 0, 1, 0, 0, 'bool', 'Verbose output'),
-
- array('search', '', 0, 1, 1, 1, 'string', 'Search for given term or coordinate'),
- array('country', '', 0, 1, 1, 1, 'string', 'Structured search: country'),
- array('state', '', 0, 1, 1, 1, 'string', 'Structured search: state'),
- array('county', '', 0, 1, 1, 1, 'string', 'Structured search: county'),
- array('city', '', 0, 1, 1, 1, 'string', 'Structured search: city'),
- array('street', '', 0, 1, 1, 1, 'string', 'Structured search: street'),
- array('amenity', '', 0, 1, 1, 1, 'string', 'Structured search: amenity'),
- array('postalcode', '', 0, 1, 1, 1, 'string', 'Structured search: postal code'),
-
- array('accept-language', '', 0, 1, 1, 1, 'string', 'Preferred language order for showing search results'),
- array('bounded', '', 0, 1, 0, 0, 'bool', 'Restrict results to given viewbox'),
- array('nodedupe', '', 0, 1, 0, 0, 'bool', 'Do not remove duplicate results'),
- array('limit', '', 0, 1, 1, 1, 'int', 'Maximum number of results returned (default: 10)'),
- array('exclude_place_ids', '', 0, 1, 1, 1, 'string', 'Comma-separated list of place ids to exclude from results'),
- array('featureType', '', 0, 1, 1, 1, 'string', 'Restrict results to certain features (country, state,city,settlement)'),
- array('countrycodes', '', 0, 1, 1, 1, 'string', 'Comma-separated list of countries to restrict search to'),
- array('viewbox', '', 0, 1, 1, 1, 'string', 'Prefer results in given view box'),
-
- array('project-dir', '', 0, 1, 1, 1, 'realpath', 'Base directory of the Nominatim installation (default: .)'),
- );
-getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
-
-loadSettings($aCMDResult['project-dir'] ?? getcwd());
-
-@define('CONST_Database_DSN', getSetting('DATABASE_DSN'));
-@define('CONST_Default_Language', getSetting('DEFAULT_LANGUAGE', false));
-@define('CONST_Log_DB', getSettingBool('LOG_DB'));
-@define('CONST_Log_File', getSetting('LOG_FILE', false));
-@define('CONST_NoAccessControl', getSettingBool('CORS_NOACCESSCONTROL'));
-@define('CONST_Places_Max_ID_count', getSetting('LOOKUP_MAX_COUNT'));
-@define('CONST_PolygonOutput_MaximumTypes', getSetting('POLYGON_OUTPUT_MAX_TYPES'));
-@define('CONST_Search_BatchMode', getSettingBool('SEARCH_BATCH_MODE'));
-@define('CONST_Search_NameOnlySearchFrequencyThreshold', getSetting('SEARCH_NAME_ONLY_THRESHOLD'));
-@define('CONST_Use_US_Tiger_Data', getSettingBool('USE_US_TIGER_DATA'));
-@define('CONST_MapIcon_URL', getSetting('MAPICON_URL', false));
-@define('CONST_TokenizerDir', CONST_InstallDir.'/tokenizer');
-
-require_once(CONST_LibDir.'/Geocode.php');
-
-$oDB = new Nominatim\DB;
-$oDB->connect();
-
-if (isset($aCMDResult['nodedupe'])) $aCMDResult['dedupe'] = 'false';
-
-$oParams = new Nominatim\ParameterParser($aCMDResult);
-
-$aSearchParams = array(
- 'search',
- 'amenity',
- 'street',
- 'city',
- 'county',
- 'state',
- 'country',
- 'postalcode'
- );
-
-if (!$oParams->hasSetAny($aSearchParams)) {
- showUsage($aCMDOptions, true);
- return 1;
-}
-
-$oGeocode = new Nominatim\Geocode($oDB);
-
-$oGeocode->setLanguagePreference($oParams->getPreferredLanguages(false));
-$oGeocode->loadParamArray($oParams);
-
-if ($oParams->getBool('search')) {
- $oGeocode->setQuery($aCMDResult['search']);
-} else {
- $oGeocode->setQueryFromParams($oParams);
-}
-
-$aSearchResults = $oGeocode->lookup();
-
-echo json_encode($aSearchResults, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE)."\n";
Then place_addressline doesn't contain
| object | address |
| N1 | N2 |
- When searching for "Square"
+ When sending search query "Square"
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | Square, East Farm |
+ | osm | display_name |
+ | N1 | Square, East Farm |
Scenario: given two place nodes, the closer one wins for the address
Given the grid
And place_addressline doesn't contain
| object | address |
| W1 | R1 |
- When searching for "Bolder"
+ When sending search query "Bolder"
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | Bolder, Wonderway, Left |
+ | osm | display_name |
+ | N1 | Bolder, Wonderway, Left |
Scenario: addr:* tags do not produce addresslines when the parent has the address part
Given the grid
And place_addressline doesn't contain
| object | address |
| N1 | R1 |
- When searching for "Bolder"
+ When sending search query "Bolder"
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | Bolder, Wonderway, Outer |
+ | osm | display_name |
+ | N1 | Bolder, Wonderway, Outer |
Scenario: addr:* tags on outside do not produce addresslines when the parent has the address part
Given the grid
And place_addressline doesn't contain
| object | address |
| N1 | R1 |
- When searching for "Bolder"
+ When sending search query "Bolder"
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | Bolder, Wonderway, Left |
+ | osm | display_name |
+ | N1 | Bolder, Wonderway, Left |
Scenario: POIs can correct address parts on the fly
Given the grid
| object | address |
| N1 | R1 |
| N2 | R2 |
- When searching for "Bolder"
+ When sending search query "Bolder"
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | Bolder, Wonderway, Left |
- When searching for "Leftside"
+ | osm | display_name |
+ | N1 | Bolder, Wonderway, Left |
+ When sending search query "Leftside"
Then results contain
- | osm_type | osm_id | name |
- | N | 2 | Leftside, Wonderway, Right |
+ | osm | display_name |
+ | N2 | Leftside, Wonderway, Right |
| osm | class | type | name | geometry |
| N1 | place | town | Wenig | country:de |
When importing
- When searching for "Wenig, Loudou"
+ When sending search query "Wenig, Loudou"
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | Wenig, Deutschland |
- When searching for "Wenig"
+ | osm | display_name |
+ | N1 | Wenig, Deutschland |
+ When sending search query "Wenig"
| accept-language |
| xy,en |
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | Wenig, Loudou |
+ | osm | display_name |
+ | N1 | Wenig, Loudou |
Scenario: OSM country relations outside expected boundaries are ignored
Given the places
| osm | class | type | admin | name+name:xy | country | geometry |
| osm | class | type | name | geometry |
| N1 | place | town | Wenig | country:de |
When importing
- When searching for "Wenig"
+ When sending search query "Wenig"
| accept-language |
| xy,en |
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | Wenig, Germany |
+ | osm | display_name |
+ | N1 | Wenig, Germany |
Scenario: Pre-defined country names are used
Given the places
| osm | class | type | name | geometry |
| N1 | place | town | Ingb | country:ch |
When importing
- And searching for "Ingb"
+ And sending search query "Ingb"
| accept-language |
| en,de |
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | Ingb, Switzerland |
+ | osm | display_name |
+ | N1 | Ingb, Switzerland |
Then W11 expands to interpolation
| parent_place_id | start | end |
| W3 | 12 | 16 |
- When searching for "16 Cloud Street"
+ When sending search query "16 Cloud Street"
Then results contain
| ID | osm_type | osm_id |
| 0 | N | 4 |
- When searching for "14 Cloud Street"
+ When sending search query "14 Cloud Street"
Then results contain
| ID | osm_type | osm_id |
| 0 | W | 11 |
Then W11 expands to interpolation
| parent_place_id | start | end |
| W3 | 12 | 16 |
- When searching for "16 Cloud Street"
+ When sending search query "16 Cloud Street"
Then results contain
| ID | osm_type | osm_id |
| 0 | N | 4 |
- When searching for "14 Cloud Street"
+ When sending search query "14 Cloud Street"
Then results contain
| ID | osm_type | osm_id |
| 0 | W | 11 |
| W2 | R13 |
| R13 | - |
| R23 | - |
- When searching for "rhein"
+ When sending search query "rhein"
Then results contain
| osm_type |
| R |
| object | linked_place_id |
| W1 | - |
| R1 | - |
- When searching for "rhein"
+ When sending search query "rhein"
Then results contain
| ID | osm_type |
| 0 | R |
| object | linked_place_id |
| W1 | - |
| W2 | R1 |
- When searching for "rhein2"
+ When sending search query "rhein2"
Then results contain
| osm_type |
| W |
And placex contains
| object | rank_address |
| R13 | 16 |
- When searching for ""
+ When sending search query ""
| city |
| Berlin |
Then results contain
| ID | osm_type | osm_id |
| 0 | R | 13 |
- When searching for ""
+ When sending search query ""
| state |
| Berlin |
Then results contain
And placex contains
| object | rank_address |
| R13 | 8 |
- When searching for ""
+ When sending search query ""
| state |
| Berlin |
Then results contain
| ID | osm_type | osm_id |
| 0 | R | 13 |
- When searching for ""
+ When sending search query ""
| city |
| Berlin |
Then results contain
| object | parent_place_id |
| N1 | W1 |
| N2 | W1 |
- When searching for "4 galoo"
+ When sending search query "4 galoo"
Then results contain
- | ID | osm_type | osm_id | langaddress |
+ | ID | osm_type | osm_id | display_name |
| 0 | N | 1 | 4, galoo, 12345 |
- When searching for "5 galoo"
+ When sending search query "5 galoo"
Then results contain
- | ID | osm_type | osm_id | langaddress |
+ | ID | osm_type | osm_id | display_name |
| 0 | N | 2 | 5, galoo, 99999 |
Scenario: Address without tags, closest street
| country | postcode | geometry |
| gb | EH4 7EA | country:gb |
| gb | E4 7EA | country:gb |
- When searching for "EH4 7EA"
+ When sending search query "EH4 7EA"
Then results contain
- | type | placename |
+ | type | display_name |
| postcode | EH4 7EA |
- When searching for "E4 7EA"
+ When sending search query "E4 7EA"
Then results contain
- | type | placename |
+ | type | display_name |
| postcode | E4 7EA |
Then search_name contains
| object | nameaddress_vector |
| N1 | #Rose Street, Walltown |
- When searching for "23 Rose Street, Walltown"
+ When sending search query "23 Rose Street, Walltown"
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | 23, Rose Street |
- When searching for "Walltown, Rose Street 23"
+ | osm | display_name |
+ | N1 | 23, Rose Street |
+ When sending search query "Walltown, Rose Street 23"
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | 23, Rose Street |
- When searching for "Rose Street 23, Walltown"
+ | osm | display_name |
+ | N1 | 23, Rose Street |
+ When sending search query "Rose Street 23, Walltown"
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | 23, Rose Street |
+ | osm | display_name |
+ | N1 | 23, Rose Street |
Scenario: Searching for unknown addr: tags also works for multiple words
Given the scene roads-with-pois
Then search_name contains
| object | nameaddress_vector |
| N1 | #Rose Street, rose, Little, Big, Town |
- When searching for "23 Rose Street, Little Big Town"
+ When sending search query "23 Rose Street, Little Big Town"
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | 23, Rose Street |
- When searching for "Rose Street 23, Little Big Town"
+ | osm | display_name |
+ | N1 | 23, Rose Street |
+ When sending search query "Rose Street 23, Little Big Town"
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | 23, Rose Street |
- When searching for "Little big Town, Rose Street 23"
+ | osm | display_name |
+ | N1 | 23, Rose Street |
+ When sending search query "Little big Town, Rose Street 23"
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | 23, Rose Street |
+ | osm | display_name |
+ | N1 | 23, Rose Street |
Scenario: Unnamed POI has no search entry when it has known addr: tags
Given the scene roads-with-pois
| W1 | highway | residential | Rose Street | Walltown | :w-north |
When importing
Then search_name has no entry for N1
- When searching for "23 Rose Street, Walltown"
+ When sending search query "23 Rose Street, Walltown"
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | 23, Rose Street |
+ | osm | display_name |
+ | N1 | 23, Rose Street |
Scenario: Unnamed POI must have a house number to get a search entry
Given the scene roads-with-pois
Then search_name contains
| object | name_vector | nameaddress_vector |
| N1 | #Walltown | Strange, Town |
- When searching for "23 Rose Street"
+ When sending search query "23 Rose Street"
Then exactly 1 results are returned
And results contain
- | osm_type | osm_id | name |
- | W | 1 | Rose Street, Strange Town |
- When searching for "23 Walltown, Strange Town"
+ | osm | display_name |
+ | W1 | Rose Street, Strange Town |
+ When sending search query "23 Walltown, Strange Town"
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | 23, Walltown, Strange Town |
- When searching for "Walltown 23, Strange Town"
+ | osm | display_name |
+ | N1 | 23, Walltown, Strange Town |
+ When sending search query "Walltown 23, Strange Town"
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | 23, Walltown, Strange Town |
- When searching for "Strange Town, Walltown 23"
+ | osm | display_name |
+ | N1 | 23, Walltown, Strange Town |
+ When sending search query "Strange Town, Walltown 23"
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | 23, Walltown, Strange Town |
+ | osm | display_name |
+ | N1 | 23, Walltown, Strange Town |
Scenario: Named POIs can be searched by housenumber when unknown addr:place is present
Given the scene roads-with-pois
Then search_name contains
| object | name_vector | nameaddress_vector |
| N1 | #Walltown, #Blue house | Walltown, Strange, Town |
- When searching for "23 Walltown, Strange Town"
+ When sending search query "23 Walltown, Strange Town"
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | Blue house, 23, Walltown, Strange Town |
- When searching for "Walltown 23, Strange Town"
+ | osm | display_name |
+ | N1 | Blue house, 23, Walltown, Strange Town |
+ When sending search query "Walltown 23, Strange Town"
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | Blue house, 23, Walltown, Strange Town |
- When searching for "Strange Town, Walltown 23"
+ | osm | display_name |
+ | N1 | Blue house, 23, Walltown, Strange Town |
+ When sending search query "Strange Town, Walltown 23"
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | Blue house, 23, Walltown, Strange Town |
- When searching for "Strange Town, Walltown 23, Blue house"
+ | osm | display_name |
+ | N1 | Blue house, 23, Walltown, Strange Town |
+ When sending search query "Strange Town, Walltown 23, Blue house"
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | Blue house, 23, Walltown, Strange Town |
- When searching for "Strange Town, Walltown, Blue house"
+ | osm | display_name |
+ | N1 | Blue house, 23, Walltown, Strange Town |
+ When sending search query "Strange Town, Walltown, Blue house"
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | Blue house, 23, Walltown, Strange Town |
+ | osm | display_name |
+ | N1 | Blue house, 23, Walltown, Strange Town |
Scenario: Named POIs can be found when unknown multi-word addr:place is present
Given the scene roads-with-pois
Then search_name contains
| object | name_vector | nameaddress_vector |
| N1 | #Moon sun, #Blue house | Moon, Sun, Strange, Town |
- When searching for "23 Moon Sun, Strange Town"
+ When sending search query "23 Moon Sun, Strange Town"
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | Blue house, 23, Moon sun, Strange Town |
- When searching for "Blue house, Moon Sun, Strange Town"
+ | osm | display_name |
+ | N1 | Blue house, 23, Moon sun, Strange Town |
+ When sending search query "Blue house, Moon Sun, Strange Town"
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | Blue house, 23, Moon sun, Strange Town |
+ | osm | display_name |
+ | N1 | Blue house, 23, Moon sun, Strange Town |
Scenario: Unnamed POIs doesn't inherit parent name when addr:place is present only in parent address
Given the scene roads-with-pois
Then search_name contains
| object | name_vector | nameaddress_vector |
| N1 | #Walltown | Strange, Town |
- When searching for "23 Rose Street, Walltown"
+ When sending search query "23 Rose Street, Walltown"
Then exactly 1 result is returned
And results contain
- | osm_type | osm_id | name |
- | W | 1 | Rose Street, Strange Town |
- When searching for "23 Walltown"
+ | osm | display_name |
+ | W1 | Rose Street, Strange Town |
+ When sending search query "23 Walltown"
Then exactly 1 result is returned
And results contain
- | osm_type | osm_id | name |
- | N | 1 | 23, Walltown, Strange Town |
+ | osm | display_name |
+ | N1 | 23, Walltown, Strange Town |
Scenario: Unnamed POIs does inherit parent name when unknown addr:place and addr:street is present
Given the scene roads-with-pois
| W1 | highway | residential | Rose Street | :w-north |
When importing
Then search_name has no entry for N1
- When searching for "23 Rose Street"
+ When sending search query "23 Rose Street"
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | 23, Rose Street |
- When searching for "23 Lily Street"
+ | osm | display_name |
+ | N1 | 23, Rose Street |
+ When sending search query "23 Lily Street"
Then exactly 0 results are returned
Scenario: An unknown addr:street is ignored
| W1 | highway | residential | Rose Street | :w-north |
When importing
Then search_name has no entry for N1
- When searching for "23 Rose Street"
+ When sending search query "23 Rose Street"
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | 23, Rose Street |
- When searching for "23 Lily Street"
+ | osm | display_name |
+ | N1 | 23, Rose Street |
+ When sending search query "23 Lily Street"
Then exactly 0 results are returned
Scenario: Named POIs get unknown address tags added in the search_name table
Then search_name contains
| object | name_vector | nameaddress_vector |
| N1 | #Green Moss | #Rose Street, Walltown |
- When searching for "Green Moss, Rose Street, Walltown"
+ When sending search query "Green Moss, Rose Street, Walltown"
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | Green Moss, 26, Rose Street |
- When searching for "Green Moss, 26, Rose Street, Walltown"
+ | osm | display_name |
+ | N1 | Green Moss, 26, Rose Street |
+ When sending search query "Green Moss, 26, Rose Street, Walltown"
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | Green Moss, 26, Rose Street |
- When searching for "26, Rose Street, Walltown"
+ | osm | display_name |
+ | N1 | Green Moss, 26, Rose Street |
+ When sending search query "26, Rose Street, Walltown"
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | Green Moss, 26, Rose Street |
- When searching for "Rose Street 26, Walltown"
+ | osm | display_name |
+ | N1 | Green Moss, 26, Rose Street |
+ When sending search query "Rose Street 26, Walltown"
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | Green Moss, 26, Rose Street |
- When searching for "Walltown, Rose Street 26"
+ | osm | display_name |
+ | N1 | Green Moss, 26, Rose Street |
+ When sending search query "Walltown, Rose Street 26"
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | Green Moss, 26, Rose Street |
+ | osm | display_name |
+ | N1 | Green Moss, 26, Rose Street |
Scenario: Named POI doesn't inherit parent name when addr:place is present only in parent address
Given the scene roads-with-pois
Then search_name contains
| object | name_vector | nameaddress_vector |
| N1 | #Green Moss | Walltown |
- When searching for "Green Moss, Rose Street, Walltown"
+ When sending search query "Green Moss, Rose Street, Walltown"
Then exactly 0 result is returned
- When searching for "Green Moss, Walltown"
+ When sending search query "Green Moss, Walltown"
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | Green Moss, Walltown, Strange Town |
+ | osm | display_name |
+ | N1 | Green Moss, Walltown, Strange Town |
Scenario: Named POIs inherit address from parent
Given the scene roads-with-pois
Then placex contains
| object | class | type | name+name |
| N1 | place | locality | FooBar |
- When searching for "FooBar"
+ When sending search query "FooBar"
Then results contain
- | ID | osm_type | osm_id |
- | 0 | N | 1 |
- When searching for "foobar"
+ | ID | osm |
+ | 0 | N1 |
+ When sending search query "foobar"
Then results contain
- | ID | osm_type | osm_id |
- | 0 | N | 1 |
- When searching for "fOObar"
+ | ID | osm |
+ | 0 | N1 |
+ When sending search query "fOObar"
Then results contain
- | ID | osm_type | osm_id |
- | 0 | N | 1 |
- When searching for "FOOBAR"
+ | ID | osm |
+ | 0 | N1 |
+ When sending search query "FOOBAR"
Then results contain
- | ID | osm_type | osm_id |
- | 0 | N | 1 |
+ | ID | osm |
+ | 0 | N1 |
Scenario: Multiple spaces in name
Given the places
| osm | class | type | name |
| N1 | place | locality | one two three |
When importing
- When searching for "one two three"
+ When sending search query "one two three"
Then results contain
- | ID | osm_type | osm_id |
- | 0 | N | 1 |
- When searching for "one two three"
+ | ID | osm |
+ | 0 | N1 |
+ When sending search query "one two three"
Then results contain
- | ID | osm_type | osm_id |
- | 0 | N | 1 |
- When searching for "one two three"
+ | ID | osm |
+ | 0 | N1 |
+ When sending search query "one two three"
Then results contain
- | ID | osm_type | osm_id |
- | 0 | N | 1 |
- When searching for " one two three"
+ | ID | osm |
+ | 0 | N1 |
+ When sending search query " one two three"
Then results contain
- | ID | osm_type | osm_id |
- | 0 | N | 1 |
+ | ID | osm |
+ | 0 | N1 |
Scenario: Special characters in name
Given the places
| N4 | place | locality | space |
| N5 | place | locality | mountain |
When importing
- When searching for "Jim-Knopf-Str"
+ When sending search query "Jim-Knopf-Str"
Then results contain
- | ID | osm_type | osm_id |
- | 0 | N | 1 |
- When searching for "Jim Knopf-Str"
+ | ID | osm |
+ | 0 | N1 |
+ When sending search query "Jim Knopf-Str"
Then results contain
- | ID | osm_type | osm_id |
- | 0 | N | 1 |
- When searching for "Jim Knopf Str"
+ | ID | osm |
+ | 0 | N1 |
+ When sending search query "Jim Knopf Str"
Then results contain
- | ID | osm_type | osm_id |
- | 0 | N | 1 |
- When searching for "Jim/Knopf-Str"
+ | ID | osm |
+ | 0 | N1 |
+ When sending search query "Jim/Knopf-Str"
Then results contain
- | ID | osm_type | osm_id |
- | 0 | N | 1 |
- When searching for "Jim-Knopfstr"
+ | ID | osm |
+ | 0 | N1 |
+ When sending search query "Jim-Knopfstr"
Then results contain
- | ID | osm_type | osm_id |
- | 0 | N | 1 |
- When searching for "Smith/Weston"
+ | ID | osm |
+ | 0 | N1 |
+ When sending search query "Smith/Weston"
Then results contain
- | ID | osm_type | osm_id |
- | 0 | N | 2 |
- When searching for "Smith Weston"
+ | ID | osm |
+ | 0 | N2 |
+ When sending search query "Smith Weston"
Then results contain
- | ID | osm_type | osm_id |
- | 0 | N | 2 |
- When searching for "Smith-Weston"
+ | ID | osm |
+ | 0 | N2 |
+ When sending search query "Smith-Weston"
Then results contain
- | ID | osm_type | osm_id |
- | 0 | N | 2 |
- When searching for "space mountain"
+ | ID | osm |
+ | 0 | N2 |
+ When sending search query "space mountain"
Then results contain
- | ID | osm_type | osm_id |
- | 0 | N | 3 |
- When searching for "space-mountain"
+ | ID | osm |
+ | 0 | N3 |
+ When sending search query "space-mountain"
Then results contain
- | ID | osm_type | osm_id |
- | 0 | N | 3 |
- When searching for "space/mountain"
+ | ID | osm |
+ | 0 | N3 |
+ When sending search query "space/mountain"
Then results contain
- | ID | osm_type | osm_id |
- | 0 | N | 3 |
- When searching for "space\mountain"
+ | ID | osm |
+ | 0 | N3 |
+ When sending search query "space\mountain"
Then results contain
- | ID | osm_type | osm_id |
- | 0 | N | 3 |
- When searching for "space(mountain)"
+ | ID | osm |
+ | 0 | N3 |
+ When sending search query "space(mountain)"
Then results contain
- | ID | osm_type | osm_id |
- | 0 | N | 3 |
+ | ID | osm |
+ | 0 | N3 |
Scenario: Landuse with name are found
Given the places
| R1 | natural | meadow | landuse1 | (0 0, 1 0, 1 1, 0 1, 0 0) |
| R2 | landuse | industrial | landuse2 | (0 0, -1 0, -1 -1, 0 -1, 0 0) |
When importing
- When searching for "landuse1"
+ When sending search query "landuse1"
Then results contain
- | ID | osm_type | osm_id |
- | 0 | R | 1 |
- When searching for "landuse2"
+ | ID | osm |
+ | 0 | R1 |
+ When sending search query "landuse2"
Then results contain
- | ID | osm_type | osm_id |
- | 0 | R | 2 |
+ | ID | osm |
+ | 0 | R2 |
Scenario: Postcode boundaries without ref
Given the places
| osm | class | type | postcode | geometry |
| R1 | boundary | postal_code | 12345 | (0 0, 1 0, 1 1, 0 1, 0 0) |
When importing
- When searching for "12345"
+ When sending search query "12345"
Then results contain
- | ID | osm_type | osm_id |
- | 0 | R | 1 |
+ | ID | osm |
+ | 0 | R1 |
Scenario: Unprintable characters in postcodes are ignored
Given the named places
| osm | class | type | address |
| N234 | amenity | prison | 'postcode' : u'1234\u200e' |
When importing
- And searching for "1234"
- Then results contain
- | ID | osm_type |
- | 0 | P |
+ And sending search query "1234"
+ Then result 0 has not attributes osm_type
Scenario Outline: Housenumbers with special characters are found
Given the grid
| osm | class | type | housenr | geometry |
| N1 | building | yes | <nr> | 9 |
When importing
- And searching for "Main St <nr>"
+ And sending search query "Main St <nr>"
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | <nr>, Main St |
+ | osm | display_name |
+ | N1 | <nr>, Main St |
Examples:
| nr |
| osm | class | type | housenr | geometry |
| N1 | building | yes | <nr-list> | 9 |
When importing
- And searching for "Main St <nr>"
+ And sending search query "Main St <nr>"
Then results contain
- | osm_type | osm_id | name |
- | N | 1 | <nr-list>, Main St |
+ | osm | display_name |
+ | N1 | <nr-list>, Main St |
Examples:
| nr-list | nr |
| osm | class | type | name+name | geometry |
| N1 | place | village | Foo | 10.0 -10.0 |
When importing
- And searching for "Foo"
+ And sending search query "Foo"
Then results contain
- | ID | osm | class | type | centroid |
- | 0 | N1 | place | village | 10 -10 |
+ | ID | osm | category | type | centroid |
+ | 0 | N1 | place | village | 10 -10 |
Scenario: Updating postcode in postcode boundaries without ref
Given the places
| osm | class | type | postcode | geometry |
| R1 | boundary | postal_code | 12345 | poly-area:1.0 |
When importing
- And searching for "12345"
+ And sending search query "12345"
Then results contain
- | ID | osm_type | osm_id |
- | 0 | R | 1 |
+ | ID | osm |
+ | 0 | R1 |
When updating places
| osm | class | type | postcode | geometry |
| R1 | boundary | postal_code | 54321 | poly-area:1.0 |
- And searching for "12345"
+ And sending search query "12345"
+ Then result 0 has not attributes osm_type
+ When sending search query "54321"
Then results contain
- | osm_type |
- | P |
- When searching for "54321"
- Then results contain
- | ID | osm_type | osm_id |
- | 0 | R | 1 |
+ | ID | osm |
+ | 0 | R1 |
# github #1763
Scenario: Correct translation of highways under construction
| osm | class | type | name | admin | geometry |
| R1 | boundary | administrative | foo | 8 | poly-area:0.1 |
When importing
- And searching for "foo" with dups
+ And sending search query "foo"
+ | dups |
+ | 1 |
Then results contain
| osm_type |
| R |
Then placex contains
| object | linked_place_id |
| N1 | - |
- When searching for "foo" with dups
+ When sending search query "foo"
+ | dups |
+ | 1 |
Then results contain
| osm_type |
| N |
| osm | class | type | name | admin | geometry |
| R1 | boundary | administrative | foo | 8 | poly-area:0.1 |
When importing
- And searching for "foo" with dups
+ And sending search query "foo"
+ | dups |
+ | 1 |
Then results contain
| osm_type |
| R |
Then placex contains
| object | linked_place_id |
| N1 | - |
- When searching for "foo" with dups
+ When sending search query "foo"
+ | dups |
+ | 1 |
Then results contain
| osm_type |
| N |
| osm | class | type | name | geometry |
| N1 | place | city | foo | 0 0 |
When importing
- And searching for "foo" with dups
+ And sending search query "foo"
+ | dups |
+ | 1 |
Then results contain
| osm_type |
| N |
Then placex contains
| object | linked_place_id |
| N1 | R1 |
- When searching for "foo" with dups
+ When sending search query "foo"
+ | dups |
+ | 1 |
Then results contain
| osm_type |
| R |
| osm | class | type | name | admin | geometry |
| R1 | boundary | administrative | foobar | 8 | poly-area:0.1 |
When importing
- And searching for "foo" with dups
+ And sending search query "foo"
+ | dups |
+ | 1 |
Then results contain
| osm_type |
| N |
Then placex contains
| object | linked_place_id |
| N1 | R1 |
- When searching for "foo" with dups
+ When sending search query "foo"
+ | dups |
+ | 1 |
Then results contain
| osm_type |
| R |
| osm | class | type | postcode | geometry |
| R1 | boundary | postal_code | 12345 | poly-area:0.5 |
When importing
- And searching for "12345"
+ And sending search query "12345"
Then results contain
- | ID | osm_type | osm_id |
- | 0 | R | 1 |
+ | ID | osm |
+ | 0 | R1 |
When updating places
| osm | class | type | geometry |
| R1 | boundary | postal_code | poly-area:0.5 |
from check_functions import Almost
-OSM_TYPE = {'N' : 'node', 'W' : 'way', 'R' : 'relation'}
+OSM_TYPE = {'N' : 'node', 'W' : 'way', 'R' : 'relation',
+ 'n' : 'node', 'w' : 'way', 'r' : 'relation',
+ 'node' : 'n', 'way' : 'w', 'relation' : 'r'}
def _geojson_result_to_json_result(geojson_result):
result = geojson_result['properties']
assert self.result[i]['osm_type'] in (OSM_TYPE[value[0]], value[0]), \
BadRowValueAssert(self, i, 'osm_type', value)
self.assert_field(i, 'osm_id', value[1:])
+ elif name == 'osm_type':
+ assert self.result[i]['osm_type'] in (OSM_TYPE[value[0]], value[0]), \
+ BadRowValueAssert(self, i, 'osm_type', value)
elif name == 'centroid':
lon, lat = value.split(' ')
self.assert_field(i, 'lat', float(lat))
raise Exception("unknown operator '%s'" % operator)
-@when(u'searching for "(?P<query>.*)"(?P<dups> with dups)?')
-def query_cmd(context, query, dups):
- """ Query directly via PHP script.
- """
- cmd = ['/usr/bin/env', 'php']
- cmd.append(context.nominatim.src_dir / 'lib-php' / 'admin' / 'query.php')
- if query:
- cmd.extend(['--search', query])
- # add more parameters in table form
- if context.table:
- for h in context.table.headings:
- value = context.table[0][h].strip()
- if value:
- cmd.extend(('--' + h, value))
-
- if dups:
- cmd.extend(('--dedupe', '0'))
-
- outp, err = run_script(cmd, cwd=context.nominatim.website_dir.name,
- env=context.nominatim.test_env)
-
- context.response = SearchResponse(outp, 'json')
-
def send_api_query(endpoint, params, fmt, context):
if fmt is not None and fmt.strip() != 'debug':
params['format'] = fmt.strip()