华南农业大学地信C#综合性试验报告汇总.doc
文本预览下载声明
综合性实验报告
专业 地理信息科学 年级 2013级 学号 201330150113 姓名 廖家宝
时间 2014年1月15日
实验名称:简单图形程序设计
实验目的:综合运用C#程序设计知识和方法,加深面向对象程序设计理论和方法的理解,巩固程序设计课程基础知识,提高程序设计能力。
实验准备(数据与软件):
1.开发环境和测试数据
开发环境采用Visual studio 2012.Net,开发语言为C#,实验测试数据为.shp类型文件
2. 相关文档阅读:
ESRI公开的Shapefile白皮书《ESRI Shapefile Technical Description》;IBM公开的DBF文件格式。
内容与步骤:
了解shapefile的文件组织形式,以及各个组成部分的数据结构
(1)一个.shp文件由文件头和记录组成。文件头大小为100个字节,其布局如下表:
Position Field Value Type Order
Byte 0 File Code 9994 Integer Big
Byte 4 Unused 0 Integer Big
Byte 8 Unused 0 Integer Big
Byte 12 Unused 0 Integer Big
Byte 16 Unused 0 Integer Big
Byte 20 Unused 0 Integer Big
Byte 24 File Length File Length Integer Big
Byte 28 Version 1000 Integer Little
Byte 32 Shape Type Shape Type Integer Little
Byte 36 Bounding Box Xmin Double Little
Byte 44 Bounding Box Ymin Double Little
Byte 52 Bounding Box Xmax Double Little
Byte 60 Bounding Box Ymax Double Little
Byte 68* Bounding Box Zmin Double Little
Byte 76* Bounding Box Zmax Double Little
Byte 84* Bounding Box Mmin Double Little
Byte 92* Bounding Box Mmax Double Little
* Unused, with value 0.0, if not Measured or Z type
注意其中的字节顺序,Big表示大尾(big endian)型字节顺序,即是高低位字节是反序的,主要适用于Sun? or Motorola?平台,而Little表示小尾(little endian)型字节顺序,高低位字节顺序不变,主要使用在PC or Intel?平台。在读取的字节为Big时,需要进行字节顺序交换,才能得出正确的值。一个把Big顺序转换为Little顺序的函数可以如下:
int Big2LittleEndian(int num)
{
int reverse; //返回结果
char bit0, bit1, bit2, bit3;
bit0 = (num 0x000000ff);
bit1 = (num 0x0000ff00) 8;
bit2 = (num 0x00ff0000) 16;
bit3 = (num 0xff000000) 24;
reverse = (bit0 24) | (bit1 16) | (bit2 8) | (bit3);
return reverse;
}
文件头中第32-35位字节为一个整型,其值反映了shapefile的图形对象类型,具体值对应含义如下:
Value Shape Type
0 Null Shape
1 Point
3 PolyLine
5 Polygon
8 MultiPoint
11 PointZ
13 PolyLineZ
15 PolygonZ
18 MultiPoi
显示全部