public Route(OnlineMapsXML node) { List <Leg> legs = new List <Leg>(); List <int> waypointOrder = new List <int>(); List <string> warnings = new List <string>(); foreach (OnlineMapsXML n in node) { if (n.name == "summary") { summary = n.Value(); } else if (n.name == "leg") { legs.Add(new Leg(n)); } else if (n.name == "copyrights") { copyrights = n.Value(); } else if (n.name == "overview_polyline") { overview_polyline = OnlineMapsUtils.DecodePolylinePoints(n["points"].Value()).ToArray(); } else if (n.name == "waypoint_index") { waypointOrder.Add(n.Value <int>()); } else if (n.name == "warning") { warnings.Add(n.Value()); } else if (n.name == "fare") { fare = new Fare(n); } else if (n.name == "bounds") { OnlineMapsXML sw = n["southwest"]; OnlineMapsXML ne = n["northeast"]; bounds = new OnlineMapsGPXObject.Bounds(sw.Get <double>("lng"), sw.Get <double>("lat"), ne.Get <double>("lng"), ne.Get <double>("lat")); } else { Debug.Log("Route: " + n.name + "\n" + n.outerXml); } } this.legs = legs.ToArray(); waypoint_order = waypointOrder.ToArray(); this.warnings = warnings.ToArray(); }
/// <summary> /// Constructor. \n /// Use OnlineMapsDirectionStep.TryParse. /// </summary> /// <param name="node">XMLNode of route</param> private OnlineMapsDirectionStep(OnlineMapsXML node) { start = node.GetLatLng("start_location"); end = node.GetLatLng("end_location"); duration = node.Find <int>("duration/value"); instructions = node.Find <string>("html_instructions"); GetStringInstructions(); distance = node.Find <int>("distance/value"); maneuver = node.Find <string>("maneuver"); string encodedPoints = node.Find <string>("polyline/points"); points = OnlineMapsUtils.DecodePolylinePoints(encodedPoints); }
public static List <Vector2> DecodePolylinePoints(string encodedPoints) { return(OnlineMapsUtils.DecodePolylinePoints(encodedPoints)); }
public Step(OnlineMapsXML node) { List <Step> steps = new List <Step>(); foreach (OnlineMapsXML n in node) { if (n.name == "travel_mode") { travel_mode = n.Value(); } else if (n.name == "start_location") { start_location = OnlineMapsXML.GetVector2FromNode(n); } else if (n.name == "end_location") { end_location = OnlineMapsXML.GetVector2FromNode(n); } else if (n.name == "polyline") { polyline = OnlineMapsUtils.DecodePolylinePoints(n["points"].Value()).ToArray(); } else if (n.name == "duration") { duration = new TextValue <int>(n); } else if (n.name == "distance") { distance = new TextValue <int>(n); } else if (n.name == "step") { steps.Add(new Step(n)); } else if (n.name == "html_instructions") { html_instructions = n.Value(); if (string.IsNullOrEmpty(html_instructions)) { return; } string_instructions = OnlineMapsDirectionStep.StrReplace(html_instructions, new[] { "<", ">", " ", "&", "&nbsp;" }, new[] { "<", ">", " ", "&", " " }); string_instructions = Regex.Replace(string_instructions, "<div.*?>", "\n"); string_instructions = Regex.Replace(string_instructions, "<.*?>", string.Empty); } else if (n.name == "maneuver") { maneuver = n.Value(); } else if (n.name == "transit_details") { transit_details = new TransitDetails(n); } else { Debug.Log("Step: " + n.name + "\n" + n.outerXml); } } this.steps = steps.ToArray(); }