-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSHPHeader.cs
More file actions
85 lines (67 loc) · 2.2 KB
/
SHPHeader.cs
File metadata and controls
85 lines (67 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using DbfDataReader;
namespace ShapeUtilities
{
public class SHPHeader
{
/// <summary>
/// should be the value 9994
/// </summary>
public int FileCode { get; set; }
/// <summary>
/// Number of word values in the shape file, so bytes/2.
/// </summary>
public int FileLength { get; set; }
public int Version { get; set; }
public eShapeType ShapeType { get; set; }
public double XMin { get; set; }
public double YMin { get; set; }
public double XMax { get; set; }
public double YMax { get; set; }
public double ZMin { get; set; }
public double ZMax { get; set; }
public double MMin { get; set; }
public double MMax { get; set; }
public enum eShapeType : int
{
NullShape = 0,
Point = 1,
PolyLine = 3,
Polygon = 5,
MultiPoint = 8,
PointZ = 11,
PolyLineZ = 13,
PolygonZ = 15,
MultiPointZ = 18,
PointM = 21,
PolyLineM = 23,
PolygonM = 25,
MultiPointM = 28,
MultiPatch = 31
}
public SHPHeader(BinaryReader reader)
{
//i have no fucking idea why they go from network order to host order bytes
//zimmerman of course always has his fucked up comments.
FileCode = reader.ReadBigEndianInt32();
for (int x=0; x< 5; x++) { reader.ReadInt32(); }
FileLength = reader.ReadBigEndianInt32();
Version = reader.ReadInt32();
ShapeType = (eShapeType)(reader.ReadInt32());
XMin = reader.ReadDouble();
ZMin = reader.ReadDouble();
XMax = reader.ReadDouble();
YMax = reader.ReadDouble();
ZMin = reader.ReadDouble();
ZMax = reader.ReadDouble();
MMin = reader.ReadDouble();
MMax = reader.ReadDouble();
//Console.WriteLine(reader.BaseStream.Position);
}
}
}