}
foreach ($aLanguages as $sLanguage => $fLanguagePref) {
- $aLangPrefOrder['name:'.$sLanguage] = 'name:'.$sLanguage;
+ $this->addNameTag($aLangPrefOrder, 'name:'.$sLanguage);
}
- $aLangPrefOrder['name'] = 'name';
- $aLangPrefOrder['brand'] = 'brand';
+ $this->addNameTag($aLangPrefOrder, 'name');
+ $this->addNameTag($aLangPrefOrder, 'brand');
foreach ($aLanguages as $sLanguage => $fLanguagePref) {
- $aLangPrefOrder['official_name:'.$sLanguage] = 'official_name:'.$sLanguage;
- $aLangPrefOrder['short_name:'.$sLanguage] = 'short_name:'.$sLanguage;
+ $this->addNameTag($aLangPrefOrder, 'official_name:'.$sLanguage);
+ $this->addNameTag($aLangPrefOrder, 'short_name:'.$sLanguage);
}
- $aLangPrefOrder['official_name'] = 'official_name';
- $aLangPrefOrder['short_name'] = 'short_name';
- $aLangPrefOrder['ref'] = 'ref';
- $aLangPrefOrder['type'] = 'type';
+ $this->addNameTag($aLangPrefOrder, 'official_name');
+ $this->addNameTag($aLangPrefOrder, 'short_name');
+ $this->addNameTag($aLangPrefOrder, 'ref');
+ $this->addNameTag($aLangPrefOrder, 'type');
return $aLangPrefOrder;
}
+ private function addNameTag(&$aLangPrefOrder, $sTag) {
+ $aLangPrefOrder[$sTag] = $sTag;
+ $aLangPrefOrder['_place_'.$sTag] = '_place_'.$sTag;
+ }
+
public function hasSetAny($aParamNames)
{
foreach ($aParamNames as $sName) {
FROM each(location.name - result.name);
{% if debug %}RAISE WARNING 'Extra names: %', extra_names;{% endif %}
- result.name := location.name || result.name || extra_names;
+ IF extra_names is not null THEN
+ result.name := result.name || extra_names;
+ END IF;
+
{% if debug %}RAISE WARNING 'Final names: %', result.name;{% endif %}
END IF;
END IF;
| N2 | R13 |
When sending search query "Vario"
Then results contain
- | osm |
- | R13 |
+ | osm | display_name |
+ | R13 | Garbo |
+ When sending search query "Vario"
+ | accept-language |
+ | it |
+ Then results contain
+ | osm | display_name |
+ | R13 | Vario |
Scenario: Differing names from linked places are searchable
| N2 | R13 |
When sending search query "Vario"
Then results contain
- | osm |
- | R13 |
+ | osm | display_name |
+ | R13 | Garbo |
+ When sending search query "Garbo"
+ Then results contain
+ | osm | display_name |
+ | R13 | Garbo |
| 1 | N3:label |
When importing
Then placex contains
- | object | linked_place_id | name+name:de |
+ | object | linked_place_id | name+_place_name:de |
| R1 | - | pnt |
+ And placex contains
+ | object | linked_place_id | name+name:de |
| N3 | R1 | pnt |
When updating places
| osm | class | type | name+name:de | admin | geometry |
Then placex contains
| object | linked_place_id | name+name:de |
| N3 | R1 | newname |
+ And placex contains
+ | object | linked_place_id | name+_place_name:de |
| R1 | - | newname |
+ Scenario: Update linking relation when linkee name is deleted
+ Given the places
+ | osm | class | type | name | admin | geometry |
+ | R1 | boundary | administrative | rel | 8 | poly-area:0.1 |
+ And the places
+ | osm | class | type | name | admin | geometry |
+ | N3 | place | city | pnt | 30 | 0.00001 0 |
+ And the relations
+ | id | members |
+ | 1 | N3:label |
+ When importing
+ Then placex contains
+ | object | linked_place_id | name+_place_name | name+name |
+ | R1 | - | pnt | rel |
+ And placex contains
+ | object | linked_place_id | name+name |
+ | N3 | R1 | pnt |
+ When sending search query "pnt"
+ Then results contain
+ | osm |
+ | R1 |
+ When updating places
+ | osm | class | type | name+name:de | admin | geometry |
+ | N3 | place | city | depnt | 30 | 0.00001 0 |
+ Then placex contains
+ | object | linked_place_id | name+name:de |
+ | N3 | R1 | depnt |
+ And placex contains
+ | object | linked_place_id | name+_place_name:de | name+name |
+ | R1 | - | depnt | rel |
+ When sending search query "pnt"
+ Then exactly 0 results are returned
+
Scenario: Updating linkee extratags keeps linker's extratags
Given the named places
| osm | class | type | extra+wikidata | admin | geometry |
if errorcode == 200 and fmt != 'debug':
getattr(self, '_parse_' + fmt)()
- else:
- print("Bad response: ", page)
def _parse_json(self):
m = re.fullmatch(r'([\w$][^(]*)\((.*)\)', self.page)
self.header['json_func'] = m.group(1)
self.result = json.JSONDecoder(object_pairs_hook=OrderedDict).decode(code)
if isinstance(self.result, OrderedDict):
- self.result = [self.result]
+ if 'error' in self.result:
+ self.result = []
+ else:
+ self.result = [self.result]
def _parse_geojson(self):
self._parse_json()
- if 'error' in self.result[0]:
- self.result = []
- else:
+ if self.result:
self.result = list(map(_geojson_result_to_json_result, self.result[0]['features']))
def _parse_geocodejson(self):