mirror of
https://github.com/osm-search/Nominatim.git
synced 2024-12-25 22:12:45 +03:00
adjust secondary order when no addressimportance available
In cases of countries and remote places without an address it is possible that 'addressimportance' comes back empty. Adjust the 'foundorder' to the places importance instead in such cases. Fixes #2023.
This commit is contained in:
parent
b012e15245
commit
788ba6d985
@ -917,6 +917,24 @@ class Geocode
|
||||
$aResult['lon'],
|
||||
$aResult['lat']
|
||||
);
|
||||
|
||||
// secondary ordering (for results with same importance (the smaller the better):
|
||||
// - approximate importance of address parts
|
||||
if (isset($aResult['addressimportance']) && $aResult['addressimportance']) {
|
||||
$aResult['foundorder'] = -$aResult['addressimportance']/10;
|
||||
} else {
|
||||
$aResult['foundorder'] = -$aResult['importance'];
|
||||
}
|
||||
// - number of exact matches from the query
|
||||
$aResult['foundorder'] -= $aResults[$aResult['place_id']]->iExactMatches;
|
||||
// - importance of the class/type
|
||||
$iClassImportance = ClassTypes\getImportance($aResult);
|
||||
if (isset($iClassImportance)) {
|
||||
$aResult['foundorder'] += 0.0001 * $iClassImportance;
|
||||
} else {
|
||||
$aResult['foundorder'] += 0.01;
|
||||
}
|
||||
|
||||
// Adjust importance for the number of exact string matches in the result
|
||||
$iCountWords = 0;
|
||||
$sAddress = $aResult['langaddress'];
|
||||
@ -927,20 +945,8 @@ class Geocode
|
||||
}
|
||||
}
|
||||
|
||||
$aResult['importance'] = $aResult['importance'] + ($iCountWords*0.1); // 0.1 is a completely arbitrary number but something in the range 0.1 to 0.5 would seem right
|
||||
|
||||
// secondary ordering (for results with same importance (the smaller the better):
|
||||
// - approximate importance of address parts
|
||||
$aResult['foundorder'] = -$aResult['addressimportance']/10;
|
||||
// - number of exact matches from the query
|
||||
$aResult['foundorder'] -= $aResults[$aResult['place_id']]->iExactMatches;
|
||||
// - importance of the class/type
|
||||
$iClassImportance = ClassTypes\getImportance($aResult);
|
||||
if (isset($iClassImportance)) {
|
||||
$aResult['foundorder'] += 0.0001 * $iClassImportance;
|
||||
} else {
|
||||
$aResult['foundorder'] += 0.01;
|
||||
}
|
||||
// 0.1 is a completely arbitrary number but something in the range 0.1 to 0.5 would seem right
|
||||
$aResult['importance'] = $aResult['importance'] + ($iCountWords*0.1);
|
||||
}
|
||||
$aSearchResults[$iIdx] = $aResult;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user