public void GetElementID() { RegularGrid regularGrid = new RegularGrid(100, 200, 10, 3, 4, 0.0); Assert.AreEqual("105_235", regularGrid.GetElementID(0)); Assert.AreEqual("125_205", regularGrid.GetElementID(11)); }
public void GetElementIndex() { RegularGrid regularGrid = new RegularGrid(100, 200, 10, 3, 4, 0.0); Assert.AreEqual(0, regularGrid.GetElementIndex("105_235")); Assert.AreEqual(11, regularGrid.GetElementIndex("125_205")); }
public void GetVertexCount() { RegularGrid regularGrid = new RegularGrid(100, 200, 10, 3, 4, 0.0); Assert.AreEqual(4, regularGrid.GetVertexCount(0)); Assert.AreEqual(4, regularGrid.GetVertexCount(11)); }
public void Creat(GraphicsLayer layer, RegularGrid grid) { _GraphicsLayer = layer; var cellsize = grid.CellSize * 0.5; var polygon = new Polygon(); for (int i = 0; i < grid.NCell; i++) { var symbol = GetDefaultSymbol(polygon, System.Windows.Media.Colors.White); ESRI.ArcGIS.Client.Geometry.PointCollection pc = new ESRI.ArcGIS.Client.Geometry.PointCollection(); var buf = SpatialReferenceSystem.ToWebMercator(grid.CentroidX[i] - cellsize, grid.CentroidY[i] + cellsize); MapPoint p1 = new MapPoint(buf[0], buf[1]); buf = SpatialReferenceSystem.ToWebMercator(grid.CentroidX[i] + cellsize, grid.CentroidY[i] + cellsize); MapPoint p2 = new MapPoint(buf[0], buf[1]); buf = SpatialReferenceSystem.ToWebMercator(grid.CentroidX[i] + cellsize, grid.CentroidY[i] - cellsize); MapPoint p3 = new MapPoint(buf[0], buf[1]); buf = SpatialReferenceSystem.ToWebMercator(grid.CentroidX[i] - cellsize, grid.CentroidY[i] - cellsize); MapPoint p4 = new MapPoint(buf[0], buf[1]); buf = SpatialReferenceSystem.ToWebMercator(grid.CentroidX[i] - cellsize, grid.CentroidY[i] + cellsize); MapPoint p5 = new MapPoint(buf[0], buf[1]); pc.Add(p1); pc.Add(p2); pc.Add(p3); pc.Add(p4); pc.Add(p5); Graphic graphic = new Graphic(); Polygon ep = new Polygon(); ep.Rings.Add(pc); graphic.Geometry = ep; graphic.Symbol = symbol; graphic.Attributes.Add("ID", i); layer.Graphics.Add(graphic); } }
public void CreateSmallElementSets() { RegularGrid regularGrid = new RegularGrid(10, 10, 20, 2, 2, 0); regularGrid = new RegularGrid(10, 10, 20, 1, 2, 0); regularGrid = new RegularGrid(10, 10, 20, 2, 1, 0); regularGrid = new RegularGrid(10, 10, 20, 1, 1, 0); }
private void DrawRegularGrid(RegularGrid grid) { var bitmap = grid.GridGraphics.Bitmap; var drawPosition = MapToScreen(grid.Position.X, grid.Position.Y); var size = new Size((int)(grid.Width * scale), (int)(grid.Height * scale)); var drawArea = new Rectangle(drawPosition, size); graphics.DrawImage(bitmap, drawArea); }
public void GetYCoordinate() { RegularGrid regularGrid = new RegularGrid(100, 200, 10, 3, 4, 0.0); Assert.AreEqual(230.0, regularGrid.GetYCoordinate(0, 0)); Assert.AreEqual(230.0, regularGrid.GetYCoordinate(0, 1)); Assert.AreEqual(240.0, regularGrid.GetYCoordinate(0, 2)); Assert.AreEqual(240.0, regularGrid.GetYCoordinate(0, 3)); Assert.AreEqual(200.0, regularGrid.GetYCoordinate(11, 0)); Assert.AreEqual(200.0, regularGrid.GetYCoordinate(11, 1)); Assert.AreEqual(210.0, regularGrid.GetYCoordinate(11, 2)); Assert.AreEqual(210.0, regularGrid.GetYCoordinate(11, 3)); }
public void GetValue_GetNotExistingValue_ValueEqualNull() { var matrix = new double?[, ] { { 1, 2, 3, 2 }, { 2, null, 2, 3 }, { 3, 2, 3, 2 }, { 2, 3, 2, 4 }, }; var position = new Node <double>(2, 9); var grid = new RegularGrid(matrix, position, 2); double?zCenter = grid.GetValue(3, 6); Assert.Null(zCenter); }
public void GetZCoordinate() { RegularGrid regularGrid = new RegularGrid(100, 200, 10, 3, 4, 0.0); bool exceptionWasThrown = false; try { regularGrid.GetZCoordinate(5, 0); } catch (Exception ex) { Assert.IsTrue(ex.GetType() == typeof(Exception)); exceptionWasThrown = true; } Assert.IsTrue(exceptionWasThrown); }
public void GetValue_GetExistingValue_ValueEqualExpected() { var matrix = new double?[, ] { { 1, 2, 3, 2 }, { 2, 1, 2, 3 }, { 1, 2, 3, 2 }, { 2, 3, 2, 4 }, }; var position = new Node <double>(2, 9); var grid = new RegularGrid(matrix, position, 2); double?zCenter = grid.GetValue(3, 6); Assert.Equal(1.5, zCenter); }
public void SpatialReference() { RegularGrid regularGrid = new RegularGrid(100, 200, 10, 3, 4, 0.0); Assert.AreEqual(new SpatialReference("no reference"), regularGrid.SpatialReference); }
public void Description() { RegularGrid regularGrid = new RegularGrid(100, 200, 10, 3, 4, 0.0); Assert.AreEqual("Regular Grid", regularGrid.Description); }
public IGrid Generate() { if (Source == null) { Source = new RegularGrid(); } if (Domain != null) { Source.Origin = this.Origin; Source.ActualLayerCount = this.LayerCount; Source.RowCount = RowCount; Source.ColumnCount = ColumnCount; Source.IBound = new DataCube <float>(this.LayerCount, RowCount, ColumnCount); Source.DELC = new DataCube <float>(1, 1, RowCount); Source.DELR = new DataCube <float>(1, 1, ColumnCount); Source.DELC.Flags[0, 0] = TimeVarientFlag.Constant; Source.DELR.Flags[0, 0] = TimeVarientFlag.Constant; Source.DELC.Constants[0, 0] = this.XSize; Source.DELR.Constants[0, 0] = this.YSize; Source.DELC.ILArrays[0]["0", ":"] = this.XSize; Source.DELR.ILArrays[0]["0", ":"] = this.YSize; Source.Projection = Domain.Projection; Source.BBox = new Envelope(Domain.Extent.MinX, Domain.Extent.MaxX, Domain.Extent.MinY, Domain.Extent.MaxY); int active = 0; var geo = Domain.Features[0].Geometry.Coordinates; List <Coordinate> centroids = new List <Coordinate>(); for (int r = 0; r < RowCount; r++) { for (int c = 0; c < ColumnCount; c++) { var cor = Source.LocateCentroid(c + 1, r + 1); if (SpatialRelationship.PointInPolygon(geo, cor)) { for (int l = 0; l < Source.ActualLayerCount; l++) { Source.IBound[l, r, c] = 1; } active++; centroids.Add(cor); } } } Source.ActiveCellCount = active; Source.Elevations = new DataCube <float>(Source.LayerCount, 1, active); Source.Elevations.Variables[0] = "Top Elevation"; for (int i = 0; i < active; i++) { //var cell = DEM.ProjToCell(centroids[i]); //if (cell != null && cell.Row > 0) // Source.Elevations.Value[0][0][i] = (float)DEM.Value[cell.Row, cell.Column]; //else // Source.Elevations.Value[0][0][i] = 0; var pt = new Coordinate(centroids[i].X - 0.5 * XSize, centroids[i].Y - 0.5 * YSize); Source.Elevations[0, 0, i] = ZonalStatastics.GetCellAverage(DEM, pt, XSize, AveragingMethod); } for (int l = 1; l < Source.LayerCount; l++) { Source.Elevations.Variables[l] = string.Format("Layer {0} Bottom Elevation", l); for (int i = 0; i < active; i++) { Source.Elevations[l, 0, i] = (float)(Source.Elevations[l - 1, 0, i] - LayerGroups[l - 1].LayerHeight); } } Source.BuildTopology(); Source.Elevations.Topology = Source.Topology; } else { Error = "The domain featureset is null"; } return(Source); }
private double?SearchRegularGrid(RegularGrid grid) => grid.GetValue(searchPoint.X, searchPoint.Y);
public void ID() { RegularGrid regularGrid = new RegularGrid(100, 200, 10, 3, 4, 0.0); Assert.AreEqual("RegularGrid", regularGrid.ID); }
public void GetFaceVertexIndices() { RegularGrid regularGrid = new RegularGrid(100, 200, 10, 3, 4, 0.0); Assert.AreEqual(null, regularGrid.GetFaceVertexIndices(0, 0)); }
public void ElementType() { RegularGrid regularGrid = new RegularGrid(100, 200, 10, 3, 4, 0.0); Assert.AreEqual(global::OpenMI.Standard.ElementType.XYPolygon, regularGrid.ElementType); }
public RegularGridGraphics(RegularGrid grid) { this.grid = grid; nullColor = Color.FromArgb(0, 0, 0, 0); }
public void Version() { RegularGrid regularGrid = new RegularGrid(100, 200, 10, 3, 4, 0.0); Assert.AreEqual(0, regularGrid.Version); }
public void ElementCount() { RegularGrid regularGrid = new RegularGrid(100, 200, 10, 3, 4, 0.0); Assert.AreEqual(12, regularGrid.ElementCount); }