Beispiel #1
0
        //public static double Percentile(double[] elements, double percentile)
        //{
        //    Array.Sort(elements);
        //    double realIndex = percentile * (elements.Length - 1);
        //    int index = (int)realIndex;
        //    double frac = realIndex - index;
        //    if (index + 1 < elements.Length)
        //        return elements[index] * (1 - frac) + elements[index + 1] * frac;
        //    else
        //        return elements[index];
        //}
        private void axMap1_MouseMoveEvent(object sender, AxMapWinGIS._DMapEvents_MouseMoveEvent e)
        {
            if (btnShowCellInfo.Checked)
            {
                string stt = "";
                int    row;
                int    column;
                double X = 0;
                double Y = 0;
                axMap1.PixelToProj(e.x, e.y, ref X, ref Y);
                stt += "Kinh độ: " + Convert.ToString(Math.Round(X, 3)) +
                       " Vĩ độ: " + Convert.ToString(Math.Round(Y, 3)) +
                       ". Giá trị Band: ";
                MapWinGIS.Image img = axMap1.get_Image(idxLayerRaster);
                img.ProjectionToImage(X, Y, out column, out row);
                double[] vals = new double[img.NoBands];
                for (int i = 1; i <= img.NoBands; i++)
                {
                    GdalRasterBand rst = img.get_Band(i);
                    double         pVal;
                    rst.get_Value(row, column, out pVal);
                    vals[i - 1] = pVal;
                    stt        += i.ToString() + " : " + Math.Round(pVal, 3).ToString() + "; ";
                }

                toolStripStatusLabel1.Text = stt;
            }
            else
            {
                double x, y;
                x = y = 0;
                axMap1.PixelToProj(e.x, e.y, ref x, ref y);
                x = Math.Round(x, 3);
                y = Math.Round(y, 3);

                toolStripStatusLabel1.Text = "Kinh độ: " + Convert.ToString(x) + " Vĩ độ: " + Convert.ToString(y);
            }
        }