Example #1
0
        private void HandleLocationChanged(object sender, LocationChangedEventArgs e)
        {
            System.Diagnostics.Debug.WriteLine(string.Format("New Journey Id: {0} ", NewJourneyId));
            if (previousLocation != null)
            {
                distance      = Math.Round(distance + HaversineCalculator.CalculateHaversineDistiance(e.Location, previousLocation), 5);
                todayDistance = Math.Round(todayDistance + HaversineCalculator.CalculateHaversineDistiance(e.Location, previousLocation), 5);

                if (NewJourneyId != int.MinValue)
                {
                    JourneyRepository.UpdateJourneyDetails(NewJourneyId, distance);
                    journeyPointRespository.InsertPointIntoTrack(NewJourneyId, JourneyPointIndex, e.Location.Latitude, e.Location.Longitude);
                }
            }

            previousLocation  = e.Location;
            JourneyPointIndex = JourneyPointIndex + 1;
        }