public async void InitRoute()
        {
            ShowDetails = true;
            if (Waypoints.Count() > 2)
            {
                Route.Clear();

                foreach (var w in Waypoints)
                {
                    Route.Add(new Position(w.Latitude, w.Longitude));
                }
            }
            else
            {
                var leg =
                    await Host.GeocodingService.GetDirectionsFromGoogle(
                        new[] { OriginAddress.Latitude, OriginAddress.Longitude },
                        new[] { DestinationAddress.Latitude, DestinationAddress.Longitude });

                Route.Clear();
                if (leg != null)
                {
                    foreach (var step in leg.steps)
                    {
                        Route.Add(new Position(step.end_location.lat, step.end_location.lng));
                    }
                }
            }

            Loaded = true;
        }
Exemple #2
0
 public void AddWaypoint(Vector3 waypointPosition)
 {
     if (Waypoints.Count(way => (way.Position - waypointPosition).magnitude <= minWaypointGraphDistance) == 0)
     {
         var w = Instantiate(waypointPrefab, waypointPosition, Quaternion.identity, transform);
         AddWaypoint(w.GetComponent <Waypoint>());
     }
 }
    private double CalculateLength()
    {
        var sum    = 0.0;
        var wpList = Waypoints.ToList();

        for (var i = 1; i < Waypoints.Count(); i++)
        {
            sum += GetDistanceBetweenWaypoints(wpList[i - 1], wpList[i]);
        }
        return(sum);
    }
        public JourneyViewModel(Journey j)
        {
            Distance = Units.MetersToMiles(j.Distance);
            Cost     = Convert.ToDecimal(j.Cost);
            Date     = j.Date;

            Waypoints.Clear();

            foreach (var w in j.Waypoints)
            {
                Waypoints.Add(w);
            }

            var originWaypoint      = Waypoints.OrderBy(w => w.Step).First();
            var destinationWaypoint = Waypoints.OrderBy(w => w.Step).Last();

            OriginAddress = new Address
            {
                Label     = originWaypoint.Label,
                Latitude  = originWaypoint.Latitude,
                Longitude = originWaypoint.Longitude,
                PlaceId   = originWaypoint.PlaceId
            };

            DestinationAddress = new Address
            {
                Label     = destinationWaypoint.Label,
                Latitude  = destinationWaypoint.Latitude,
                Longitude = destinationWaypoint.Longitude,
                PlaceId   = destinationWaypoint.PlaceId
            };

            if (Waypoints.Count() > 2)
            {
                Gps = true;
            }
            else
            {
                Manual = true;
            }

            Invoiced   = j.Invoiced;
            Passengers = j.Passengers;
            Vehicle    = j.Vehicle;
            Company    = j.Company;
            Reason     = j.Reason;

            ShareCommand = new Command(Share);
        }
Exemple #5
0
        /// <summary>
        /// Sanity checks the instance.
        /// </summary>
        /// <returns>All errors that were recognized.</returns>
        public List <Tuple <SanityError, string> > SanityCheck()
        {
            List <Tuple <SanityError, string> > errors = new List <Tuple <SanityError, string> >();

            // Check dead end waypoints
            foreach (var waypoint in Waypoints)
            {
                if (!waypoint.Paths.Any())
                {
                    errors.Add(new Tuple <SanityError, string>(SanityError.DeadEnd, waypoint.ToString()));
                }
            }
            // Check dead end waypoints by blocking
            foreach (var waypoint in Waypoints)
            {
                if (!waypoint.Paths.Any(other => !other.PodStorageLocation))
                {
                    errors.Add(new Tuple <SanityError, string>(SanityError.DeadEnd, waypoint.ToString()));
                }
            }
            // Check blockable storage locations
            foreach (var storageLocation in Waypoints.Where(w => w.PodStorageLocation))
            {
                if (!Waypoints.Any(otherWP => !otherWP.PodStorageLocation && otherWP.ContainsPath(storageLocation)))
                {
                    errors.Add(new Tuple <SanityError, string>(SanityError.BlockableStorageLocation, storageLocation.ToString()));
                }
            }
            // Check resting positions
            int storageLocations = Waypoints.Count(w => w.PodStorageLocation);

            if (storageLocations - Pods.Count < Bots.Count)
            {
                errors.Add(new Tuple <SanityError, string>(SanityError.InsufficientRestingPositions, "StorageLocations-Pods<Bots:" + storageLocations + "-" + Pods.Count + "<" + Bots.Count));
            }
            // Return the list
            return(errors);
        }