[booking] Fix the matching function

This commit is contained in:
Sergey Yershov 2016-05-31 15:19:53 +03:00
parent a55c1a47d6
commit bef32bcb75
2 changed files with 15 additions and 3 deletions

View file

@ -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;
}

View file

@ -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