Exemplo n.º 1
0
 private void AxMap1_MeasuringChanged(object sender, _DMapEvents_MeasuringChangedEvent e)
 {
     if (e.action == tkMeasuringAction.PointAdded)
     {
     }
     if (e.action == tkMeasuringAction.MesuringStopped)
     {
         if (btnAnotation.Checked)
         {
             Shape shp = new Shape();
             shp.Create(ShpfileType.SHP_POLYGON);
             //shp_tmp.EditAddShape()
             double x, y;
             //Debug.WriteLine("Measured points (in map units.): " + axMap1.Measuring.PointCount);
             for (int i = 0; i < axMap1.Measuring.PointCount; i++)
             {
                 if (axMap1.Measuring.get_PointXY(i, out x, out y))
                 {
                     //var c = 0;
                     MapWinGIS.Point ptn = new MapWinGIS.Point();
                     ptn.Set(x, y);
                     shp.InsertPoint(ptn, ref i);
                     //Debug.WriteLine("x={0}; y={1}", x, y);
                 }
             }
             tmpLayer.EditAddShape(shp);
             axMap1.Redraw();
         }
         if (btnVP.Checked)
         {
             double x, y;
             axMap1.Measuring.get_PointXY(0, out x, out y);
             MapWinGIS.Point pt1 = new Point();
             pt1.Set(x, y);
             axMap1.Measuring.get_PointXY(1, out x, out y);
             MapWinGIS.Point pt2 = new Point();
             pt2.Set(x, y);
             MapWinGIS.Image         DEMImg = axMap1.get_Image(idxLayerRaster);
             Vertical_Profiling_Form vpf    = new Vertical_Profiling_Form(DEMImg, pt1, pt2);
             vpf.Show(this);
             axMap1.Redraw();
         }
     }
 }
Exemplo n.º 2
0
        private void BtnImport_Click(object sender, EventArgs e)
        {
            if (idxLayerTmp >= 0)
            {
                axMap1.RemoveLayer(idxLayerTmp);
            }
            OpenFileDialog sfd = new OpenFileDialog();

            sfd.Filter           = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
            sfd.FilterIndex      = 0;
            sfd.RestoreDirectory = true;

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                StreamReader streamWriter = new StreamReader(sfd.FileName);
                tmpLayer = new Shapefile();
                tmpLayer.CreateNewWithShapeID("", ShpfileType.SHP_POLYGON);

                while (!streamWriter.EndOfStream)
                {
                    var   line    = streamWriter.ReadLine();
                    var   listPtn = line.Split(' ');
                    Shape shp     = new Shape();
                    shp.Create(ShpfileType.SHP_POLYGON);
                    for (int i = 1; i < listPtn.Length - 1; i++)
                    {
                        var             xy  = listPtn[i].Remove(listPtn[i].Length - 1).Replace('(', ' ').Replace(')', ' ').Split(';');
                        MapWinGIS.Point ptn = new MapWinGIS.Point();
                        ptn.Set(Convert.ToDouble(xy[0]), Convert.ToDouble(xy[1]));
                        shp.InsertPoint(ptn, ref i);
                    }
                    tmpLayer.EditAddShape(shp);
                }
                streamWriter.Close();
                MessageBox.Show("Done!!");
                idxLayerTmp = axMap1.AddLayer(tmpLayer, true);
            }
        }