-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathshapedef.h
156 lines (139 loc) · 4.77 KB
/
shapedef.h
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
//ShapeDef.h
//2011 3 13 created by ugi
#include "QList"
#include "../gdem_base/GDM_Vector3D.h"
#include <QVector>
#include "../gdem_base/GDM_Rect.h"
//added by RSH 2012.5.6
#include <QStringList>
#define AV_NULL_SHP 0
#define AV_POINT_SHP 1
#define AV_POLYLINE_SHP 3
#define AV_POLYGON_SHP 5
#define AV_MULTIPOINT_SHP 8
#define AV_POINT_Z_SHP 11
#define AV_POLYLINE_Z_SHP 13
#define AV_POLYGON_Z_SHP 15
#define AV_MULTIPOINT_Z_SHP 18
#define AV_POINT_M_SHP 21
#define AV_POLYLINE_M_SHP 23
#define AV_POLYGON_M_SHP 25
#define AV_MULTIPOINT_M_SHP 28
#define AV_MULTIPATCH_SHP 31
#define AV_FILE_CODE 9994
#define AV_FILE_VER 1000
#define AV_FILE_HDR_SIZE 100
struct AVF_HDR {
long nFileCode; // Big endian
long nReserved[5]; // Big endian
long nFileLength; // Big endian
long nVer;
long nShapeType;
double Xmin;
double Ymin;
double Xmax;
double Ymax;
double Zmin;
double Zmax;
double Mmin;
double Mmax;
};
struct AV_DATA_REC_HDR {
long nRecNum; // Big endian
long nContentLength; // Big endian
long nShapeType;
};
struct AV_POINT {
double x;
double y;
};
struct INT_POINT {
int x;
int y;
};
struct AV_POLY_HDR {
double BXmin;
double BYmin;
double BXmax;
double BYmax;
long nPartCount;
long nPointCount;
};
struct AV_POLYGON {
struct AV_POLY_HDR polyHd;
//long *nFirstPtIdx; // length = nPartCount
struct AV_POINT *pPoints; // length = nPointCount
};
//end of RSH
class Point
{
double _X;
double _Y;
public:
Point() {_X=0;_Y=0;}
void Set (double x,double y) {_X=x;_Y=y;}
void SetX(double x) {_X=x;}
void SetY(double y) {_Y=y;}
double X() {return _X;}
double Y() {return _Y;};
};
class Line
{
QList<Point> _PointList;
public:
Line() {_PointList.clear();}
~Line() {_PointList.clear();}
void AddPoint(Point p) {_PointList.append(p);}
void Clear() {_PointList.clear();}
Point GetPoint(int index){return _PointList[index];}
unsigned int GetPointCount() {return (unsigned int)_PointList.size();}
};
class PolyLine
{
QList<Line> _LineList;
public:
void AddLine(Line l) {_LineList.append(l);}
void AddPolyline(PolyLine polyline)
{
Line line;
for(unsigned int i=0;i<polyline.GetLineCount();i++)
{
line=polyline.GetLine(i);
_LineList.append(line);
}
}
void Clear() {_LineList.clear();}
unsigned int GetLineCount() {return (unsigned int)_LineList.count();}
Line GetLine(unsigned int index){return _LineList[index];}
bool IsEmpty() {return _LineList.empty();}
};
//added by RSH 2013.3.3 for bounding box inclusion
void GetBoundingRect(CGDM_LocationArr ptArr, CGDM_Rect2D *bound);
//end addition by RSH
bool ReadPolylineFromShapeFile(QString filename,PolyLine& polyline);
bool WriteShapeFile(QString filename,PolyLine polyline, bool hasID);
bool WriteShapeFile(int x,int y,int level,CGDM_LocationPolygonArr polygonarray, bool hasID);
bool ReadShapeFile(QString filename,CGDM_LocationPolygonArr& linearray);
//added by RSH 2012.5.6
int GetShapeFileType(QString srcFileName);
long _ConvertBigToLittle(long op);
void ReadDataHeader(FILE * i_pfi, struct AVF_HDR * avHdr);
void ReadAvPolyHdr(FILE * i_pfi,struct AV_POLY_HDR * hdr);
void ReadAvPoint(FILE * i_pfi, struct AV_POINT * pt);
void ReadAvDataRecHdr(FILE * i_pfi,struct AV_DATA_REC_HDR * avDRhdr);
QVector<AV_POINT> GetPointFileData(FILE * i_pfi, struct AVF_HDR * hd);
QVector<AV_POLYGON> GetPolyFileData(FILE * i_pfi, struct AVF_HDR * hd);
//Shape ÃùËεṢÀ¾ À°Ëλôµê´É˾
void ConvertShapeFile(QString srcFileName, QString dstDirStr, int level, bool hasID, int tolPixNum, int maxFSize, int maxNum);
bool ConvertShapeToGS(QString shpFileDir, QString saveDir);
bool isIntersecting(double Xmin, double Xmax, double Ymin, double Ymax, double minX, double maxX, double minY, double maxY);
QString MakeFileName(int nX, int nY, int level, QString extension);
void ProcessPolyData(QVector<AV_POLYGON> pPolyData, struct AVF_HDR * hd, QString dstDir, int level,
bool hasID, int tolPixNum, int maxFSize, int maxFeatureNum);
void PostProcessPolyData(QVector<AV_POLYGON> pPolyData);
bool WriteShapeFile(int x,int y,int level, CGDM_LocationPolygonArr polygonarray, QString dstDir,QVector<int> idArr,
bool hasID, int maxFSize);
CGDM_LocationPolygonArr GetReducedPolygonArray(CGDM_LocationPolygonArr inArray, int level);
bool WriteOneBlockShapeFile(QString srcShpDirStr, QStringList srcShpFileList, QString saveDirStr);
QString getDirName(QString filename);
//end of RSH