public static IRasterDataset TinToRaster(ITinAdvanced itinAdvanced_0, esriRasterizationType esriRasterizationType_0, string string_0, string string_1, string string_2, rstPixelType rstPixelType_0, double double_0, IEnvelope ienvelope_0, bool bool_0) { object obj3; IPoint lowerLeft = ienvelope_0.LowerLeft; lowerLeft.X -= double_0 * 0.5; lowerLeft.Y -= double_0 * 0.5; int num = ((int)Math.Round((double)(ienvelope_0.Width / double_0))) + 1; int num2 = ((int)Math.Round((double)(ienvelope_0.Height / double_0))) + 1; IGeoDataset dataset = itinAdvanced_0 as IGeoDataset; ISpatialReference2 spatialReference = dataset.SpatialReference as ISpatialReference2; IRasterDataset dataset2 = CreateRasterSurf(string_0, string_1, string_2, lowerLeft, num, num2, double_0, double_0, 1, rstPixelType_0, spatialReference, bool_0); IRawPixels rawPixels = GetRawPixels(dataset2, 0); object cache = rawPixels.AcquireCache(); ITinSurface pSurface = itinAdvanced_0 as ITinSurface; IRasterProps o = rawPixels as IRasterProps; double zMin = itinAdvanced_0.Extent.ZMin; if (rstPixelType_0 == rstPixelType.PT_FLOAT) { obj3 = (float)(zMin - 1.0); } else { obj3 = (int)(zMin - 1.0); } o.NoDataValue = obj3; IPnt tlc = new DblPnt(); int num4 = 2048; if (num < 2048) { num4 = num; } int num5 = 2048; if (num2 < 2048) { num5 = num2; } IPnt size = new DblPnt { X = num4, Y = num5 }; IPixelBlock3 block = rawPixels.CreatePixelBlock(size) as IPixelBlock3; ITrackCancel cancel = new CancelTracker { CancelOnClick = false, CancelOnKeyPress = true }; int num6 = (int)(Math.Round((double)((num / num4) + 0.49)) * Math.Round((double)((num2 / num5) + 0.49))); if (num6 == 1) { itinAdvanced_0.TrackCancel = cancel; } IPoint point2 = new Point(); object obj4 = block.get_PixelDataByRef(0); for (int i = 0; i < num2; i += num5) { for (int j = 0; j < num; j += num4) { if ((num - j) < num4) { size.X = num - j; block = rawPixels.CreatePixelBlock(size) as IPixelBlock3; obj4 = block.get_PixelDataByRef(0); } point2.X = (lowerLeft.X + (j * double_0)) + (double_0 * 0.5); point2.Y = (lowerLeft.Y + ((num2 - i) * double_0)) - (double_0 * 0.5); IGeoDatabaseBridge2 bridge = new GeoDatabaseHelper() as IGeoDatabaseBridge2; bridge.QueryPixelBlock(pSurface, point2.X, point2.Y, double_0, double_0, esriRasterizationType_0, obj3, ref obj4); tlc.X = j; tlc.Y = i; block.set_PixelData(0, obj4); rawPixels.Write(tlc, block as IPixelBlock); } bool flag = false; if (size.X != num4) { size.X = num4; flag = true; } if ((num2 - i) < num5) { size.Y = num2 - i; flag = true; } if (flag) { block = rawPixels.CreatePixelBlock(size) as IPixelBlock3; obj4 = block.get_PixelDataByRef(0); } } rawPixels.ReturnCache(cache); Marshal.ReleaseComObject(cache); cache = null; Marshal.ReleaseComObject(rawPixels); rawPixels = null; Marshal.ReleaseComObject(block); block = null; Marshal.ReleaseComObject(o); o = null; obj4 = 0; GC.Collect(); return(dataset2); }
public static IRasterDataset TinToRaster(ITinAdvanced itinAdvanced_0, esriRasterizationType esriRasterizationType_0, string string_0, string string_1, rstPixelType rstPixelType_0, double double_0, IEnvelope ienvelope_0, bool bool_0) { IPoint lowerLeft = ienvelope_0.LowerLeft; lowerLeft.X -= double_0 * 0.5; lowerLeft.Y -= double_0 * 0.5; int num = (int)Math.Round((double)((ienvelope_0.Width / double_0) + 1.0)); int num2 = (int)Math.Round((double)((ienvelope_0.Height / double_0) + 1.0)); IGeoDataset dataset = itinAdvanced_0 as IGeoDataset; ISpatialReference2 spatialReference = dataset.SpatialReference as ISpatialReference2; IRasterDataset dataset2 = CreateRasterSurf(string_0, string_1, "GRID", lowerLeft, num, num2, double_0, double_0, rstPixelType_0, spatialReference, true); IRasterBandCollection bands = dataset2 as IRasterBandCollection; IRawPixels pixels = bands.Item(0) as IRawPixels; ITinSurface pSurface = itinAdvanced_0 as ITinSurface; pSurface.RasterInterpolationMethod = esriSurfaceInterpolationType.esriNaturalNeighborInterpolation; IRasterProps props = pixels as IRasterProps; object noDataValue = props.NoDataValue; IPnt tlc = new DblPnt(); int num3 = 2048; int num4 = 2048; if (num < 2048) { num3 = num; } if (num2 < num4) { num4 = num2; } IPnt size = new DblPnt { X = num3, Y = num4 }; IPixelBlock pxls = pixels.CreatePixelBlock(size); object block = pxls.get_SafeArray(0); IPoint point2 = new Point(); for (int i = 0; i < num2; i += num4) { for (int j = 0; j < num; j += num3) { if ((num - j) < num3) { size.X = num - j; pxls = pixels.CreatePixelBlock(size); block = pxls.get_SafeArray(0); } point2.X = (lowerLeft.X + (j * double_0)) + (double_0 * 0.5); point2.Y = (lowerLeft.Y + ((num2 - i) * double_0)) - (double_0 * 0.5); IGeoDatabaseBridge2 bridge = new GeoDatabaseHelper() as IGeoDatabaseBridge2; bridge.QueryPixelBlock(pSurface, point2.X, point2.Y, double_0, double_0, esriRasterizationType_0, noDataValue, ref block); tlc.X = j; tlc.Y = i; pxls.set_SafeArray(0, block); pixels.Write(tlc, pxls); } bool flag = false; if (size.X != num3) { size.X = num3; flag = true; } if ((num2 - i) < num4) { size.Y = num2 - i; } if (flag) { block = pixels.CreatePixelBlock(size).get_SafeArray(0); } } return(dataset2); }