Beispiel #1
0
 /// <summary>
 /// 参数检查
 /// </summary>
 /// <returns>true表示检查通过,false表示不通过</returns>
 private bool ParasCheck()
 {
     if (txtExportPath.Text == "")
     {
         if (lang == Language.Chinese)
         {
             MessageBox.Show("路径设置不能为空!");
         }
         else if (lang == Language.English)
         {
             MessageBox.Show("The path cannot be empty!");
         }
         return(false);
     }
     if (!SortTool.IsFitNumber(txtGridSize.Text, 1, false))
     {
         if (lang == Language.Chinese)
         {
             MessageBox.Show("栅格像元大小设置出错!");
         }
         else if (lang == Language.English)
         {
             MessageBox.Show("Pixel size error!");
         }
         return(false);
     }
     if ((!txtNeighbor.ReadOnly) && (!SortTool.IsFitNumber(txtNeighbor.Text, 1, false, true)))
     {
         if (lang == Language.Chinese)
         {
             MessageBox.Show("像元邻域大小只能为正整数!");
         }
         else if (lang == Language.English)
         {
             MessageBox.Show("The neighborhood size can only be a positive integer!");
         }
         return(false);
     }
     if ((!txtSearchR.ReadOnly) && (!SortTool.IsFitNumber(txtSearchR.Text, 1, false, true)))
     {
         if (lang == Language.Chinese)
         {
             MessageBox.Show("搜索半径只能为正整数!");
         }
         else if (lang == Language.English)
         {
             MessageBox.Show("The search radius can only be positive integer!");
         }
         return(false);
     }
     return(true);
 }
Beispiel #2
0
 private void btEnsure_Click(object sender, EventArgs e)
 {
     if (SortTool.IsFitNumber(txtLng.Text) && SortTool.IsFitNumber(txtLat.Text) && SortTool.IsFitNumber(txtElevation.Text))
     {
         double lng = double.Parse(txtLng.Text);
         double lat = double.Parse(txtLat.Text);
         if (Math.Abs(lng) > 180)
         {
             if (lang == Language.Chinese)
             {
                 MessageBox.Show("经度绝对值不大于180!");
             }
             else if (lang == Language.English)
             {
                 MessageBox.Show("The absolute longitude is no more than 180!");
             }
             return;
         }
         if (Math.Abs(lat) > 90)
         {
             if (lang == Language.Chinese)
             {
                 MessageBox.Show("纬度绝对值不大于90!");
             }
             else if (lang == Language.English)
             {
                 MessageBox.Show("The absolute latitude is no more than 90!");
             }
             return;
         }
         double elevation = double.Parse(txtElevation.Text);
         gcp = new GCP(lng, lat, elevation);
         this.Close();
     }
     else
     {
         if (lang == Language.Chinese)
         {
             MessageBox.Show("坐标都要为数字!");
         }
         else if (lang == Language.English)
         {
             MessageBox.Show("All the coordinates must be numbers!");
         }
     }
 }
        private void btRender_Click(object sender, EventArgs e)
        {
            int number = 0;

            if (cbColorRamp.SelectedIndex == -1)
            {
                if (lang == Language.Chinese)
                {
                    MessageBox.Show("请先选择一种色带");
                }
                else if (lang == Language.English)
                {
                    MessageBox.Show("Please choose a color ribbon first");
                }
                return;
            }
            try
            {
                number = int.Parse(txtNumber.Text);
                if (number <= 1)
                {
                    if (lang == Language.Chinese)
                    {
                        MessageBox.Show("类别数量只能为>1的正整数");
                    }
                    else if (lang == Language.English)
                    {
                        MessageBox.Show("The class number can only be a positive integer of >1");
                    }
                }
            }
            catch
            {
                if (lang == Language.Chinese)
                {
                    MessageBox.Show("类别数量只能为整数");
                }
                else if (lang == Language.English)
                {
                    MessageBox.Show("The class number can only be an integer");
                }
            }
            IRasterClassifyColorRampRenderer pRasterClassifyRenderer = new RasterClassifyColorRampRendererClass();
            IRasterRenderer          pRasterRenderer = pRasterClassifyRenderer as IRasterRenderer;
            IUniqueValues            uniVal          = new UniqueValuesClass();
            IRasterCalcUniqueValues2 calValues       = new RasterCalcUniqueValuesClass();

            calValues.MaxUniqueValueCount = 10000000;
            calValues.AddFromRaster(rasterLayer.Raster, cbSelectedBand.SelectedIndex, uniVal);
            object vValues, vFrequences;

            uniVal.GetHistogram(out vValues, out vFrequences);
            double[] doubleArray = (double[])vValues;
            int[]    longArray   = (int[])vFrequences;
            int      order       = SortTool.CheckInOrder(doubleArray, doubleArray.Length);

            if (order == 0)
            {
                SortTool.QuickSort3(doubleArray, 0, doubleArray.Length - 1, longArray);
            }
            else if (order == -1)
            {
                SortTool.Reverse(doubleArray, doubleArray.Length, longArray);
            }
            IClassifyGEN classify = GetMethod(cbMethod.Text);

            classify.Classify((double[])vValues, (int[])vFrequences, ref number);
            double[] classes = classify.ClassBreaks as double[];

            pRasterRenderer.Raster             = rasterLayer.Raster;
            pRasterClassifyRenderer.ClassCount = number;
            for (int i = 0; i < classes.Length; i++)
            {
                pRasterClassifyRenderer.set_Break(i, classes[i]);
            }
            pRasterRenderer.Update();

            IStyleGalleryItem galleryItem = symbol.GetItem(cbColorRamp.SelectedIndex);
            IColorRamp        colorRamp   = galleryItem.Item as IColorRamp;
            IFillSymbol       fill        = new SimpleFillSymbolClass() as IFillSymbol;
            int increase = colorRamp.Size / (number - 1);

            for (int i = 0; i < pRasterClassifyRenderer.ClassCount - 1; i++)
            {
                fill.Color = colorRamp.get_Color(i * increase);
                pRasterClassifyRenderer.set_Symbol(i, fill as ISymbol);
                pRasterClassifyRenderer.set_Label(i, pRasterClassifyRenderer.get_Break(i).ToString() + "-" + pRasterClassifyRenderer.get_Break(i + 1).ToString());
            }
            fill.Color = colorRamp.get_Color(colorRamp.Size - 1);
            pRasterClassifyRenderer.set_Symbol(pRasterClassifyRenderer.ClassCount - 1, fill as ISymbol);
            pRasterClassifyRenderer.set_Label(pRasterClassifyRenderer.ClassCount - 1, pRasterClassifyRenderer.get_Break(pRasterClassifyRenderer.ClassCount - 1).ToString() + "-" + pRasterClassifyRenderer.get_Break(pRasterClassifyRenderer.ClassCount).ToString());
            rasterLayer.Renderer = pRasterRenderer;
            succeed = true;
            this.Close();
        }