private MeanOfTransport GetMeanOfTransport() { MeanOfTransport mot = 0; if (busCheckBox.Checked) { mot |= MeanOfTransport.Bus; } if (subwayCheckBox.Checked) { mot |= MeanOfTransport.Subway; } if (tramCheckBox.Checked) { mot |= MeanOfTransport.Tram; } if (trainCheckBox.Checked) { mot |= MeanOfTransport.Rail; } if (shipCheckBox.Checked) { mot |= MeanOfTransport.Ship; } if (cablecarCheckBox.Checked) { mot |= MeanOfTransport.CableCar | MeanOfTransport.Funicular | MeanOfTransport.Gondola; } return(mot); }
/// <summary> /// Gets predefined means of transport that can be used. /// </summary> public static MeanOfTransport GetMoT() { MeanOfTransport mot = 0; if (AllowBus) { mot |= MeanOfTransport.Bus; } if (AllowCablecar) { mot |= MeanOfTransport.CableCar | MeanOfTransport.Funicular | MeanOfTransport.Gondola; } if (AllowShip) { mot |= MeanOfTransport.Ship; } if (AllowSubway) { mot |= MeanOfTransport.Subway; } if (AllowTrain) { mot |= MeanOfTransport.Rail; } if (AllowTram) { mot |= MeanOfTransport.Tram; } return(mot); }
public RouteInfoBasic(int id, string label, MeanOfTransport type, CPColor c, CPColor tc) { ID = id; Label = label; MeanOfTransport = type; Color = c; TextColor = tc; }
public RouterRequest(int sourceStationID, int targetStationID, DateTime departureDateTime, int transfers, DateTime arrivalTime, double coefficient, MeanOfTransport mot) { SourceStationID = sourceStationID; TargetStationID = targetStationID; EarliestDepartureDateTime = ConvertDateTimeToUnixTimestamp(departureDateTime); MaxTransfers = transfers; MaximalArrivalDateTime = ConvertDateTimeToUnixTimestamp(arrivalTime); TransfersDurationCoefficient = coefficient; MeansOfTransport = mot; }
public Models.Route GetRoute(Coordinates from, Coordinates to, MeanOfTransport meanOfTransport) { var request = new RestRequest { Resource = $"route/v1/driving/{from.Longitude.ToString(CultureInfo.InvariantCulture)}" + $",{from.Latitude.ToString(CultureInfo.InvariantCulture)};" + $"{to.Longitude.ToString(CultureInfo.InvariantCulture)}," + $"{to.Latitude.ToString(CultureInfo.InvariantCulture)}?geometries=geojson" }; var response = _restClient.Execute <RouteResponse>(request); if (!response.IsSuccessful) { return(null); } var route = response.Data.MapToRoute(); return(route); }
public IRouteFinderService GetService(MeanOfTransport meanOfTransport) { var service = _services.FirstOrDefault(x => x.IsValidFor(meanOfTransport)); return(service ?? throw new Exception($"Mean of transport: {meanOfTransport} is not supported.")); }
/// <summary> /// Tries to obtain journeys and returns window with results. /// </summary> /// <param name="sourceName">Source station name.</param> /// <param name="targetName">Target station name.</param> /// <param name="dt">Datetime.</param> /// <param name="transfers">Max transfers.</param> /// <param name="count">Number of journeys.</param> /// <param name="coefficient">Coefficient for the footpaths.</param> /// <param name="mot">Mean of transport.</param> /// <param name="win">Window with request.</param> /// <param name="comp">Comparer for journeys.</param> /// <returns>Window with results</returns> public static async Task <JourneyResultsWindow> GetRouterWindowAsync(string sourceName, string targetName, DateTime dt, int transfers, int count, double coefficient, MeanOfTransport mot, NewJourneyWindow win, IComparer <Journey> comp = null) { Structures.Basic.StationsBasic.StationBasic source = GetStationFromString(sourceName); Structures.Basic.StationsBasic.StationBasic target = GetStationFromString(targetName); if (source == null || target == null) { return(null); } var routerRequest = new RouterRequest(source.ID, target.ID, dt, transfers, count, coefficient, mot); var routerResponse = await SendRouterRequestAsync(routerRequest); if (comp != null && routerResponse != null) { routerResponse.Journeys.Sort(comp); } return(routerResponse == null ? null : new JourneyResultsWindow(routerResponse, source.Name, target.Name, dt, win)); }
public bool IsValidFor(MeanOfTransport meanOfTransport) { return(meanOfTransport == MeanOfTransport.Car); }
public Route GetRoute(Coordinates from, Coordinates to, MeanOfTransport meanOfTransport) { var service = _serviceFactory.GetService(meanOfTransport); return(service.GetRoute(from, to, meanOfTransport)); }