Esempio n. 1
0
        private void FormXGIS_MouseClick(object sender, MouseEventArgs e)
        {
            if (layer.FeatureCount() == 0)
            {
                return;
            }
            XVertex onevertex   = view.ToMapVertex(e.Location);
            double  mindistance = Double.MaxValue;
            int     findid      = -1;
            int     index       = 0;

            foreach (XFeature feature in layer.Features)
            {
                double distance = feature.Distance(onevertex);
                if (distance < mindistance)
                {
                    mindistance = distance;
                    findid      = index;
                }
                index++;
            }
            int ScreenDistance = view.ToScreenDistance(mindistance);

            if (ScreenDistance < 5)
            {
                MessageBox.Show("找到的Feature的序号是" + findid);
            }
        }
Esempio n. 2
0
        void WriteFileHeader(XLayer layer, BinaryWriter bw)
        {
            MyFileHeader mfh = new MyFileHeader();

            mfh.MinX         = layer.Extent.GetMinX();
            mfh.MinY         = layer.Extent.GetMinY();
            mfh.MaxX         = layer.Extent.GetMaxX();
            mfh.MaxY         = layer.Extent.GetMaxY();
            mfh.FeatureCount = layer.FeatureCount();
            mfh.ShapeType    = (int)(layer.ShapeType);
            mfh.FieldCount   = layer.Fields.Count;
            bw.Write(XTools.ToBytes(mfh));
        }
Esempio n. 3
0
        private void BReadMyFile_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            if (openFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            XMyFile myFile = new XMyFile();

            layer = myFile.ReadFile(openFileDialog.FileName);
            MessageBox.Show("读入" + layer.FeatureCount() + "个实体");
            view.UpdateExtent(layer.Extent);
            UpdateMap();
        }
Esempio n. 4
0
 public FormAttribute(XLayer _Layer)
 {
     InitializeComponent();
     for (int i = 0; i < _Layer.Fields.Count; i++)
     {
         dgvAttribute.Columns.Add(_Layer.Fields[i].name, _Layer.Fields[i].name);
     }
     for (int i = 0; i < _Layer.FeatureCount(); i++)
     {
         dgvAttribute.Rows.Add();
         for (int j = 0; j < _Layer.Fields.Count; j++)
         {
             dgvAttribute.Rows[i].Cells[j].Value = _Layer.GetFeature(i).GetAttribute(j);
         }
     }
 }
Esempio n. 5
0
        private void BOpenShapeFile_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter           = "Shapefile文件|*.shp";
            openFileDialog.RestoreDirectory = false;
            openFileDialog.FilterIndex      = 1;
            openFileDialog.Multiselect      = false;
            if (openFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            XShapeFile sf = new XShapeFile();

            layer = sf.ReadShapefile(openFileDialog.FileName);
            layer.DrawAttributeOrNot = false;
            MessageBox.Show("读入" + layer.FeatureCount() + "个实体");
            view.UpdateExtent(layer.Extent);
            UpdateMap();
        }