private Location_ GetAssessmentLocationOfFall(Fall CurrentFall)
        {
            List <Assessment> assessments = CurrentFallPredictionVM.Assessments.ToList();
            // List<Report> report = CurrentReportVM.Reports.ToList();
            List <Assessment> currentAssessment = (from a in assessments
                                                   from f in a.Falls
                                                   where f.id == CurrentFall.id
                                                   select a).ToList();

            if (currentAssessment.Count == 0)
            {
                return(null);
            }

            GeoCoordinate location2      = new GeoCoordinate(CurrentFall.location.latitude, CurrentFall.location.longitude);
            double        min            = double.MaxValue;
            Location_     returnLocation = new Location_();

            foreach (Location_ location1 in currentAssessment[0].Locations)//getalllocation
            {
                double cur = new GeoCoordinate(location1.latitude, location1.longitude).GetDistanceTo(location2);
                if (cur < min)
                {
                    min            = cur;
                    returnLocation = location1;
                }
            }
            return(returnLocation);
        }
        public Information(Fall CurrentFall)
        {
            InitializeComponent();
            CurrentReportVM         = new ReportVM();
            CurrentFallPredictionVM = new AssessmentVM();
            Location_ Assessmentlocation = GetAssessmentLocationOfFall(CurrentFall);

            DataContext        = this;
            fallLocation       = CurrentFall.location.latitude.ToString() + " " + "," + " " + CurrentFall.location.longitude.ToString();
            CalculatedLocation = Assessmentlocation.latitude.ToString() + " " + "," + " " + Assessmentlocation.longitude.ToString();
            ReportsNumber      = CalculateReportNumber(CurrentFall);
        }
Beispiel #3
0
        public void RemoveLocation(int id)
        {
            Location_ ToRemove = GetLocation(id);

            if (ToRemove == null)
            {
                throw new Exception("An Assessment with this ID does not exist..");
            }
            using (var db = new Project_Context())
            {
                db.Locations.Remove(ToRemove);
                db.SaveChanges();
            }
        }
Beispiel #4
0
        public void AddLocation(Location_ location)
        {
            var ToAdd = GetLocation(location.id);

            if (ToAdd != null)
            {
                throw new Exception("An Location with an identical id already exists...");
            }
            using (var db = new Project_Context())
            {
                db.Locations.Add(ToAdd);
                db.SaveChanges();
            }
        }
        public void Update(Fall CurrentFall)
        {
            CurrentReportVM         = new ReportVM();
            CurrentFallPredictionVM = new AssessmentVM();
            Location_ assessmentLocation = GetAssessmentLocationOfFall(CurrentFall);

            DataContext = this;
            if (fallLocation != null)
            {
                fallLocation = CurrentFall.location.latitude.ToString() + " " + "," + " " + CurrentFall.location.longitude.ToString();
            }
            if (CalculatedLocation != "")
            {
                CalculatedLocation = assessmentLocation.latitude.ToString() + " " + "," + " " + assessmentLocation.longitude.ToString();
            }
            ReportsNumber = CalculateReportNumber(CurrentFall);
        }
Beispiel #6
0
        public void UpdateAssessment(Assessment assessment)
        {
            try
            {
                // Assessment asses =GetAssessment(assessment.id);

                //remove last assessments location
                assessment.locations.Clear();

                int k = (int)assessment.reports.Average(r => r.numOfExplosions);
                List <GeoCoordinate> clusters = kMeans(assessment.reports.ToList(), k);
                foreach (GeoCoordinate c in clusters)
                {
                    Location_ temp = new Location_(c.Latitude, c.Longitude);
                    assessment.locations.Add(temp);
                }

                dal.UpdateAssessment(assessment);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #7
0
        public void AddFall(Location_ location)
        {
            Location_ temp = new Location_(location);

            currentModel.FallLocation.Add(temp);
        }
Beispiel #8
0
        public void AddAssessment(Location_ location)
        {
            Location_ temp = new Location_(location);

            currentModel.AssessmentLocation.Add(temp);
        }
Beispiel #9
0
        public void AddReport(Location_ location)
        {
            Location_ temp = new Location_(location);

            currentModel.ReportLocation.Add(temp);
        }