@Override
public ArbitraryTimespanMetadata getArbitraryTimespanMetadata(final long guestId, final long start, final long end) {
final TreeSet<String> dates = getDatesBetween(start, end);
List<VisitedCity> cities = getVisitedCitiesForDates(guestId, dates);
VisitedCity previousInferredCity = null, nextInferredCity = null;
if (cities.size()==0) {
previousInferredCity = searchCityBeforeDate(guestId, dates.first());
nextInferredCity = searchCityAfterDate(guestId, dates.last());
if (previousInferredCity==null&&nextInferredCity==null) {
ArbitraryTimespanMetadata info = new ArbitraryTimespanMetadata(start, end);
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);
ArbitraryTimespanMetadata info = new ArbitraryTimespanMetadata(consensusVisitedCity, previousInferredCity, nextInferredCity, consensusTimezoneMap, timezoneMap, cities, consensusCities, start, end);