• 大小: 66KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-05
  • 语言: C#
  • 标签: c#gisshp  

资源简介

C#实现shp文件的读取和显示程序,gis本专业的课程设计

资源截图

代码片段和文件信息

using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace tangll
{
    public partial class Form1 : Form
    {
        [STAThread]
        static void Main()
        {
            Application.EnableVisualstyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }

        ArrayList polygons = new ArrayList();
        ArrayList polylines = new ArrayList();
        ArrayList points = new ArrayList();
        Pen pen = new Pen(Color.Blue 2);
        int ShapeType;
        int count;
        double xmin ymin xmax ymax;
        double n1 n2;

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender EventArgs e)
        {
            DialogResult dr = this.openFileDialog1.ShowDialog();
            if (dr == DialogResult.OK)
            {
                BinaryReader br = new BinaryReader(openFileDialog1.OpenFile());
                //读取文件过程

                br.ReadBytes(24);
                int FileLength = br.ReadInt32();//<0代表数据长度未知
                int FileBanben = br.ReadInt32();
                ShapeType = br.ReadInt32();
                xmin = br.ReadDouble();
                ymax = -1 * br.ReadDouble();
                xmax = br.ReadDouble();
                ymin = -1 * br.ReadDouble();
                double width = xmax - xmin;
                double height = ymax - ymin;
                n1 = (float)(this.pictureBox1.Width * 0.9 / width);//x轴放大倍数
                n2 = (float)(this.pictureBox1.Height * 0.9 / height);//y轴放大倍数
                br.ReadBytes(32);

                switch (ShapeType)
                {
                    case 1:
                        points.Clear();
                        while (br.PeekChar() != -1)
                        {
                            Point_shape point = new Point_shape();

                            uint RecordNum = br.ReadUInt32();
                            int DataLength = br.ReadInt32();


                            //读取第i个记录
                            br.ReadInt32();
                            point.X = br.ReadDouble();
                            point.Y = -1 * br.ReadDouble();
                            points.Add(point);
                        }
                        StreamWriter sw = new StreamWriter(“point.txt“);

                        foreach (Point_shape p in points)
                        {
                            sw.WriteLine(“{0}{1}{2} “ p.X -1 * p.Y 0);
                        }
                        sw.Close();
                        break;
                    case 3:
                        polylines.Clear();
                        while (br.PeekChar() != -1)
             

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      24576  2008-10-23 14:32  Shape\Shape\bin\Debug\tangll.exe

     文件      30208  2008-10-23 14:32  Shape\Shape\bin\Debug\tangll.pdb

     文件       5632  2005-11-11 22:25  Shape\Shape\bin\Debug\tangll.vshost.exe

     目录          0  2008-10-23 14:32  Shape\Shape\bin\Debug

     目录          0  2008-10-23 14:30  Shape\Shape\bin

     文件      14533  2008-10-23 14:32  Shape\Shape\Form1.cs

     文件       6228  2008-10-23 14:31  Shape\Shape\Form1.Designer.cs

     文件       6391  2007-09-06 10:24  Shape\Shape\Form1.resx

     文件       1018  2008-07-21 08:29  Shape\Shape\obj\Debug\Shape.csproj.GenerateResource.Cache

     文件      24576  2008-07-21 08:29  Shape\Shape\obj\Debug\Shape.exe

     文件        180  2007-09-06 10:24  Shape\Shape\obj\Debug\Shape.Form1.resources

     文件      32256  2008-07-21 08:29  Shape\Shape\obj\Debug\Shape.pdb

     文件        180  2007-09-06 10:24  Shape\Shape\obj\Debug\Shape.Properties.Resources.resources

     文件        842  2008-10-23 14:30  Shape\Shape\obj\Debug\tangll.csproj.GenerateResource.Cache

     文件      24576  2008-10-23 14:32  Shape\Shape\obj\Debug\tangll.exe

     文件        180  2008-10-23 14:30  Shape\Shape\obj\Debug\tangll.Form1.resources

     文件      30208  2008-10-23 14:32  Shape\Shape\obj\Debug\tangll.pdb

     文件        180  2008-10-23 14:30  Shape\Shape\obj\Debug\tangll.Properties.Resources.resources

     文件       4608  2008-10-23 14:23  Shape\Shape\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll

     目录          0  2008-10-23 14:23  Shape\Shape\obj\Debug\TempPE

     目录          0  2008-10-23 14:32  Shape\Shape\obj\Debug

     文件        254  2008-10-23 14:21  Shape\Shape\obj\Shape.csproj.FileList.txt

     文件        454  2007-09-06 10:30  Shape\Shape\obj\Shape.csproj.FileListAbsolute.txt

     文件        261  2008-10-23 14:32  Shape\Shape\obj\tangll.csproj.FileList.txt

     目录          0  2008-10-23 14:30  Shape\Shape\obj

     文件        464  2008-10-23 14:30  Shape\Shape\Program.cs

     文件       1202  2008-10-23 14:22  Shape\Shape\Properties\AssemblyInfo.cs

     文件       2834  2008-10-23 14:21  Shape\Shape\Properties\Resources.Designer.cs

     文件       5612  2007-05-10 10:19  Shape\Shape\Properties\Resources.resx

     文件       1102  2008-10-23 14:21  Shape\Shape\Properties\Settings.Designer.cs

............此处省略12个文件信息

评论

共有 条评论

相关资源