public static List <TravelTimePolygonPath> CreatePolygonPaths(List <TravelTimeCircle> circles, double speed) { List <TravelTimePolygonPath> paths = new List <TravelTimePolygonPath>(); var clipper = new Clipper.Clipper(); foreach (var circle in circles) { clipper.AddPolygon(CreateCirclePolygon(circle.Center, circle.TimeLeft, 12, speed), PolyType.ptSubject); } List <List <IntPoint> > solution = new List <List <IntPoint> >(); clipper.Execute(ClipType.ctUnion, solution, PolyFillType.pftPositive, PolyFillType.pftPositive); foreach (var solutionItem in solution) { var path = new TravelTimePolygonPath(); foreach (var intPoint in solutionItem) { path.Coords.Add(new LatLng(intPoint.X / 10000000.0, intPoint.Y / 10000000.0)); } paths.Add(path); } return(paths); }
private static TravelTimePolygonPath CreateEdgePolygonPath(int startIndex, int size, BitArray array, BitArray visitedArray, LatLngBounds bounds, out bool touchesOutside) { TravelTimePolygonPath path = new TravelTimePolygonPath(); // select value which identifies a wall bool wallValue = !array[startIndex]; touchesOutside = false; // start walking right const int startDirection = 2; int currentDirection = startDirection; int currentIndex = startIndex; // do until start point reached again while (startIndex != currentIndex || currentDirection != 2 || path.Coords.Count == 0) { // check left of walking direction bool outsideWall; if (IsWall(array, visitedArray, currentIndex, size, (currentDirection - 1 + 4) % 4, wallValue, out outsideWall)) { // if there is ONE outside wall - it touches outside touchesOutside = outsideWall || touchesOutside; // add wall left of walking direction path.Coords.Add(GetWallCordinates(currentIndex, size, (currentDirection - 1 + 4) % 4, bounds)); // check in front if (IsWall(array, visitedArray, currentIndex, size, currentDirection, wallValue, out outsideWall)) { // turn right currentDirection = (currentDirection + 1) % 4; } else { currentIndex = GetNextIndexInDirection(currentIndex, size, currentDirection).Value; } } else { // turn left & make one step currentDirection = (currentDirection - 1 + 4) % 4; currentIndex = GetNextIndexInDirection(currentIndex, size, currentDirection).Value; } } return(path); }