public static WeightVectorLabel TranslateLabel(PlanElementType type) { switch (type) { case PlanElementType.Activity: return(WeightVectorLabel.Activity); case PlanElementType.Culture: return(WeightVectorLabel.Culture); case PlanElementType.Entertainment: return(WeightVectorLabel.Entertainment); case PlanElementType.Partying: return(WeightVectorLabel.Partying); case PlanElementType.Relax: return(WeightVectorLabel.Relax); case PlanElementType.Shopping: return(WeightVectorLabel.Shopping); case PlanElementType.Sightseeing: default: return(WeightVectorLabel.Sightseeing); } }
public PlanElementCandidate Pick(IList <PlanElementCandidate> candidates, PlanElementType planElementType) { return(null); //if (candidates.Any(x => x.ElementType == planElementType)) // return candidates.First(x => x.ElementType == planElementType); //else // return candidates.First(x => x.ElementType == PlanElementType.Nothing); //default start from accomodation }
public PlanElementDecision(PlanElementType elementType) { ElementType = elementType; }
public PlanElementyTypeEntity(PlanElementType elementType) { ElementType = elementType; }
public async Task <IList <PlanElementCandidate> > GetCandidates(Plan plan, WeightVector weightVector) { var test = true; var candidates = new List <PlanElementCandidate>(); PlanElementType[] planElementTypes = new PlanElementType[] { PlanElementType.Entertainment, PlanElementType.Relax, PlanElementType.Activity, PlanElementType.Culture, PlanElementType.Sightseeing, PlanElementType.Partying, PlanElementType.Shopping, }; foreach (var planElementType in planElementTypes) { var googlePlaceTypes = GooglePlaceTypes.Table.Where(x => x.PlanElementType == planElementType).ToList(); foreach (var type in googlePlaceTypes) { var nearbySearchInput = _googlePlaceNearbySearchInputFactory.Create(plan.StartLocation, (int)MaximumDistanceToAccomodation, type); var nearbyResults = await _googlePlaceNearbySearchApiClient.GetAsync(nearbySearchInput); int counter = 1; foreach (var nr in nearbyResults.results) { var details = await _googlePlaceDetailsApiClient.GetAsync(_googlePlaceDetailsInputFactory.CreateAllUseful(nr.place_id)); if (details.IsOk) { var candidate = new PlanElementCandidate(details.Result.name, details.Result.place_id, details.Result.formatted_address, details.Result.geometry.location, details.Result.opening_hours, details.Result.types, details.Result.rating, details.Result.price_level, details.Result.user_ratings_total); if (!candidates.Any(x => x.PlaceId == candidate.PlaceId)) { candidates.Add(candidate); } } ++counter; } if (test && candidates.Count > 15) { return(candidates); } WeightVectorLabel weightVectorLabel = WeightVector.TranslateLabel(planElementType); if ((plan.PlanForm.IsOverOneWeek || weightVector.GetLabelValue(weightVectorLabel) >= 0.1m) && nearbyResults.IsMoreResults) { var nearbyResults2 = await _googlePlaceNearbySearchApiClient.GetNextPageTokenAsync(nearbyResults.next_page_token); foreach (var nr in nearbyResults2.results) { var details = await _googlePlaceDetailsApiClient.GetAsync(_googlePlaceDetailsInputFactory.CreateAllUseful(nr.place_id)); if (details.IsOk) { var candidate = new PlanElementCandidate(details.Result.name, details.Result.place_id, details.Result.formatted_address, details.Result.geometry.location, details.Result.opening_hours, details.Result.types, details.Result.rating, details.Result.price_level, details.Result.user_ratings_total); if (!candidates.Any(x => x.PlaceId == candidate.PlaceId)) { candidates.Add(candidate); } } ++counter; } } if (test && candidates.Count > 15) { return(candidates); } } if (test && candidates.Count > 15) { break; } } if (candidates.Count == 0) { throw new UserFriendlyException($"Nie znaleziono żadnych potencjalnych kandydatów na elementy planu"); } return(candidates); }
public PlanElement(string placeName, string placeId, string formattedAddress, DateTime start, DateTime end, double lat, double lng, int orderNo, decimal?rating, decimal?price, decimal?popularity, PlanElementType type) { PlaceName = placeName; PlaceId = placeId; Start = start; End = end; FormattedAddress = formattedAddress; Lat = lat; Lng = lng; OrderNo = orderNo; Rating = rating; Price = price; Popularity = popularity; ScorePosition = 0; NormalizedScore = 0; PlanElementTypes = new List <PlanElementyTypeEntity>(); PlanElementTypes.Add(new PlanElementyTypeEntity(type)); OpeningHours = new List <PlanElementOpeningHourEntity>(); }