Umasoft
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
DLG.h
1 //
2 // Classes/structures to represent the data in a DLG file
3 //
4 // Copyright (c) 2001 Virtual Terrain Project
5 // Free for all uses, see license.txt for details.
6 //
7 
8 #ifndef VTDATA_DLGH
9 #define VTDATA_DLGH
10 
11 #include <stdio.h>
12 #include <vector>
13 #include "MathTypes.h"
14 #include "Projections.h"
15 
16 #define DLG_ERR_FILE 1
17 #define DLG_ERR_READ 2
18 #define DLG_ERR_HEADER 3
19 #define DLG_ERR_NODE 4
20 #define DLG_ERR_AREA 5
21 #define DLG_ERR_LINE 6
22 
23 enum DLGType
24 {
25  DLG_HYPSO,
26  DLG_HYDRO,
27  DLG_VEG,
28  DLG_NONVEG,
29  DLG_BOUNDARIES,
30  DLG_MARKERS,
31  DLG_ROAD,
32  DLG_RAIL,
33  DLG_MTF,
34  DLG_MANMADE,
35  DLG_UNKNOWN
36 };
37 
39 {
40  int m_iMajorAttr, m_iMinorAttr;
41 };
42 
43 class DLGNode
44 {
45 public:
46  DPoint2 m_p;
47  int m_iAttribs;
48 };
49 
50 class DLGArea
51 {
52 public:
53  DPoint2 m_p;
54  int m_iAttribs;
55 };
56 
57 class DLGLine
58 {
59 public:
60  int HighwayNumber();
61 
62  int m_iNode1, m_iNode2;
63  int m_iLeftArea, m_iRightArea;
64  int m_iCoords;
65  int m_iAttribs;
66  std::vector<DLGAttribute> m_attr;
67  DLine2 m_p;
68 };
69 
73 class vtDLGFile
74 {
75 public:
76  vtDLGFile(); // constructor
77 
79  bool Read(const char *fname, bool progress_callback(int) = NULL);
80 
81  // read a single record from the file
82  bool GetRecord(char *buf);
83 
85  DLGType GuessFileType();
86 
88  const char *GetErrorMessage();
89 
90  //for m_fp
91  void OpenFile();
92  void CloseFile();
93 
94  // return error if it didn't load successfully
95  int m_iError;
96 
97  char m_header[80];
98  int m_iNodes;
99  int m_iAreas;
100  int m_iLines;
101  bool m_bLFdelimited;
102 
103  // used while reading
104  const char* m_fname;
105 
106  // quad corners (in the ground planimetric coordinate system)
107  DPoint2 m_SW_utm, m_NW_utm, m_NE_utm, m_SE_utm;
108  DPoint2 m_SW_lat, m_NW_lat, m_NE_lat, m_SE_lat;
109 
110  std::vector<DLGNode> m_nodes;
111  std::vector<DLGArea> m_areas;
112  std::vector<DLGLine> m_lines;
113 
114  vtProjection &GetProjection() { return m_proj; }
115 
116 protected:
117  FILE *m_fp;
118 
119  vtProjection m_proj;
120 
121 private:
122  // Don't let unsuspecting users stumble into assuming that object
123  // copy semantics will work. Declare them private and never
124  // define them,
125 
126  vtDLGFile( const vtDLGFile & );
127  vtDLGFile &operator=( const vtDLGFile & );
128 };
129 
130 // helper
131 bool ConvertDLG_from_LFDelim(const char *fname_from, const char *fname_to);
132 
133 #endif