public Vertical_Profiling_Form(MapWinGIS.Image demImg, MapWinGIS.Point pt1, MapWinGIS.Point pt2)
        {
            this.InitializeComponent();
            //MapWinGIS.Point pt1 = new MapWinGIS.Point();
            //pt1.Set(0, 4);
            //MapWinGIS.Point pt2 = new MapWinGIS.Point();
            //pt2.Set(2, 0);

            int row1, col1;

            demImg.ProjectionToImage(pt1.x, pt1.y, out col1, out row1);
            int row2, col2;

            demImg.ProjectionToImage(pt2.x, pt2.y, out col2, out row2);
            var myModel = new PlotModel {
                Title = "Mặt cắt dọc"
            };

            //double step = 0.1;
            //int a_count = (int)Math.Abs((pt1.x - pt2.x) / step);
            //var plot3_Series = new LineSeries { StrokeThickness = 1, MarkerSize = 1 };
            //for (int i = 0; i < a_count; i++)
            //{
            //    int row;
            //    int column;
            //    double x_val = pt1.x + i*step;
            //    double y_val = LineEquation(pt1, pt2, x_val);
            //    demImg.ProjectionToImage(x_val, y_val, out column, out row);
            //    double yDEM = 0;
            //    demImg.Band[1].get_Value(column,row,out yDEM);
            //    plot3_Series.Points.Add(new DataPoint(x_val, yDEM));

            //}
            MapWinGIS.Point ptTmp1 = new MapWinGIS.Point();
            ptTmp1.Set(col1 + 0.5, row1 + 0.5);
            MapWinGIS.Point ptTmp2 = new MapWinGIS.Point();
            ptTmp2.Set(col2 + 0.5, row2 + 0.5);

            int a_count      = Math.Abs(col1 - col2);
            var plot3_Series = new LineSeries {
                StrokeThickness = 1, MarkerSize = 1
            };

            for (int i = 0; i < a_count; i++)
            {
                double x_val = col1 + i;
                double y_val = LineEquation(ptTmp1, ptTmp2, x_val);
                double yDEM  = 0;
                demImg.Band[1].get_Value((int)x_val, (int)y_val, out yDEM);
                demImg.ImageToProjection((int)x_val, (int)y_val, out x_val, out y_val);
                plot3_Series.Points.Add(new DataPoint(x_val, yDEM));
            }
            myModel.Series.Add(plot3_Series);

            this.plotView1.Model = myModel;
        }
Exemple #2
0
 public bool ProjectionToImage(double projX, double projY, out int column, out int row)
 {
     _image.ProjectionToImage(projX, projY, out column, out row);
     return(column >= 0 && column < Width && row >= 0 && row < Height);
 }
Exemple #3
0
 public bool ProjectionToImage(double projX, double projY, out int imageX, out int imageY)
 {
     _image.ProjectionToImage(projX, projY, out imageX, out imageY);
     return(imageX >= 0 && imageX < Width && imageY >= 0 && imageY < Height);
 }
Exemple #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();
        }