forked from organicmaps/organicmaps
[booking] Fix the matching function
This commit is contained in:
parent
a55c1a47d6
commit
bef32bcb75
2 changed files with 15 additions and 3 deletions
|
@ -257,11 +257,20 @@ bool BookingDataset::MatchWithBooking(OsmElement const & e) const
|
|||
return false;
|
||||
|
||||
// Find 3 nearest values to a point.
|
||||
auto const indexes = GetNearestHotels(e.lat, e.lon, 3, 150 /* max distance in meters */);
|
||||
if (indexes.empty())
|
||||
auto const bookingIndexes = GetNearestHotels(e.lat, e.lon, 3, kDistanceLimitInMeters);
|
||||
if (bookingIndexes.empty())
|
||||
return false;
|
||||
|
||||
bool matched = MatchByName(name, indexes);
|
||||
bool matched = false;
|
||||
|
||||
for (size_t const j : bookingIndexes)
|
||||
{
|
||||
auto const & hotel = GetHotel(j);
|
||||
double const dist = ms::DistanceOnEarth(e.lat, e.lon, hotel.lat, hotel.lon);
|
||||
double score = (kDistanceLimitInMeters - dist) / kDistanceLimitInMeters;
|
||||
matched = score > kOptimalThreshold;
|
||||
}
|
||||
|
||||
return matched;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,9 @@ namespace generator
|
|||
class BookingDataset
|
||||
{
|
||||
public:
|
||||
double static constexpr kDistanceLimitInMeters = 150;
|
||||
double static constexpr kOptimalThreshold = 0.709283;
|
||||
|
||||
struct Hotel
|
||||
{
|
||||
enum class Fields
|
||||
|
|
Loading…
Add table
Reference in a new issue