コード例 #1
0
ファイル: frmArgNDVIManager.cs プロジェクト: windygu/hispeed
        private void btnAddRegion_Click(object sender, EventArgs e)
        {
            errorProvider1.Clear();
            string name = txtName.Text;
            double minx = txtMinLon.Value;
            double maxx = txtMaxLon.Value;
            double miny = txtMinLat.Value;
            double maxy = txtMaxLat.Value;

            RSS.Core.DF.CoordEnvelope env = new RSS.Core.DF.CoordEnvelope(minx, maxx, miny, maxy);
            if (string.IsNullOrWhiteSpace(name))
            {
                errorProvider1.SetError(txtName, "名字不能为空");
                return;
            }
            if (env == null || env.Width <= 0 || env.Height <= 0 ||
                env.MinX < -180 || env.MaxX > 180 ||
                env.MinY < -90 || env.MaxY > 90)
            {
                errorProvider1.SetError(panel2, "范围不合法");
                return;
            }
            if (ContainItem(name))
            {
                errorProvider1.SetError(txtName, "已经含有该名字的范围定义");
                return;
            }
            float minValue;

            if (float.TryParse(txtAvgMin.Text, out minValue))
            {
                errorProvider1.SetError(txtAvgMin, "未指定最小端元值");
            }
            float maxValue;

            if (float.TryParse(txtAvgMax.Text, out maxValue))
            {
                errorProvider1.SetError(txtAvgMin, "未指定最大端元值");
            }
            NDVISettingItem item = new NDVISettingItem();

            item.Envelope = env;
            item.Name     = name;
            item.MinValue = minValue;
            item.MaxValue = maxValue;
            AddNDVISetting(item);
        }
コード例 #2
0
        public override void Execute(string argument)
        {
            if (string.IsNullOrWhiteSpace(argument) || !Directory.Exists(argument))
            {
                return;
            }
            string fullfilename;
            string maskpng = AppDomain.CurrentDomain.BaseDirectory + @"\SystemData\ProductArgs\CLD\Cloudsat_Overview_withcountry.png";

            fullfilename = argument;
            ICommand cmd = _smartSession.CommandEnvironment.Get(2000);

            if (cmd != null)
            {
                cmd.Execute(maskpng);
            }
            GeoDo.RSS.Core.DF.CoordEnvelope env = TryGetActiveViewerEnv();
            if (env == null)
            {
                env = new RSS.Core.DF.CoordEnvelope(65, 145, 10, 60);
            }
            //如果测试整个影像数据,则输出图像为:0,37081,37081
            int x1    = 0;
            int x2    = 37081;
            int outnx = 2000;
            int h1    = -1;      //# km
            int h2    = 21;      //# km
            int nz    = 400;     //# Number of pixels in the vertical.(这个偏移需要指定)
            int dtnx  = 0;       //125
            int dtny  = 0;       //13000
            int xn    = x2 - x1; //值从1700到2000,要读取的实际横轴方向数据。(最后这个偏移会通过地理范围,或者时间范围,计算出来)
            //return;
            CloudsatDataProvider raster = GeoDataDriver.Open(fullfilename) as CloudsatDataProvider;
            CloudSatRasterBand   band   = raster.GetRasterBand(1) as CloudSatRasterBand;

            dtnx = band.Width;  //层数
            dtny = band.Height; //点数
            sw.Start();
            float[] Latitude   = raster.ReadVdata("Latitude", null, x1, x2) as float[];
            float[] Longtitude = raster.ReadVdata("Longitude", null, x1, x2) as float[];
            sw.Stop();
            elapsed = sw.ElapsedMilliseconds;
            Console.WriteLine("ReadVdata" + elapsed + "毫秒");
            int cou      = 0;
            int minIndex = 0;
            int maxIndex = Latitude.Length;

            IntersectEnvelope(Latitude, Longtitude, env, ref cou, ref minIndex, ref maxIndex);

            Console.WriteLine(cou + "点在指定范围内");
            float[] times = raster.ReadVdata("Profile_time", null, x1, x2) as float[];
            if (cou > 0 && (x1 != minIndex || x2 != maxIndex))
            {
                x1 = minIndex;
                x2 = maxIndex;
                xn = x2 - x1 + 1;
                float[] lats  = new float[xn];
                float[] longs = new float[xn];
                float[] ts    = new float[xn];
                Buffer.BlockCopy(Latitude, x1 * 4, lats, 0, xn * 4);
                Buffer.BlockCopy(Longtitude, x1 * 4, longs, 0, xn * 4);
                Buffer.BlockCopy(times, x1 * 4, ts, 0, xn * 4);
                Latitude   = lats;
                Longtitude = longs;
                times      = ts;
            }
            string   start_time = raster.ReadAttribute("start_time") as string;
            DateTime dt_start_time;

            dt_start_time = DateTime.ParseExact(start_time, "yyyyMMddHHmmss", null);
            List <DateTime> dts = new List <DateTime>();

            foreach (float time in times)
            {
                dts.Add(dt_start_time.AddMinutes(time));                                              //应为AddSeconds()
            }
            short[] heights = readSDS("Height", new int[] { x1, 0 }, new int[] { xn, dtnx }, raster); //p1c1,p1c2,..,p1c125,p2c1,...
            short[] datas   = readData(new int[] { x1, 0 }, new int[] { xn, dtnx }, band);

            float[] X = new float[xn];//原始数据中的数据点号
            for (int i = 0; i < xn; i++)
            {
                X[i] = i + x1;
            }
            //heights数据是x=125,y=100=>Z[100,125]
            float[,] Z = new float[xn, dtnx];                 //每个点的高度xn = 100, dtnx =125;
            for (int i = 0; i < dtnx; i++)                    //heights的列,层数
            {
                for (int j = 0; j < xn; j++)                  //heights的行,点数
                {
                    Z[j, i] = heights[j * dtnx + i] * 0.001f; //m-->km
                }
            }

            short[,] newdata = new short[xn, dtnx];//点数,层数
            var dest = Marshal.UnsafeAddrOfPinnedArrayElement(newdata, 0);

            Marshal.Copy(datas, 0, dest, datas.Length);//将数据的一维数组变化为2维数组
            Marshal.Release(dest);

            short[,] dat = Rote <short>(newdata);//调换数组的行列,dat为层数×点数的数组;

            Bitmap bmp = null;
            IntPtr src;

            outnx             = xn < 4000 ? xn : 4000;
            float[,] dataf    = interp2d_12(newdata, X, Z, x1, x2, outnx, h2, h1, nz); //将数据进行插值
            float[,] newdataf = Rote <float>(dataf);                                   //调换数组的行列,dat为层数×点数的数组;
            int count = newdataf.Length;

            float[] datac = new float[count];
            src = Marshal.UnsafeAddrOfPinnedArrayElement(newdataf, 0);//
            Marshal.Copy(src, datac, 0, newdataf.Length);
            Marshal.Release(dest);
            DisplayLonLat(Latitude, Longtitude, fullfilename);
            //string[] dtimes = new string[dts.Count];
            //for(int i =0;i< dts.Count;i++)
            //{
            //    DateTime dt  = dts[i];
            //    dtimes[i] = dt.ToString("HH:mm:ss");
            //}
            //try
            //{
            //    bmp = ToBitmap(outnx, nz, datac);//点数(宽),层数(高)
            //    if (bmp != null)
            //    {
            //        string bmpfilename = MifEnvironment.GetFullFileName("2B-GEOPROF.Radar_Reflectivity.bmp");
            //        bmp.Save(bmpfilename);
            //        //OpenFileFactory.Open(bmpfilename);

            //        CloudsatPlotWnd wnd = _smartSession.SmartWindowManager.SmartToolWindowFactory.GetSmartToolWindow(_id) as CloudsatPlotWnd;
            //        if (wnd != null)
            //        {
            //            _smartSession.SmartWindowManager.DisplayWindow(wnd, new WindowPosition(System.Windows.Forms.DockStyle.Bottom, false));
            //            wnd.Reset(fullfilename, bmp, x1, x2, h1, h2, dtimes, null);
            //        }

            //        frmPlot frm = new frmPlot();
            //        ucCloudsatPlot plots = frm.plots;
            //        plots.AddYAxis(dtimes);
            //        plots.Reset(fullfilename, bmp, x1, x2, h1, h2, null);
            //        //plots.Rerender();
            //        //frm.Reset(fullfilename, bmp, x1, x2, h1, h2, dtimes, null);
            //        frm.Show();
            //    }
            //}
            //finally
            //{
            //    //if (bmp != null)
            //    //    bmp.Dispose();
            //}
        }