/// <summary> /// Overrides dispose to correctly handle disposing the objects at the raster level. /// </summary> /// <param name="disposeManagedResources"></param> protected override void Dispose(bool disposeManagedResources) { if (disposeManagedResources) { if (Bands != null) { foreach (IRaster r in Bands) { r.Dispose(); } Bands = null; Bounds = null; CustomFileType = null; DriverCode = null; Filename = null; Notes = null; Options = null; _rows = null; _tag = null; _values = null; } } if (Bands != null) { foreach (IRaster r in Bands) { if (!r.IsDisposeLocked) { r.Dispose(); } } Bands = null; } base.Dispose(disposeManagedResources); }
static private void Hoi(IValueGrid src, double nodata, double xllcenter, double yllcenter, double cellsize, int nrow, int ncol, IValueGrid output) { double todeg = 180.0 / Math.PI; for (int i = 1; i < nrow - 1; i++) { bool flg = false; double dx3 = 0; double dy3 = 0; for (int j = 1; j < ncol - 1; j++) { if (Check8(src, nodata, j, i) == false) { continue; } if (flg == false) { Dxdy(j, i, xllcenter, yllcenter, cellsize, out dx3, out dy3); dx3 = dx3 * 3; dy3 = dy3 * 3; flg = true; } double Hx = (src[i - 1, j - 1] + src[i, j - 1] + src[i + 1, j - 1] - (src[i - 1, j + 1] + src[i, j + 1] + src[i + 1, j + 1])) / (dx3); double Hy = (src[i + 1, j - 1] + src[i + 1, j] + src[i + 1, j + 1] - (src[i - 1, j - 1] + src[i - 1, j] + src[i - 1, j + 1])) / (dy3); double sita = Math.Atan(Hx / Hy) * todeg; if (Hy < 0) { sita = sita + 180; } output[i - 1, j - 1] = sita; if ((Hy == 0) && (Hx == 0)) { output[i - 1, j - 1] = nodata; } } } }
static private bool Check8(IValueGrid grd, double nodata, int x, int y) { if (grd[y - 1, x - 1] == nodata) { return(false); } if (grd[y, x - 1] == nodata) { return(false); } if (grd[y + 1, x - 1] == nodata) { return(false); } if (grd[y, x - 1] == nodata) { return(false); } if (grd[y, x + 1] == nodata) { return(false); } if (grd[y - 1, x + 1] == nodata) { return(false); } if (grd[y, x - 1] == nodata) { return(false); } if (grd[y + 1, x + 1] == nodata) { return(false); } return(true); }