public List <GPSInstruction.Instruction> GetRoute(string currentlocation, string destination) { var uri = GetRoutingURI(currentlocation, destination); var response = GetURIResponseSynced(uri); RouteLeg leg = ((BingMapsRESTService.Common.JSON.Route)(response.ResourceSets[0].Resources[0])).RouteLegs[0]; var instructions = new GPSInstruction(((BingMapsRESTService.Common.JSON.Route)(response.ResourceSets[0].Resources[0])).RouteLegs[0].ItineraryItems); return(instructions.InstructionList); }
private RouteLeg GetLegByGoogleApi(Marker startPoint, Marker endPoint) { RouteLeg leg = googleApi.GetLegByGoogleApi(startPoint.Point, endPoint.Point); leg.StartPoint = startPoint.PointId; leg.EndPoint = endPoint.PointId; return(leg); }
private void GetTextDetailsOfRoute(RouteLeg leg) { routeText.Clear(); foreach (var itenary in leg.Itinerary) { Regex regex = new Regex("<[a-zA-z:@#$%^&*()~+?\\/0-9]*>"); var text = regex.Replace(itenary.Text, " "); routeText.Add(text.TrimEnd().TrimStart()); } }
private void DisplayDirections(RouteData routeData) { RouteLeg routeLeg = routeData.resourceSets[0].resources[0].routeLegs[0]; List <ItineraryItem> routePoints = routeLeg.itineraryItems; string routeInstructions = ""; for (int i = 0; i < routePoints.Count; i++) { routeInstructions += " " + (i + 1) + ". " + routePoints[i].instruction.text + "\n"; } routeDirectionsTextBlock.Text = routeInstructions; }
private static RouteInfoLeg AddInfoLegFromLeg(RouteLeg routeLeg) { RouteInfoLeg infoLeg = new RouteInfoLeg() { Distance = routeLeg.Distance, Duration = routeLeg.Duration, Summary = routeLeg.Summary, Steps = new List <RouteInfoStep>() }; foreach (RouteStep step in routeLeg.Steps) { infoLeg.Steps.Add(AddInfoStepFromStep(step)); } return(infoLeg); }
public MapSimpleRouteResponce GetRouteLegs(Marker[] markers) { List <RouteLeg> legsRequest = new List <RouteLeg>(); List <RouteLeg> legsRepos, legsResponce; for (int i = 0; i < markers.Count() - 1; i++) { RouteLeg leg = new RouteLeg() { StartPoint = markers[i].PointId, EndPoint = markers[i + 1].PointId }; legsRequest.Add(leg); } // Get All legs by this route from local DB legsResponce = dbSet .Where(repLeg => legsRequest.Any(r => r.StartPoint == repLeg.StartPoint && r.EndPoint == repLeg.EndPoint )).ToList(); var legsFromDbCount = legsResponce.Count(); legsRequest = legsRequest.Where(req => !legsResponce.Any(resp => resp.StartPoint == req.StartPoint && resp.EndPoint == req.EndPoint )).ToList(); foreach (var leg in legsRequest) { RouteLeg newLeg = GetLegByGoogleApi(markers.FirstOrDefault(m => m.PointId == leg.StartPoint), markers.FirstOrDefault(m => m.PointId == leg.EndPoint)); legsResponce.Add(newLeg); dbSet.Add(newLeg); } db.SaveChanges(); //return legsResponce; return(new MapSimpleRouteResponce() { Legs = legsResponce, LegsFromDbCount = legsFromDbCount }); }
private void DisplayMapRoute(RouteData routeData) { Resource resources = routeData.resourceSets[0].resources[0]; RouteLeg routeLeg = resources.routeLegs[0]; List <double> startLocationCoords = routeLeg.startLocation.point.coordinates; List <double> endLocationCoords = routeLeg.endLocation.point.coordinates; CenterMapToCoords(startLocationCoords[0], startLocationCoords[1]); DrawLocationPoint(startLocationCoords[0], startLocationCoords[1], routeLeg.startLocation.name); DrawLocationPoint(endLocationCoords[0], endLocationCoords[1], routeLeg.endLocation.name); List <List <double> > routePathCoords = resources.routePath.line.coordinates; for (int i = 0; i < routePathCoords.Count; i++) { if (i + 1 < routePathCoords.Count) { DrawMapLine(routePathCoords[i], routePathCoords[i + 1]); } } }