Beispiel #1
0
 public Route(Element route, Jid from, Jid to, RouteType type) : this()
 {
     RouteElement = route;
     From = from;
     To = to;
     Type = type;
 }
        public async Task<Route> CalcuteRouteAsync(IList<AddressSearch> addressSearches, RouteType routeType)
        {
            var routeStops = new List<RouteStop>();

            addressSearches.ToList().ForEach(x =>
            {
                var routeStop = Mapper.Map<AddressSearch, RouteStop>(x);
                var point = Mapper.Map<AddressSearch, Point>(x);
                routeStop.point = point;
                routeStops.Add(routeStop);
            });

            var options = _config.GetRouteOptions(routeType);

            using (var routeSoapClient = new RouteSoapClient())
            {
                var response = await routeSoapClient.getRouteAsync(routeStops.ToArray(), options, _token.Tokenvalue);

                if (response.Body.getRouteResult.routeTotals != null)
                {
                    var route = Mapper.Map<RouteTotals, Route>(response.Body.getRouteResult.routeTotals);                    
                    return route;
                }
            }
            return null;
        }
 public IRoute GetRoute(RouteSpecification spec,
     RouteType routeType)
 {
     IRouteAlgorithm algorithm = 
         this.factory.CreateAlgorithm(routeType);
     return algorithm.CalculateRoute(spec);
 }
        public string AddToCart(int routeId, int userId)
        {
            RouteType route = _routeRepository.GetAll().FirstOrDefault(repository => repository.Id == routeId);

            if (route != null)
            {
                carts[userId].AddItem(route, 1);
            }

            return("OK");
        }
 public void GetRouteReturnsCorrectRoute([Frozen]Mock<IRouteAlgorithmFactory> factoryStub, Mock<IRouteAlgorithm> routeAlgorithmStub, RouteSpecification specification, RouteType selectedAlgorithm, IRoute expectedResult, RouteController sut)
 {
     // Fixture setup
     factoryStub.Setup(f => f.CreateAlgorithm(selectedAlgorithm)).Returns(routeAlgorithmStub.Object);
     routeAlgorithmStub.Setup(a => a.CalculateRoute(specification)).Returns(expectedResult);
     // Exercise system
     var result = sut.GetRoute(specification, selectedAlgorithm);
     // Verify outcome
     Assert.Equal(expectedResult, result);
     // Teardown
 }
Beispiel #6
0
        public async Task <List <RouteResult> > GetRouteByAddress(string originAddress, string destinationAddress, RouteType routeType = null)
        {
            if (routeType == null)
            {
                routeType = new RouteType();
            }
            //get geolocations of addresses:
            var positions = await GetPositions(originAddress, destinationAddress);

            //get routing result:
            return(await GetRouteByPosition(positions.Item1, positions.Item2, routeType));
        }
Beispiel #7
0
        public async Task <string> GetRouteByPositionJson(Position origin, Position destination, RouteType routeType = null)
        {
            if (routeType == null)
            {
                routeType = new RouteType();
            }
            Initalize(HereApiBaseUrl.RoutingApiBase);
            var response = await _hereClient.GetRouteByPositionJsonAsync(origin.ToString(), destination.ToString(),
                                                                         routeType.IsMetricString, routeType.ModeTypeString, routeType.VehicleTypeString, routeType.HasTrafficString);

            return(response);
        }
Beispiel #8
0
 public RatingHistoryEntry(RouteType pRouteType, int pRatedRouteId, DateTime pFirstDate, DateTime pLastDate, RatingInfoDto pRatingInfo)
 {
     if (pFirstDate > pLastDate)
     {
         throw new ArgumentOutOfRangeException("pFirstDate", "'First Date' cannot be grater then 'Last Date'.");
     }
     RouteType    = pRouteType;
     ratedRouteId = pRatedRouteId;
     firstDate    = trimToDay(pFirstDate);
     lastDate     = trimToDay(pLastDate);
     ratingInfo   = pRatingInfo;
 }
        /// <summary>
        /// Adds a route type to the list of route types that service this
        /// stop and all parents of this stop.
        ///
        /// Does not add a stop type to the list if it is already in the list.
        /// </summary>
        private static void AddRouteTypeToStopServicedByList(Stop stop, RouteType routeType)
        {
            if (!stop.ServicedBy.Contains(routeType))
            {
                stop.ServicedBy.Add(routeType);
            }

            if (stop.Parent is object)
            {
                AddRouteTypeToStopServicedByList(stop.Parent, routeType);
            }
        }
Beispiel #10
0
        public async Task <ActionResult> Create([Bind(Include = "id,label,description")] RouteType routeType)
        {
            if (ModelState.IsValid)
            {
                db.RouteTypes.Add(routeType);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(routeType));
        }
        public void ProcessRouteProperties()
        {
            foreach (PropertyInfo property in
                     RouteType.GetProperties().Where(p => p.HasAttribute <ApiMemberAttribute>() || (p.CanRead && p.CanWrite)))
            {
                if (PropertiesProcessed.Contains(property.Name))
                {
                    continue;
                }

                ProcessClrProperty(property);
            }
        }
        public async Task <StopFacilities> GetStopFacilitiesAsync(string stopID, RouteType routeType, bool getLocation = true, bool getAmenity = true, bool getAccessibility = true)
        {
            var pathAndQuery = string.Format(TimetableClient.GetStopFacilitiesAndQueryFormat,
                                             stopID,
                                             (uint)routeType,
                                             Convert.ToInt32(getLocation),
                                             Convert.ToInt32(getAmenity),
                                             Convert.ToInt32(getAccessibility)
                                             );
            var result = await this.ExecuteAsync <StopFacilities>(pathAndQuery);

            return(result);
        }
Beispiel #13
0
        /// <summary>
        /// Request a polyline that connects the end points of all routes leaving from one defined center
        /// with either a specified length or a specified travel time.
        /// </summary>
        /// <param name="position">Center of the isoline request. Isoline will cover all roads which can be reached from this point within given range.</param>
        /// <param name="rangeType">Specifies type of range. Possible values are distance, time, consumption. For distance the unit is meters.
        /// For time the unit is seconds. For consumption it is defined by consumption model</param>
        /// <param name="range">Range of isoline. Several comma separated values can be specified.
        /// The unit is defined by parameter <paramref name="rangeType"/></param>
        /// <param name="routeType">Type;TransportModes;TrafficMode;Feature</param>
        /// <returns></returns>
        public async Task <CoordinateArray> GetIsoline(Position position, RangeType rangeType, int range, RouteType routeType = null)
        {
            if (routeType == null)
            {
                routeType = new RouteType();
            }
            Initalize(HereApiBaseUrl.IsolineApiBase);

            var response = await _hereClient.GetIsolineAsync(position.ToString(), rangeType.ToString(), range.ToString(),
                                                             routeType.ModeTypeString, routeType.VehicleTypeString, routeType.HasTrafficString);

            return(response.Content.Isoline[0].Component[0].Shape);
        }
Beispiel #14
0
 static bool InnerNavigateTo(Frame frame, RouteType tag, NavigationTransitionInfo transition)
 {
     if (!contexts.TryGetValue(frame, out var context))
     {
         context = contexts[frame] = new FrameContext();
     }
     if (context.Current == tag)
     {
         return(false);
     }
     context.Current = tag;
     return(frame.Navigate(GetRoute(tag), null, transition ?? TransitionHelper.DefaultSlide));
 }
        private void AddRoutingTwoWays(
            Location from, Location to, int duration, RouteType routeType,
            // destinations we can target using the route from `From` to `To`
            List <string>?destinationsAfterTo,
            // destinations we can target using the route from `To` to `From`
            List <string>?destinationsBeforeFrom)
        {
            // perspective of `From`
            AddRoutingOneWay(from, to, duration, routeType, destinationsAfterTo);

            // perspective of `To`
            AddRoutingOneWay(to, from, duration, routeType, destinationsBeforeFrom);
        }
Beispiel #16
0
        public void ShouldMapToUrl(string url)
        {
            var builder = new TestControllerBuilder();
            var context = new RequestContext(builder.HttpContext, new RouteData());

            context.HttpContext.Response.Stub(x => x.ApplyAppPathModifier(null)).IgnoreArguments().Do(new Func <string, string>(s => s)).Repeat.Any();

            var urlhelper = new UrlHelper(context);

            var generatedUrl = RouteType.GetUrl(urlhelper);

            generatedUrl.AssertSameStringAs(url);
        }
Beispiel #17
0
 public string this[string key]
 {
     get
     {
         if (StringComparer.InvariantCultureIgnoreCase.Compare(key, "priority") == 0)
         {
             return(Priority.ToString(CultureInfo.InvariantCulture));
         }
         if (StringComparer.InvariantCultureIgnoreCase.Compare(key, "MessageType") == 0)
         {
             return(MessageType.ToString());
         }
         if (StringComparer.InvariantCultureIgnoreCase.Compare(key, "CommunicationType") == 0)
         {
             return(CommunicationType.ToString());
         }
         if (StringComparer.InvariantCultureIgnoreCase.Compare(key, "RouteType") == 0)
         {
             return(RouteType.ToString());
         }
         if (StringComparer.InvariantCultureIgnoreCase.Compare(key, "RemoteBoundContext") == 0)
         {
             return(RemoteBoundedContext);
         }
         if (StringComparer.InvariantCultureIgnoreCase.Compare(key, "LocalBoundedContext") == 0)
         {
             return(LocalContext);
         }
         if (StringComparer.InvariantCultureIgnoreCase.Compare(key, "Exclusive") == 0)
         {
             return(Exclusive.ToString());
         }
         string value;
         m_Hints.TryGetValue(key, out value);
         return(value);
     }
     set
     {
         if (StringComparer.InvariantCultureIgnoreCase.Compare(key, "priority") == 0 ||
             StringComparer.InvariantCultureIgnoreCase.Compare(key, "MessageType") == 0 ||
             StringComparer.InvariantCultureIgnoreCase.Compare(key, "CommunicationType") == 0 ||
             StringComparer.InvariantCultureIgnoreCase.Compare(key, "RouteType") == 0 ||
             StringComparer.InvariantCultureIgnoreCase.Compare(key, "RemoteBoundContext") == 0 ||
             StringComparer.InvariantCultureIgnoreCase.Compare(key, "LocalBoundedContext") == 0 ||
             StringComparer.InvariantCultureIgnoreCase.Compare(key, "Exclusive") == 0)
         {
             throw new ArgumentException(key + " should be set with corresponding RoutingKey property", "key");
         }
         m_Hints[key] = value;
     }
 }
Beispiel #18
0
        /// <inheritdoc/>
        public XmlElement ToXmlElement(XmlDocument xmlDocument, ref IList <object> id_source, string name = "")
        {
            if (xmlDocument is null)
            {
                throw new ArgumentNullException(nameof(xmlDocument));
            }
            if (id_source is null)
            {
                throw new ArgumentNullException(nameof(id_source));
            }
            if (name is null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (name == "")
            {
                name = GetType().Name;
            }
            XmlElement xmlThis = xmlDocument.CreateElement(name);

            if (id_source.Contains(this))
            {
                xmlThis.SetAttribute("ref", id_source.IndexOf(this).ToString("x16"));
            }
            else
            {
                xmlThis.SetAttribute("id", id_source.Count.ToString("x16"));
                id_source.Add(this);
                xmlThis.SetAttribute("type", GetType().FullName);
                XmlElement xmlRoute = xmlDocument.CreateElement("RouteType");
                xmlThis.AppendChild(xmlRoute);
                xmlRoute.InnerText = RouteType.ToString();
                XmlElement xmlRouteMode = xmlDocument.CreateElement("RouteMode");
                xmlThis.AppendChild(xmlRouteMode);
                xmlRouteMode.InnerText = RouteMode.ToString();
                XmlElement xmlIncrease = xmlDocument.CreateElement("Increase");
                xmlThis.AppendChild(xmlIncrease);
                xmlIncrease.InnerText = _increase.ToString();
                XmlElement xmlCurrentIndex = xmlDocument.CreateElement("CurrentIndex");
                xmlThis.AppendChild(xmlCurrentIndex);
                xmlCurrentIndex.InnerText = CurrentIndex is null ? "null" : CurrentIndex.ToString();
                XmlElement xmlEntries = xmlDocument.CreateElement("Entries");
                xmlThis.AppendChild(xmlEntries);
                foreach (T entry in this)
                {
                    XmlElement xmlEntry = CyclicalMethods.ToXmlElement(entry, xmlDocument, ref id_source, "Entry");
                    xmlEntries.AppendChild(xmlEntry);
                }
            }
            return(xmlThis);
        }
        public async Task <IActionResult> List(string type = null, bool archived = false, string creator = null)
        {
            RouteType?nullableParsedtype = null;
            RouteType parsedtype;

            if (RouteType.TryParse(type, true, out parsedtype))
            {
                nullableParsedtype = parsedtype;
            }

            RouteListViewModel model = await GetListViewModel(archived, creator, nullableParsedtype);

            return(View(model));
        }
        // GET: RouteTypes/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RouteType routeType = db.RouteTypes.Find(id);

            if (routeType == null)
            {
                return(HttpNotFound());
            }
            return(View(routeType));
        }
Beispiel #21
0
        public string GetSpecialRoute(RouteType type)
        {
            string val;

            try
            {
                _destinations.TryGetValue(type, out val);
            }
            catch (Exception)
            {
                val = string.Empty;
            }
            return(val);
        }
Beispiel #22
0
        // GET: RouteTypes/Delete/5
        public async Task <ActionResult> Delete(byte?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RouteType routeType = await db.RouteTypes.FindAsync(id);

            if (routeType == null)
            {
                return(HttpNotFound());
            }
            return(View(routeType));
        }
Beispiel #23
0
        public async Task <ActionResult> AddRouteType([FromBody] RouteType routeType)
        {
            var userIdClaim = int.Parse(User.Claims.SingleOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value ?? "-1");

            if (userIdClaim < 0)
            {
                return(Forbid());
            }
            routeType.UserId = userIdClaim;
            _context.RouteTypes.Add(routeType);
            await _context.SaveChangesAsync();

            return(Ok(routeType.TypeId));
        }
Beispiel #24
0
        public async Task <List <RouteResult> > GetRouteByGeocode(string originPosition, string destinationPosition, RouteType routeType = null)
        {
            Initalize("https://route.api.here.com/routing/");

            if (routeType == null)
            {
                routeType = new RouteType();
            }

            var response = await _hereClient.GetRouteByAddressAsync(originPosition, destinationPosition,
                                                                    routeType.IsMetricString, routeType.ModeTypeString, routeType.VehicleTypeString, routeType.HasTrafficString);

            return(response.Response.ResultList);
        }
Beispiel #25
0
        private bool SendMessage(Type type, object message, RouteType routeType, string context, uint priority, string remoteBoundedContext = null)
        {
            RouteMap routeMap = DefaultRouteMap;

            if (context != null)
            {
                routeMap = Contexts.FirstOrDefault(bc => bc.Name == context);
                if (routeMap == null)
                {
                    throw new ArgumentException($"bound context {context} not found", nameof(context));
                }
            }
            var telemtryOperation = TelemetryHelper.InitTelemetryOperation(
                routeType == RouteType.Commands ? "Cqrs send command" : "Cqrs publish event",
                type.Name,
                context,
                remoteBoundedContext);

            try
            {
                var published = routeMap.PublishMessage(
                    MessagingEngine,
                    type,
                    message,
                    routeType,
                    priority,
                    remoteBoundedContext);
                if (!published && routeType == RouteType.Commands)
                {
                    published = DefaultRouteMap.PublishMessage(
                        MessagingEngine,
                        type,
                        message,
                        routeType,
                        priority,
                        remoteBoundedContext);
                }
                return(published);
            }
            catch (Exception e)
            {
                TelemetryHelper.SubmitException(telemtryOperation, e);
                throw;
            }
            finally
            {
                TelemetryHelper.SubmitOperationResult(telemtryOperation);
            }
        }
Beispiel #26
0
        public FavoriteDistanceDto GetRoute(int maskId, int sourceId, int targetId, RouteType routeType)
        {
            var watch = new Stopwatch();

            watch.Start();
            _logger.LogInformation("Dijkstra starting");
            var matrix = GetAdjMatrix(maskId, routeType);
            var dijk   = DijkstraAlgoDict(matrix, sourceId, targetId);

            _logger.LogInformation("Dijkstra Ended" + watch.Elapsed);
            watch.Stop();
            var solarSystemDict = _solarSystemService.GetAll().ToDictionary(x => x.Id, x => new { x.Name, Color = x.SystemType.Color });
            var u     = targetId;
            var route = new List <int>();

            do
            {
                route.Add(u);
                u = dijk[u];
                if (u < 0)
                {
                    return(new FavoriteDistanceDto
                    {
                        SystemName = solarSystemDict[targetId].Name,
                        SystemId = targetId,
                        DistanceInJumps = -1,
                        Route = new List <RouteDto>()
                    });
                }
            }while (dijk.ContainsKey(u) && u != sourceId);
            route.Reverse();
            var index = 0;
            var res   = new FavoriteDistanceDto
            {
                SystemName      = solarSystemDict[targetId].Name,
                SystemId        = targetId,
                DistanceInJumps = route.Count(),
                Route           = route.Select(x => new RouteDto
                {
                    SystemId   = x,
                    SystemName = solarSystemDict[x].Name,
                    Order      = index++,
                    Color      = solarSystemDict[x].Color
                }).ToList()
            };

            return(res);
            //return dijk.ContainsKey(targetId) ? dijk[targetId] : int.MaxValue;
        }
Beispiel #27
0
        public Route(RouteType type, string id, Airport destination1, Airport destination2)
        {
            this.Type         = type;
            this.Id           = id;
            this.Destination1 = destination1;
            this.Destination2 = destination2;

            this.TimeTable  = new RouteTimeTable(this);
            this.Invoices   = new Invoices();
            this.Statistics = new RouteStatistics();
            this.Banned     = false;
            this.Stopovers  = new List <StopoverRoute>();

            this.Season = Weather.Season.All_Year;
        }
        public Route(RouteType type, string id, Airport destination1, Airport destination2)
        {
            this.Type = type;
            this.Id = id;
            this.Destination1 = destination1;
            this.Destination2 = destination2;

            this.TimeTable = new RouteTimeTable(this);
            this.Invoices = new Invoices();
            this.Statistics = new RouteStatistics();
            this.Banned = false;
            this.Stopovers = new List<StopoverRoute>();

            this.Season = Weather.Season.All_Year;
        }
        public static async Task <RouteDirectionsResponse> GetRouteDirections(List <BasicGeoposition> waypoints, string language, TravelMode travelMode, List <Avoid> avoids,
                                                                              RouteType routeType, int alternativeRouteCount, DateTime?departureTime, DateTime?arrivalTime)
        {
            var rawresult = await MainPage.azureMaps.GetRouteDirectionsAsync(waypoints, language, true, null, routeType, null, null, travelMode, avoids,
                                                                             null, null, null, null, null, null, null, null, null, null, null,
                                                                             null, null, null, null, null, null, null, null, null, alternativeRouteCount,
                                                                             null, null, arrivalTime, departureTime, null, RouteInstructionsType.text, null, ComputeTravelTimeFor.all, null, null, null);

            try
            {
                return(rawresult as RouteDirectionsResponse);
            }
            catch
            { return(null); }
        }
Beispiel #30
0
        public IEnumerable <LinePlus> GetScheduleLines(string typeOfLine)
        {
            if (typeOfLine == null)
            {
                var             type  = db.Lines.GetAll().FirstOrDefault(u => u.RouteType == Enums.RouteType.Town);
                List <Line>     lines = db.Lines.GetAll().ToList();
                List <LinePlus> ret   = new List <LinePlus>();

                foreach (Line l in lines)
                {
                    LinePlus lp = new LinePlus()
                    {
                        Number = l.Number, IDtypeOfLine = 0, TypeOfLine = type.ToString(), Stations = l.Stations
                    };
                    ret.Add(lp);
                }

                return(ret);
            }
            else
            {
                RouteType type = Enums.RouteType.Town;
                if (typeOfLine == "Town")
                {
                    type = Enums.RouteType.Town;
                }
                else if (typeOfLine == "Suburban")
                {
                    type = Enums.RouteType.Suburban;
                }
                List <Line>     lines = db.Lines.GetAll().ToList();
                List <LinePlus> ret   = new List <LinePlus>();

                foreach (Line l in lines)
                {
                    if (l.RouteType == type)
                    {
                        LinePlus lp = new LinePlus()
                        {
                            Number = l.Number, IDtypeOfLine = 0, TypeOfLine = type.ToString(), Stations = l.Stations
                        };
                        ret.Add(lp);
                    }
                }

                return(ret);
            }
        }
Beispiel #31
0
 /// <inheritdoc/>
 public void SetRouteType(RouteType routeType)
 {
     if (RouteType != routeType)
     {
         _remainder = null;
     }
     else
     {
         return;
     }
     RouteType  = routeType;
     _increase  = Increase;
     BeginIndex = BInd;
     EndIndex   = EInd;
     NextIndex  = NInd;
 }
Beispiel #32
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (MessageType != null ? MessageType.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ CommunicationType.GetHashCode();
         hashCode = (hashCode * 397) ^ RouteType.GetHashCode();
         hashCode = (hashCode * 397) ^ (int)Priority;
         hashCode = (hashCode * 397) ^ Exclusive.GetHashCode();
         hashCode = (hashCode * 397) ^ (LocalContext != null ? LocalContext.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (RemoteBoundedContext != null ? RemoteBoundedContext.GetHashCode() : 0);
         hashCode = m_Hints.Keys.OrderBy(k => k).Aggregate(hashCode, (h, key) => (h * 397) ^ key.GetHashCode());
         hashCode = m_Hints.Values.OrderBy(v => v).Aggregate(hashCode, (h, value) => (h * 397) ^ (value != null?value.GetHashCode():0));
         return(hashCode);
     }
 }
Beispiel #33
0
//	public static void ClearConsole()
//	{
//		var assembly = Assembly.GetAssembly(typeof(SceneView));
//		var type = assembly.GetType("UnityEditor.LogEntries");
//		var method = type.GetMethod("Clear");
//		method.Invoke(new object(), null);
//	}

    void RouteFinished(RouteType routeType, TargetController target)
    {
        if (_targetsStarted)
        {
            if (routeType == RouteType.Left)
            {
                _routeIndexLeft = GetRandomIndex(_routeIndexLeft, _recieverRoutesLeft);
                StartTarget(_recieverRoutesLeft, _routeIndexLeft, RouteType.Left);
            }
            if (routeType == RouteType.Right)
            {
                _routeIndexRight = GetRandomIndex(_routeIndexRight, _recieverRoutesRight);
                StartTarget(_recieverRoutesRight, _routeIndexRight, RouteType.Right);
            }
        }
    }
Beispiel #34
0
        private string GetKewordByRoutType(RouteType routeType)
        {
            string keyword = null;

            switch (routeType)
            {
            case RouteType.Commands:
                keyword = _commandsKeyword;
                break;

            case RouteType.Events:
                keyword = _eventsKeyword;
                break;
            }
            return(keyword ?? routeType.ToString().ToLower());
        }
Beispiel #35
0
        protected Route(RouteType type, string id, Airport destination1, Airport destination2, DateTime startDate)
        {
            Type = type;
            Id = id;
            Destination1 = destination1;
            Destination2 = destination2;
            StartDate = startDate;

            TimeTable = new RouteTimeTable(this);
            Invoices = new Invoices();
            Statistics = new RouteStatistics();
            Banned = false;
            Stopovers = new List<StopoverRoute>();

            Season = Weather.Season.AllYear;
        }
Beispiel #36
0
            internal override Route ReadEntry(BinaryReaderEx br)
            {
                RouteType type = br.GetEnum32 <RouteType>(br.Position + 0x10);

                switch (type)
                {
                case RouteType.MufflingPortalLink:
                    return(MufflingPortalLinks.EchoAdd(new Route.MufflingPortalLink(br)));

                case RouteType.MufflingBoxLink:
                    return(MufflingBoxLinks.EchoAdd(new Route.MufflingBoxLink(br)));

                default:
                    throw new NotImplementedException($"Unimplemented route type: {type}");
                }
            }
        public async Task<Route> CalculateRouteAsync(IList<AddressSearch> addressSearches, RouteType routeType)
        {

            if (addressSearches == null || addressSearches.Count() == 0)
            {
                throw new ArgumentException("Address cannot be null or empty.");
            }

            var tasks = addressSearches.Select(async search =>
            {
                var coordinate = await _coordinateFinder.FindCoordinateAsync(search);

                search.SetCoordinate(coordinate);
            });

            await Task.WhenAll(tasks);

            var result = await _routeCalculator.CalcuteRouteAsync(addressSearches, routeType);

            return result;
        }
        private RouteCost RequestRouteCost(RouteType routeType)
        {
            _routeDetails = new RouteDetails();
            _routeDetails.descriptionType = Config.DesciptionType;
            _routeDetails.optimizeRoute = true;
            _routeDetails.routeType = Convert.ToInt32(routeType);

            _routeOptions.routeDetails = _routeDetails;

            using (var routeSoapClient = new RouteSoapClient())
            {
                _routeInfo = routeSoapClient.getRoute(GenerateRouteStop(), _routeOptions, _token);
            }

            return new RouteCost
            {
                TotalDistance = _routeInfo.routeTotals.totalDistance,
                TotalFuelCost = _routeInfo.routeTotals.totalfuelCost,
                TotalCostWithToll = _routeInfo.routeTotals.totalCost,
                TotalTimeRote = _routeInfo.routeTotals.totalTime
            };
        }
Beispiel #39
0
 private static void DrawRoute(RouteType type, RouteDrawer r, Graphics g)
 {
     if (r != null)
     {
         Pen MyPen;
         switch (type)
         {
             case RouteType.EDAGE:
                 MyPen = new Pen(Color.Red, 2);
                 Paint(r, g, MyPen);
                 break;
             case RouteType.GROUP:
                 MyPen = new Pen(Color.LightBlue, 3);
                 Paint(r, g, MyPen);
                 break;
             case RouteType.NORMAL:
                 MyPen = new Pen(Color.White, 1);
                 Paint(r, g, MyPen);
                 break;
         }
     }
 }
        public RouteOptions GetRouteOptions(RouteType type, string language = "", Vehicle vehicle = null)
        {
            var options = new RouteOptions
            {
                language = string.IsNullOrWhiteSpace(language) ? "portugues" : language,
                routeDetails = new RouteDetails
                {
                    descriptionType = (int)DescriptionRoute.UrbanRoute,
                    routeType = (int)type
                }
            };

            if (vehicle != null)
            {
                options.vehicle = vehicle;
            }
            else
            {
                options.vehicle = GetDefaultVehicle();
            }

            return options;
        }
Beispiel #41
0
        public void autoRoute(int width, int height, RouteType route)
        {
            // キャンパスとの対応を確認 //
            int bmpAspect = _bmp.Width / _bmp.Height;
            int campusAspect = width / height;

            if (bmpAspect == campusAspect)
            {
                return;
            }

            // 指定方向に回転 //
            switch (route)
            {
                case RouteType.right:
                    _bmp.RotateFlip(RotateFlipType.Rotate90FlipNone);
                    break;

                case RouteType.left:
                    _bmp.RotateFlip(RotateFlipType.Rotate270FlipNone);
                    break;

            }
        }
Beispiel #42
0
 /// <summary>
 /// 导航开始
 /// </summary>
 /// <param name="source"></param>
 /// <param name="destination"></param>
 /// <param name="type"></param>
 void _bTipControl_DirecttionStarted(string source, string destination, RouteType type)
 {
     if (BDirectionBoard != null)
     {
         BDirectionBoard.SourcePlace = source;
         BDirectionBoard.DestinationPlace = destination;
     }
 }
Beispiel #43
0
        /// <summary>
        /// This is the required constructor for the type.
        /// </summary>
        /// <param name="RouteID"></param>
        /// <param name="AgencyID"></param>
        /// <param name="NameShort"></param>
        /// <param name="NameLong"></param>
        /// <param name="Description"></param>
        /// <param name="RouteType"></param>
        /// <param name="RouteColor"></param>
        /// <param name="RouteTextColor"></param>
        /// <param name="RouteUrl"></param>
        public Route(
            string RouteID,
            string AgencyID,
            string NameShort,
            string NameLong,
            string Description,
            RouteType RouteType,
            string RouteColor,
            string RouteTextColor,
            Uri RouteUrl
            )
        {
            mRouteID=RouteID ;
            mAgencyID = AgencyID;

            mShortName=NameShort ;
            mLongName=NameLong ;
            mDesc=Description ;

            mRouteType=RouteType ;
            mRouteUrl=RouteUrl ;
            mRouteColor=RouteColor ;
            mRouteTextColor=RouteTextColor ;
        }
Beispiel #44
0
 public Route(RouteType routeType, IEnumerable<ICallHandler> handlers)
 {
     _isRecordReplayRoute = routeType == RouteType.RecordReplay;
     _handlers = handlers;
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="locations"></param>
 /// <param name="routeType"></param>
 /// <param name="drivingStyle"></param>
 /// <param name="avoids"></param>
 /// <param name="enhancedNarrative"></param>
 /// <param name="metric"></param>
 /// <param name="fuelEfficiency"></param>
 /// <returns></returns>
 public static Directions getDirections(List<Locations> locations, StaticMap.MapType mapType, RouteType routeType = RouteType.Fastest, DrivingStyle drivingStyle = DrivingStyle.Normal, List<Avoids> avoids = null, bool enhancedNarrative = false, bool metric = false, int fuelEfficiency = 21)
 {
     if (locations.Count == 0)
         return new Directions();
     if (locations.Count == 1)
     {
         //Front end request an empty direction with the map of the location
         Directions d = new Directions();
         d.mainMap = locations[0].map;
         d.mapDetails = locations[0].mapDetails;
         d.mapDetails.mapType = mapType;
         d.legs.Add(new Leg());
         d.legs[0].maneuvers.Add(new Maneuver());
         return d;
     }
     WebClient w = new WebClient();
     string url = ConfigurationManager.AppSettings["MapQuestDirectionsURL"] + ConfigurationManager.AppSettings["MapQuestAPIKey"];
     if (avoids != null)
     {
         foreach (Avoids a in avoids)
             switch (a)
             {
                 case Avoids.CountryBorderCrossing:
                     url += "&avoids=Country border";
                     break;
                 case Avoids.Ferry:
                     url += "&avoids=Ferry";
                     break;
                 case Avoids.LimitedAccess:
                     url += "&avoids=Limited Access";
                     break;
                 case Avoids.SeasonalClosure:
                     url += "&avoids=Approximate Seasonal Closure";
                     break;
                 case Avoids.TollRoad:
                     url += "&avoids=Toll road";
                     break;
                 case Avoids.Unpaved:
                     url += "&avoids=Unpaved";
                     break;
                 default:
                     break;
             }
     }
     url += "&outFormat=json";
     switch (routeType)
     {
         case RouteType.Fastest:
             url += "&routeType=fastest";
             break;
         case RouteType.Shortest:
             url += "&routeType=shortest";
             break;
         case RouteType.Pedestrian:
             url += "&routeType=pedestrian";
             break;
         case RouteType.Bicycle:
             url += "&routeType=bicycle";
             break;
         case RouteType.Multimodal:
             url += "&routeType=multimodal";
             break;
         default:
             url += "&routeType=fastest";
             break;
     }
     url += "&timeType=1";
     url += (enhancedNarrative ? "&enhancedNarrative=true" : "&enhancedNarrative=false");
     url += "&shapeFormat=raw&generalize=0";
     url += ConfigurationManager.AppSettings["MapQuestDirectionsLocale"];
     url += (metric ? "&unit=k" : "&unit=m");
     for (int i = 1; i < locations.Count; ++i)
     {
         url += ("&from=" + locations[i - 1].latLng.lat + ',' + locations[i - 1].latLng.lng
             + "&to=" + locations[i].latLng.lat + ',' + locations[i].latLng.lng);
     }
     url += "&drivingStyle=";
     switch (drivingStyle)
     {
         case DrivingStyle.Aggressive:
             url += "3";
             break;
         case DrivingStyle.Cautious:
             url += "1";
             break;
         case DrivingStyle.Normal:
             url += "2";
             break;
         default:
             url += "2";
             break;
     }
     url += "&highwayEfficiency=" + fuelEfficiency;
     JsonSerializerSettings s = new JsonSerializerSettings();
     s.NullValueHandling = NullValueHandling.Ignore;
     s.ObjectCreationHandling = ObjectCreationHandling.Replace;
     Directions result = JsonConvert.DeserializeObject<DirectionsRootObject>(w.DownloadString(url), s).route;
     result.mapDetails.mapType = mapType;
     return result;
 }
Beispiel #46
0
        /// <summary>
        /// This is the CSV row item constructor.
        /// </summary>
        /// <param name="item">The CSV row item.</param>
        public Route(CSVRowItem item)
        {
            mRouteID = item.ValidateNotEmptyOrNull("route_id");

            mAgencyID = item["agency_id"];

            mLongName = item["route_long_name"];
            mShortName = item["route_short_name"];

            if ((mShortName == null || mShortName == "") && (mLongName == null || mLongName == ""))
                throw new ArgumentException("Must specify either route_long_name or route_short_name");

            if (mShortName == null || mShortName == "")
                mShortName = mLongName;
            else if (mLongName == null || mLongName == "")
                mLongName = mShortName;

            mDesc = item["route_desc"];

            mRouteType=item["route_type"].ToRouteType();

            string url = item["route_url"];
            mRouteUrl = url == null || url ==""?null:new Uri(url);

            mRouteColor = item["route_color"];
            mRouteTextColor = item["route_text_color"];
        }
Beispiel #47
0
 /// <summary>
 /// By default, the role mask is 0: no role.
 /// The application determines how the uint bits determine role permissions.
 /// Any bits that are set with a binary "and" of the route's role mask and the current role passes the authorization test.
 /// </summary>
 public RouteInfo(Type receptorSemanticType, RouteType routeType = RouteType.PublicRoute, uint roleMask = 0)
 {
     ReceptorSemanticType = receptorSemanticType;
     RouteType = routeType;
     RoleMask = roleMask;
 }
Beispiel #48
0
 //-------------------------------------------------------------------------
 public override void load(EbPropSet prop_set)
 {
     Name = prop_set.getPropString("T_Name").get();
     var prop_state = prop_set.getPropInt("I_State");
     State = prop_state == null ? DataState.Default : (DataState)prop_state.get();
     string strPoints = prop_set.getPropString("T_Points").get();
     if (!string.IsNullOrEmpty(strPoints))
     {
         ListPoints = new List<EbVector3>();
         string[] arrayPoints = strPoints.Split(';');
         bool is_x = true;
         float x = 0;
         foreach (var it in arrayPoints)
         {
             if (is_x)
             {
                 x = float.Parse(it);
                 is_x = false;
             }
             else
             {
                 ListPoints.Add(new EbVector3(x, float.Parse(it), 0));
                 is_x = true;
             }
         }
     }
     var prop_type = prop_set.getPropInt("I_Type");
     Type = prop_type == null ? RouteType.Default : (RouteType)prop_type.get();
     var prop_routecategory = prop_set.getPropInt("I_RouteCategory");
     routeCategory = prop_routecategory == null ? RouteCategory.Default : (RouteCategory)prop_routecategory.get();
 }
Beispiel #49
0
 private static void DrawRoutes(RouteType type, RouteDrawer[] r, Graphics g)
 {
     for (int i = 0; i < r.GetLength(0); i++)
     {
         DrawRoute(type, r[i], g);
     }
 }
Beispiel #50
0
 public void addRoute(List<DB_station> route, RouteType routeType)
 {
     m_routes.Add(route);
     m_routeTypes.Add(routeType);
 }
 public RouteCost Calculate(RouteType routeType)
 {
     return RequestRouteCost(routeType);
 }