FindClosestBike() public static méthode

public static FindClosestBike ( double _lat, double _long ) : BikeLocation
_lat double
_long double
Résultat BikeLocation
Exemple #1
0
        public static void StartNewTripItem()
        {
            currentTripLog                  = new TripLog();
            currentTripLog.Ticks            = DateTime.Now.Ticks;
            currentTripLog.TimeInSeconds    = -1;
            currentTripLog.DistanceInMeters = -1;

            GetCurrentLocation(currentTripLog, true, delegate {
                Util.Log("Found Start location");

#if DEBUG
#if FAKEDATA
                currentTripLog.StartLat = Locations.HydePark.Latitude;
                currentTripLog.StartLon = Locations.HydePark.Longitude;
#endif
#endif

                BikeLocation loc = BikeLocation.FindClosestBike(currentTripLog.StartLat, currentTripLog.StartLon);
                if (loc != null)
                {
                    if (loc.DistanceFromCurrentPoint > 500)
                    {
                        currentTripLog.StartStation = "Unknown";
                    }
                    else
                    {
                        currentTripLog.StartStation = loc.Name;
                    }
                }
                else
                {
                    currentTripLog.StartStation = "Unknown";
                }

                Util.Log("Station: " + currentTripLog.StartStation);

                NSUserDefaults defaults = NSUserDefaults.StandardUserDefaults;

                defaults.SetString(currentTripLog.AsLine, "triplog_line");
                defaults.Synchronize();
            });
        }
Exemple #2
0
        public static void StopTripItem(int totalTime)
        {
            if (currentTripLog == null)
            {
                NSUserDefaults defaults = NSUserDefaults.StandardUserDefaults;


                string line = defaults.StringForKey("triplog_line");

                if (string.IsNullOrEmpty(line))
                {
                    return;
                }

                currentTripLog = new TripLog(line.Split('|'));
            }

            currentTripLog.TimeInSeconds = totalTime;

            GetCurrentLocation(currentTripLog, false, delegate {
#if DEBUG
#if FAKEDATA
                currentTripLog.EndLat        = Locations.BanksideMix.Latitude;
                currentTripLog.EndLon        = Locations.BanksideMix.Longitude;
                currentTripLog.TimeInSeconds = 1120;
#endif
#endif

                Util.Log("Found End location");
                BikeLocation loc = BikeLocation.FindClosestBike(currentTripLog.EndLat, currentTripLog.EndLon);
                if (loc != null)
                {
                    if (loc.DistanceFromCurrentPoint > 500)
                    {
                        currentTripLog.EndStation = "Unknown";
                    }
                    else
                    {
                        currentTripLog.EndStation = loc.Name;
                    }
                }
                else
                {
                    currentTripLog.EndStation = "Unknown";
                }
                currentTripLog.DistanceInMeters = (int)BikeLocation.CalculateDistanceInMeters(
                    new CLLocationCoordinate2D(currentTripLog.StartLat, currentTripLog.StartLon),
                    new CLLocationCoordinate2D(currentTripLog.EndLat, currentTripLog.EndLon));
                BikeLocation.LogTrip(currentTripLog.TimeInSeconds, currentTripLog.DistanceInMeters);

                Util.Log("End Station: " + currentTripLog.EndStation);
                allTrips.Insert(0, currentTripLog);



                PersistToDisk();

                if (allTrips.Count > 0)
                {
                    ReverseGeocode(allTrips [0]);
                }
            });
        }