public ScenicSuggestionResults GenerateSuggestions(
            GalacticSystem from,
            GalacticSystem to,
            float acceptableExtraDistance)
        {
            if (DistanceFromSol(to.Coordinates) < bubbleIgnoreRadius && DistanceFromSol(from.Coordinates) < bubbleIgnoreRadius)
            {
                // Warn user that their trip is very close to Earth and we won't have any useful POI suggestions!
                throw new TripWithinBubbleException();
            }
            var originalDistance = DistanceBetweenPoints(from, to);
            var edsmSuggestions  = SuggestionsForList(POIs.Where(p => (int)p.Type < 100));
            var codexSuggestions = SuggestionsForList(POIs.Where(p => (int)p.Type >= 100));

            return(new ScenicSuggestionResults()
            {
                StraightLineDistance = originalDistance,
                Suggestions = edsmSuggestions.Concat(codexSuggestions).ToList()
            });

            List <ScenicSuggestion> SuggestionsForList(IEnumerable <GalacticPOI> pois)
            {
                return(pois.
                       Where(p => p.DistanceFromSol > bubbleIgnoreRadius). // Ignore the "bubble" of near-Earth POIs
                       Select(p =>
                {
                    var result = ExtraDistanceIncurred(@from, to, p, originalDistance);
                    return new ScenicSuggestion(p, result.extraDistance, result.percentageAlongRoute);
                }).
                       Where(ss => ss.ExtraDistance <= acceptableExtraDistance && ss.ExtraDistance > 0f).
                       OrderBy(ss => ss.ExtraDistance).
                       Take(MAX_SUGGESTIONS / 2).
                       ToList());
            }
        }
Esempio n. 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            POIs pOIs = db.POIs.Find(id);

            db.POIs.Remove(pOIs);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 3
0
 public ActionResult Edit([Bind(Include = "PlaceId,Name,Theme,SubTheme,Address,Latitude,Longitude,Category")] POIs pOIs)
 {
     if (ModelState.IsValid)
     {
         db.Entry(pOIs).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(pOIs));
 }
Esempio n. 4
0
        public ActionResult Create([Bind(Include = "PlaceId,Name,Theme,SubTheme,Address,Latitude,Longitude,Category")] POIs pOIs)
        {
            if (ModelState.IsValid)
            {
                db.POIs.Add(pOIs);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(pOIs));
        }
Esempio n. 5
0
        // GET: POIs/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            POIs pOIs = db.POIs.Find(id);

            if (pOIs == null)
            {
                return(HttpNotFound());
            }
            return(View(pOIs));
        }
Esempio n. 6
0
        private void SubscribeToMessages()
        {
            //Since this class manages normalisation, when a dose object is imported into the program set the relevant normalisation type
            MessengerInstance.Register <RTObjectAddedMessage <DicomDoseObject> >(this, x => {
                x.Value.Grid.NormalisationPercent        = RenderOptions.NormalisationIsodose;
                x.Value.Grid.NormalisationPOI            = RenderOptions.POI;
                x.Value.Grid.NormalisationType           = RenderOptions.NormalisationType;
                x.Value.Grid.RelativeNormalisationOption = RenderOptions.RelativeNormalisationOption;
            });

            MessengerInstance.Register <RTObjectAddedMessage <PointOfInterest> >(this, x =>
            {
                POIs.Add(x.Value);
                if (POIs.Count == 1)
                {
                    RenderOptions.POI = x.Value;
                }
            });
        }
Esempio n. 7
0
 public void RemovePOI(PointOfInterest poi)
 {
     POIs.Remove(poi);
 }
Esempio n. 8
0
 public void AddPOI(PointOfInterest poi)
 {
     POIs.Add(poi);
 }
Esempio n. 9
0
        public async Task <bool> ExecuteLoadTripCommandAsync(string id)
        {
            if (IsBusy)
            {
                return(false);
            }

            ProgressDialogManager.LoadProgressDialog("Loading trip details...");

            bool   error        = false;
            string errorMessage = "Please check internet connection and try again.";

            try
            {
                IsBusy = true;
                if (Trip == null)
                {
                    Trip = await StoreManager.TripStore.GetItemAsync(id);
                }

                Trip.Points = new List <TripPoint>(await StoreManager.TripPointStore.GetPointsForTripAsync(id));


                if (Trip.Points != null && Trip.Points.Count > 0)
                {
                    Title = Trip.Name;
                    for (int i = 0; i < Trip.Points.Count; i++)
                    {
                        var point = Trip.Points[i];
                        if (point.MassFlowRate == -255)
                        {
                            point.MassFlowRate = i == 0 ? 0 : Trip.Points[i - 1].MassFlowRate;
                        }
                        if (point.Speed == -255)
                        {
                            point.Speed = i == 0 ? 0 : Trip.Points[i - 1].Speed;
                        }
                    }
                    POIs.AddRange(await StoreManager.POIStore.GetItemsAsync(Trip.Id));

                    Title = Trip.Name;
                    Logger.Instance.Track("LoadPastTrip");
                }
                else
                {
                    Logger.Instance.Track("LoadPastTrip: no trip points! Trip id:" + id);
                    errorMessage = "The trip does not have any points recorded";
                    error        = true;
                }
            }
            catch (Exception ex)
            {
                Logger.Instance.Track("Error loading past trip!");
                Logger.Instance.Report(ex);
                error = true;
            }
            finally
            {
                ProgressDialogManager.DisposeProgressDialog();
                IsBusy = false;
            }

            if (error)
            {
                Acr.UserDialogs.UserDialogs.Instance.Alert(
                    errorMessage,
                    "Error loading trip", "OK");
            }

            return(!error);
        }
Esempio n. 10
0
        public async Task <bool> ExecuteLoadTripCommandAsync(string id)
        {
            if (IsBusy)
            {
                return(false);
            }

            Logger.Instance.Track("LoadPastTrip");

            var progress = Acr.UserDialogs.UserDialogs.Instance.Loading("Loading trip details...",
                                                                        maskType: Acr.UserDialogs.MaskType.Clear);

            bool error = false;

            try
            {
                IsBusy = true;
                if (Trip == null)
                {
                    Trip = await StoreManager.TripStore.GetItemAsync(id);
                }

                Trip.Points = new List <TripPoint>(await StoreManager.TripPointStore.GetPointsForTripAsync(id));


                if (Trip.Points != null && Trip.Points.Count > 0)
                {
                    Title = Trip.Name;
                    for (int i = 0; i < Trip.Points.Count; i++)
                    {
                        var point = Trip.Points[i];
                        if (point.MassFlowRate == -255)
                        {
                            point.MassFlowRate = i == 0 ? 0 : Trip.Points[i - 1].MassFlowRate;
                        }
                        if (point.Speed == -255)
                        {
                            point.Speed = i == 0 ? 0 : Trip.Points[i - 1].Speed;
                        }
                    }
                    POIs.AddRange(await StoreManager.POIStore.GetItemsAsync(Trip.Id));

                    Title = Trip.Name;
                }
                else
                {
                    error = true;
                }
            }
            catch (Exception ex)
            {
                Logger.Instance.Report(ex);
                error = true;
            }
            finally
            {
                progress?.Dispose();
                IsBusy = false;
            }

            if (error)
            {
                Acr.UserDialogs.UserDialogs.Instance.Alert(
                    "Please check internet connection and try again.",
                    "Unable to load Trip", "OK");
            }

            return(!error);
        }