資源簡介
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個文件信息
- 上一篇:wince條碼掃描支持一維二維
- 下一篇:基于RFID的員工考勤應用系統
評論
共有 條評論