public void Merge(Directions otherDirections) { foreach (var r in otherDirections.Routes) { Routes.Add(r); } }
public string GetGPX(Directions path) { var sw = new UTF8StringWriter(); var writer = new XmlTextWriter(sw); //XmlWriter.Create(builder, settings); writer.Formatting = Formatting.Indented; writer.WriteStartDocument(); writer.WriteStartElement("gpx"); WriteAttribute(writer, "version", "1.1"); WriteAttribute(writer, "creator", "TheFastWay.net"); writer.WriteStartElement("trk"); writer.WriteStartElement("trkseg"); WriteTrackPoints(writer, path); writer.WriteEndElement(); // trkseg writer.WriteEndElement(); // trk writer.WriteEndElement(); // gpx writer.WriteEndDocument(); writer.Flush(); writer.Close(); sw.Flush(); return sw.ToString(); }
protected override void Given() { path = new Directions(); path.Routes.Add(new Route(PointMother.EthelSt, PointMother.ChannelSt)); path.Routes.Add(new Route(PointMother.ChannelSt, PointMother.BeckwithSt)); service = container.Create<GPXService>(); }
protected override void Do() { try { result = service.Optimize(points); } catch (DBCException) { dBCExceptionThrown = true; } }
protected override void Do() { result = stitcher.Stitch(); }
public Directions CompleteCycle() { var temp = CurrentCycle; CompleteCycles.Add(CurrentCycle); CurrentCycle = new Directions(); return temp; }
private static Directions BuildSingleRouteDirections(Point[] points) { var directions = new Directions(); directions.Routes.Add(new Route(points[0], points[1])); return directions; }
private void WriteTrackPoints(XmlWriter writer, Directions path) { var points = path.Routes.Select(r => r.From).ToList(); points.Add(path.Routes[path.Routes.Count - 1].To); points.ForEach(point => WritePoint(writer, point)); }
public EdgePair FindClosestEdgePair(Directions firstCycle, Directions secondCycle) { var pairs = BuildEdgePairs(firstCycle, secondCycle); var minDistance = pairs.Min(p => p.Distance); return pairs.First(p => p.Distance == minDistance); }
private IList<EdgePair> BuildEdgePairs(Directions firstCycle, Directions secondCycle) { var pairs = new List<EdgePair>(); foreach (Edge e in firstCycle.Edges(graph)) { pairs.AddRange(BuildEdgePairs(e, secondCycle.Edges(graph))); } return pairs; }
private void AssertChannelEthelChannelCycle(Directions cycle) { Assert.AreEqual(2, cycle.Routes.Count); Assert.AreEqual(PointMother.ChannelSt, cycle.Routes[0].From); Assert.AreEqual(PointMother.EthelSt, cycle.Routes[0].To); Assert.AreEqual(PointMother.EthelSt, cycle.Routes[1].From); Assert.AreEqual(PointMother.ChannelSt, cycle.Routes[1].To); }
private void AssertBurchellBurchellCycle(Directions cycle) { Assert.AreEqual(1, cycle.Routes.Count); Assert.AreEqual(PointMother.BurchellSt, cycle.Routes[0].From); Assert.AreEqual(PointMother.BurchellSt, cycle.Routes[0].To); }
protected override void Do() { result = nav.GetCycle(); }
protected override void Do() { firstCycle = nav.GetCycle(); secondCycle = nav.GetCycle(); }
private Directions JoinTwoCycles(Directions firstCycle, Directions secondCycle, EdgePair edges) { var firstRoute = firstCycle.GetRoute(edges.FirstCycleEdge); var secondRoute = secondCycle.GetRoute(edges.SecondCycleEdge); var closest = graph.PickClosestPoint(firstRoute.From, edges.SecondCycleEdge.Vertices); firstCycle.AddRoute(firstRoute.From, closest); var otherEndOfSecondRoute = secondRoute.From.Equals(secondRoute.To) ? secondRoute.To : secondRoute.Points.Single(p => !p.Equals(closest)); firstCycle.AddRoute(otherEndOfSecondRoute, firstRoute.To); firstCycle.Merge(secondCycle); firstCycle.RemoveRoute(firstRoute); firstCycle.RemoveRoute(secondRoute); return firstCycle; }
protected override void Do() { result = service.Optimize(points); }
protected override void Given() { directions = new Directions(); directions.AddRoute(PointMother.USAPoints.UniversityAve, PointMother.USAPoints.LocustSt); directions.AddRoute(PointMother.USAPoints.LocustSt, PointMother.USAPoints.ShawSt); directions.AddRoute(PointMother.USAPoints.RaccoonSt, PointMother.USAPoints.UniversityAve); directions.AddRoute(PointMother.USAPoints.AshworthRd, PointMother.USAPoints.ShawSt); directions.AddRoute(PointMother.USAPoints.RaccoonSt, PointMother.USAPoints.AshworthRd); }