VisitedCity previousInferredCity = null, nextInferredCity = null;
if (cities.size()==0) {
previousInferredCity = searchCityBeforeDate(guestId, dates.first());
nextInferredCity = searchCityAfterDate(guestId, dates.last());
if (previousInferredCity==null && nextInferredCity==null) {
MonthMetadata info = new MonthMetadata(year, month);
return info;
}
}
final VisitedCity consensusVisitedCity = getConsensusVisitedCity(cities, previousInferredCity, nextInferredCity);
final List<DayMetadata> dayMetadataForDates = getDayMetadataForDates(guestId, dates);
final TreeMap<String, TimeZone> consensusTimezoneMap = getConsensusTimezoneMap(dayMetadataForDates);
final List<VisitedCity> consensusCities = extractConsensusCities(dayMetadataForDates);
TimezoneMap timezoneMap = TimezoneMap.fromConsensusTimezoneMap(consensusTimezoneMap);
MonthMetadata info = new MonthMetadata(consensusVisitedCity, previousInferredCity, nextInferredCity, consensusTimezoneMap, timezoneMap, cities, consensusCities, year, month);
return info;
}