Esempio n. 1
0
 public void setWaypoint(RouteWaypoint next)
 {
     if (inTransit)
     {
         interrupt(true);
     }
     nextWayPoint = next;
 }
Esempio n. 2
0
        public void AddWaypoint(string description, GeoPoint location)
        {
            RouteWaypoint waypoint = new RouteWaypoint(description, location);

            if (!waypoints.Contains(waypoint))
            {
                MapPushpin pushpin = new MapPushpin();
                pushpin.Location    = location;
                pushpin.Information = description;
                pushpin.Text        = NextWaypointLetter();
                pushpin.TraceDepth  = 0;
                pushpin.State       = MapPushpinState.Busy;
                Helpers.Add(pushpin);
                waypoints.Add(waypoint);
                SendRouteRequest();
            }
            RaisePropertyChanged("ActionText");
            RaisePropertyChanged("Waypoints");
        }
        private void AddWaypoint(string description, GeoPoint location)
        {
            RouteWaypoint waypoint = new RouteWaypoint(description, location);

            if (!waypoints.Contains(waypoint))
            {
                MapPushpin pushpin = new MapPushpin();
                pushpin.Location    = location;
                pushpin.Information = description;
                pushpin.Text        = NextWaypointLetter();
                pushpin.TraceDepth  = 0;
                pushpin.State       = MapPushpinState.Busy;
                Helpers.Add(pushpin);
                waypoints.Add(waypoint);

                if (waypoints.Count > 1)
                {
                    routeDataProvider.CalculateRoute(waypoints);
                }
            }
        }
Esempio n. 4
0
        /* Creates a route from 4350 Still Creek Dr to Langley BC with highways disallowed */
        private void CreateRoute()
        {
            /* Initialize a CoreRouter */
            CoreRouter coreRouter = new CoreRouter();

            /* Initialize a RoutePlan */
            RoutePlan routePlan = new RoutePlan();

            /*
             * Initialize a RouteOption. HERE Mobile SDK allow users to define their own parameters for the
             * route calculation,including transport modes,route types and route restrictions etc.Please
             * refer to API doc for full list of APIs
             */
            RouteOptions routeOptions = new RouteOptions();

            /* Other transport modes are also available e.g Pedestrian */
            routeOptions.SetTransportMode(RouteOptions.TransportMode.Car);
            /* Disable highway in this route. */
            routeOptions.SetHighwaysAllowed(false);
            /* Calculate the shortest route available. */
            routeOptions.SetRouteType(RouteOptions.Type.Shortest);
            /* Calculate 1 route. */
            routeOptions.SetRouteCount(1);
            /* Finally set the route option */
            routePlan.SetRouteOptions(routeOptions);

            /* Define waypoints for the route */
            // START: Daimler Fleetboard
            RouteWaypoint startPoint = new RouteWaypoint(new GeoCoordinate(48.7244153, 9.1161991));
            // END: Biergarten
            RouteWaypoint destination = new RouteWaypoint(new GeoCoordinate(48.701356, 9.1393803));

            /* Add both waypoints to the route plan */
            routePlan.AddWaypoint(startPoint);
            routePlan.AddWaypoint(destination);

            /* Trigger the route calculation,results will be called back via the listener */
            coreRouter.CalculateRoute(routePlan, new RouterListener(this));
        }
        private static double GetDistanceAlongShape(VehicleState vehicle, Route route)
        {
            Coordinate vehicleLocation = new Coordinate(vehicle.GetLatestVehicleReport().Latitude, vehicle.GetLatestVehicleReport().Longitude);

            double minimum      = Double.MaxValue;
            int    closestCoord = -1;

            for (int i = 0; i < vehicle.CurrentStopPath.Path.Count; i++)
            {
                Coordinate coord = new Coordinate(vehicle.CurrentStopPath.Path[i].Latitude, vehicle.CurrentStopPath.Path[i].Longitude);
                if (coord.DistanceTo(vehicleLocation) < minimum)
                {
                    minimum      = coord.DistanceTo(vehicleLocation);
                    closestCoord = i;
                }
            }

            RouteWaypoint closestWaypoint = route.RouteWaypoints.Find(x =>
                                                                      x.Coordinate.Latitude == vehicle.CurrentStopPath.Path[closestCoord].Latitude &&
                                                                      x.Coordinate.Longitude == vehicle.CurrentStopPath.Path[closestCoord].Longitude
                                                                      );

            return(closestWaypoint.Distance);
        }
        private void OnCalculateRoutesClick(object sender, EventArgs e)
        {
            RouteWaypoint targetPoint = new RouteWaypoint("Searched location", new GeoPoint(lat, lon));

            routeProvider.CalculateRoutesFromMajorRoads(targetPoint);
        }