private double ProcessPathHaversine(IList <Vector2Int> path, FeatureLayer targetLayer) { double distance = 0; ICoordinate prevCoordinate = null; foreach (var cell in path) { ICoordinate coordinate = ProjectFromCellMap(cell + new Vector2Int(1, 0)); Feature pointFeature = new Feature(FeatureType.Point); PointD point = new PointD(coordinate); pointFeature.Point = point; targetLayer.AddFeature(pointFeature); if (prevCoordinate != null) { distance += Haversine.GetDistance(coordinate.Y, coordinate.X, prevCoordinate.Y, prevCoordinate.X); } prevCoordinate = coordinate; } Debug.WriteLine("Path finding finished!"); RedrawMap(); return(distance); }
private int ProcessPathCells(IList <Vector2Int> path, FeatureLayer targetLayer) { int distance = path.Count; foreach (var cell in path) { ICoordinate coordinate = ProjectFromCellMap(cell + new Vector2Int(1, 0)); Feature pointFeature = new Feature(FeatureType.Point); PointD point = new PointD(coordinate); pointFeature.Point = point; targetLayer.AddFeature(pointFeature); } Debug.WriteLine("Path finding finished!"); RedrawMap(); return(distance); }
private void TestUserYButton_Click(object sender, EventArgs e) { Feature polygonFeature = new Feature(FeatureType.Polygon); ICoordinate coordinate0 = _initialRectangle.Min; ICoordinate coordinate1 = ((ICoordinate)coordinate0.Clone()); coordinate1.Translate(0, DefaultCellSize * 20); ICoordinate coordinate2 = ((ICoordinate)coordinate0.Clone()); coordinate2.Translate(DefaultCellSize * 10, DefaultCellSize * 10); Polygon polygon = new Polygon(new [] { coordinate0, coordinate1, coordinate2 }); polygonFeature.Polygon = polygon; _userRegionLayer.AddFeature(polygonFeature); RedrawMap(); }