示例#1
0
        private string GetSNWDegree(string[] files)
        {
            double pixelArea = 0;
            IInterestedRaster <Int16> timeResult = null;
            IRasterOperator <Int16>   roper      = new RasterOperator <Int16>();
            DataIdentify di = GetDataIdentify();
            string       outFileIdentify = GetStringArgument("OutFileIdentify");
            string       extinfo         = GetStringArgument("extinfo");

            timeResult = roper.Times(files, CreatRasterIndetifyId(files, "SNW", outFileIdentify, di, null, extinfo),
                                     (dstValue, srcValue) =>
            {
                if (srcValue == 0)
                {
                    return(dstValue);
                }
                else
                {
                    return(++dstValue);
                }
            });
            IRasterDataProvider dataProvider = timeResult.HostDataProvider;

            if (dataProvider != null)
            {
                ArgumentProvider             ap        = new ArgumentProvider(dataProvider, null);
                RasterPixelsVisitor <Int16>  visitor   = new RasterPixelsVisitor <Int16>(ap);
                IPixelFeatureMapper <double> memresult = new MemPixelFeatureMapper <double>("0SDC", 1000, new Size(dataProvider.Width, dataProvider.Height), dataProvider.CoordEnvelope, dataProvider.SpatialRef);
                IInterestedRaster <double>   iir       = null;
                try
                {
                    visitor.VisitPixel(new int[] { 1 }, (index, values) =>
                    {
                        if (values[0] == 0)
                        {
                            memresult.Put(index, 0);
                        }
                        else
                        {
                            pixelArea = RasterOperator <Int16> .ComputePixelArea(index / dataProvider.Width, dataProvider.CoordEnvelope.MaxY, dataProvider.ResolutionY);
                            memresult.Put(index, pixelArea * values[0]);
                        }
                    });
                    RasterIdentify id = new RasterIdentify();
                    id.ThemeIdentify      = "CMA";
                    id.ProductIdentify    = "SNW";
                    id.SubProductIdentify = "0SDC";
                    id.GenerateDateTime   = DateTime.Now;
                    iir = new InterestedRaster <double>(id, new Size(dataProvider.Width, dataProvider.Height), dataProvider.CoordEnvelope.Clone());
                    iir.Put(memresult);
                    return(iir.FileName);
                }
                finally
                {
                    if (iir != null)
                    {
                        iir.Dispose();
                    }
                    if (visitor != null)
                    {
                        visitor.Dispose();
                    }
                    if (timeResult != null)
                    {
                        timeResult.Dispose();
                    }
                    if (File.Exists(timeResult.FileName))
                    {
                        File.Delete(timeResult.FileName);
                    }
                }
            }
            return(null);
        }