Example #1
0
        private void ReadInputData(int outRow, int rowCount, RasterVirtualVistor <Tsrc>[] fileVistor, Tsrc nullValue)
        {
            for (int i = 0; i < _fileIn.Length; i++)
            {
                RasterVirtualVistor <Tsrc> fv = new RasterVirtualVistor <Tsrc>();
                fv.Raster  = _fileIn[i].Raster;
                fv.BandMap = _fileIn[i].BandMap;
                fv.IndexY  = outRow;
                fv.SizeY   = rowCount;
                fv.SizeX   = _fileIn[i].Raster.Width;
                //
                int[]         bandMap = _fileIn[i].BandMap;
                IRasterBand[] bands   = new RasterBand[bandMap.Length];
                for (int b = 0; b < bandMap.Length; b++)
                {
                    bands[b] = _fileIn[i].Raster.GetRasterBand(bandMap[b]);
                }
                fv.Bands = bands;
                Tsrc[][] bandsVirtureData = new Tsrc[bands.Length][];

                for (int j = 0; j < bands.Length; j++)
                {
                    int    bandNo         = bandMap[j];
                    Tsrc[] dstVirtualData = _vRasterIn[i].ReadData <Tsrc>(bandNo, 0, outRow, _vRasterIn[i].VirtualHeader.Width, rowCount, nullValue);
                    bandsVirtureData[j] = dstVirtualData;
                }
                fv.RasterBandsData = bandsVirtureData;
                fileVistor[i]      = fv;
            }
        }
Example #2
0
        private void ExcuteMultiRow(int rowIndex, int rowCount, Tsrc nullValue)
        {
            //初始化AOI
            TrySetAOI(rowIndex, rowCount);
            //初始化数据访问器
            RasterVirtualVistor <Tsrc>[] fileVistor    = new RasterVirtualVistor <Tsrc> [_fileIn.Length];
            RasterVirtualVistor <Tdst>[] fileOutVistor = new RasterVirtualVistor <Tdst> [_fileOut.Length];
            ReadInputData(rowIndex, rowCount, fileVistor, nullValue);
            ReadOutputData(rowIndex, rowCount, fileOutVistor);

            //处理逻辑
            if (_calcModle != null)
            {
                _calcModle(fileVistor, fileOutVistor, _aoiIndex);
            }
            bool isSave = true;

            if (_calcModleFun != null)
            {
                isSave = _calcModleFun(fileVistor, fileOutVistor, _aoiIndex);
            }
            //更新输出数据
            if (isSave)
            {
                UpdateOutData(fileOutVistor, rowCount);
            }
        }
Example #3
0
 internal void ReadOutputData(int outRow, int rowCount, RasterVirtualVistor <Tdst>[] fileVistor)
 {
     for (int i = 0; i < _fileOut.Length; i++)
     {
         RasterVirtualVistor <Tdst> fv = new RasterVirtualVistor <Tdst>();
         fv.BandMap = _fileOut[i].BandMap;
         fv.IndexY  = outRow;
         fv.SizeX   = _fileOut[i].Raster.Width;
         fv.SizeY   = rowCount;
         fv.Raster  = _fileOut[i].Raster;
         int[]         bandMap = _fileOut[i].BandMap;
         IRasterBand[] bands   = new RasterBand[bandMap.Length];
         for (int b = 0; b < bandMap.Length; b++)
         {
             bands[b] = _fileOut[i].Raster.GetRasterBand(bandMap[b]);
         }
         fv.Bands = bands;
         //初始化源数据访问
         int          outWidth    = _vRasterIn[0].VirtualHeader.Width;
         int          readOffsetx = 0;
         int          readOffsetY = outRow;
         int          xSize       = outWidth;
         int          ySize       = rowCount;
         enumDataType type        = _fileOut[i].Raster.DataType;
         //if (type == enumDataType.Int16)
         //{
         Tdst[][] bandsVirtureData = new Tdst[bands.Length][];
         for (int b = 0; b < bands.Length; b++)
         {
             Tdst[]   bufferData = new Tdst[xSize * ySize];
             GCHandle buffer     = GetHandles(bufferData);
             bands[b].Read(readOffsetx, readOffsetY, xSize, ySize, buffer.AddrOfPinnedObject(), type, xSize, ySize);
             buffer.Free();
             bandsVirtureData[b] = bufferData;
         }
         fv.RasterBandsData = bandsVirtureData;
         //}
         fileVistor[i] = fv;
     }
 }