Ejemplo n.º 1
0
 internal RasterOverviewCollection(GdalRasterBand band)
 {
     if (band == null)
     {
         throw new ArgumentNullException("band");
     }
     _band = band;
 }
Ejemplo n.º 2
0
 internal RasterBand(GdalRasterBand band, int index)
 {
     if (band == null)
     {
         throw new ArgumentNullException("band");
     }
     _band  = band;
     _index = index;
 }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
0
        private void mapControl_MouseDownEvent(object sender, _DMapEvents_MouseDownEvent e)
        {
            if (e.button == 2 && listLabel.Visible)
            {
                ListViewItem   x     = listLabel.Items[listLabel.SelectedIndices[0]];
                string         type  = x.SubItems[1].Text;
                FormEnterLabel enter = new FormEnterLabel(preSelectedShape.ToString(), type);
                enter.ShowDialog();
                string   str_    = enter.label;
                String[] rowData = new String[3];
                rowData[0] = preSelectedShape.ToString();
                rowData[1] = type;
                rowData[2] = str_;

                ListViewItem item = new ListViewItem(rowData);
                listLabel.Items.RemoveAt(preSelectedShape);
                listLabel.Items.Insert(preSelectedShape, item);
            }


            if (!toolGetValues.Checked)
            {
                return;
            }
            Shape shp = new Shape();

            if (e.button == 1)          // left button
            {
                Shapefile sf = mapControl.get_Shapefile(mapControl.NumLayers - 1);

                shp.Create(ShpfileType.SHP_POINT);
                MapWinGIS.Point pnt = new MapWinGIS.Point();
                double          x   = 0.0;
                double          y   = 0.0;
                mapControl.PixelToProj(e.x, e.y, ref x, ref y);
                Console.WriteLine(x.ToString() + "," + y.ToString());
                pnt.x = x;
                pnt.y = y;
                int index = shp.numPoints;
                shp.InsertPoint(pnt, ref index);
                index = sf.NumShapes;
                if (!sf.EditInsertShape(shp, ref index))
                {
                    MessageBox.Show("Failed to insert shape: " + sf.ErrorMsg[sf.LastErrorCode]);
                    return;
                }
                mapControl.Redraw();
            }
            else
            {
                return;
            }


            int row;
            int column;

            double X = 0;
            double Y = 0;

            mapControl.PixelToProj(e.x, e.y, ref X, ref Y);
            MapWinGIS.Image img = mapControl.get_Image(0);
            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;
            }

            FormRasterValue uiRasterValues = new FormRasterValue(vals);

            uiRasterValues.ShowDialog();
            shp.Clear();
        }