Umasoft
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
LULC.h
1 //
2 // Classes/structures to represent the data in a LULC file
3 //
4 // Copyright (c) 2001 Virtual Terrain Project
5 // Free for all uses, see license.txt for details.
6 //
7 
8 #ifndef LULCH
9 #define LULCH
10 
11 #include <stdio.h>
12 #include "MathTypes.h"
13 
14 #define LULC_ERR_FILE 1
15 #define LULC_ERR_READ 2
16 #define LULC_ERR_HEADER 3
17 
18 typedef struct
19 {
20  short x;
21  short y;
22 } Coord;
23 
24 typedef struct
25 {
26  short first_coord;
27  short last_coord;
28  short PL;
29  short PR;
30  int PAL;
31  int PAR;
32  int Length; // in coordinate units
33  short StartNode;
34  short FinishNode;
35 } LULCArc;
36 
37 class LULCPoly
38 {
39 public:
40  LULCPoly();
41  ~LULCPoly();
42 
43  short first_arc;
44  short last_arc;
45  int Attribute;
46  int PerimeterLength;
47  short NumIslands;
48  short SurroundingPoly;
49 
50  // Vertices extracted by following and decoding the Arc data
51  int m_iCoords;
52  DPoint2 *m_p; // in lat-lon
53 
54  // store extents, in local coordinates, for speed in testing
55  double xmin, zmin, xmax, zmax;
56 
57 private:
58  // Don't let unsuspecting users stumble into assuming that object
59  // copy semantics will work. Declare them private and never
60  // define them.
61  LULCPoly( const LULCPoly & );
62  LULCPoly &operator=( const LULCPoly & );
63 
64 };
65 
67 {
68 public:
69  LULCSection() {};
70  ~LULCSection();
71 
72  uint m_iNumArcs;
73  uint m_iNumCoords;
74  uint m_iNumPolys;
75  uint m_iLengthOfFAP;
76  uint m_iNumNodes;
77 
78  LULCArc *m_pArc;
79  Coord *m_pCoord;
80  LULCPoly *m_pPoly;
81  short *m_pFAP;
82 
83 private:
84  // Don't let unsuspecting users stumble into assuming that object
85  // copy semantics will work. Declare them private and never
86  // define them.
87  LULCSection( const LULCSection & );
88  LULCSection &operator=( const LULCSection & );
89 };
90 
95 {
96 public:
98  vtLULCFile(const char *fname);
99 
101  ~vtLULCFile();
102 
104  void SetupMapping();
105 
106  // read a section (there are usually 4 sections)
107  void ReadSection(LULCSection *pSection, FILE *fp);
108 
109  // read a single record from the file
110  int GetRecord(FILE *fp, char *buf);
111 
112  // convert from local coordinates to latlon
113  void LocalToLatlon(Coord &local, DPoint2 &latlon);
114 
115  // processing LULC
116  void ProcessLULCPolys();
117  void ProcessLULCPoly(LULCSection *pSection, LULCPoly *pPoly);
118  int FindAttribute(double utm_x, double utm_y);
119 
121  int m_iError;
123  const char *GetErrorMessage();
124 
125  // extent of control points, in local coordinates
126  Coord m_cMin, m_cMax;
127 
128  // local coordinates of control points
129  Coord m_cCorners[6];
130 
131  // latitude and longitude of control points
132  DPoint2 m_Corners[6];
133 
135  uint NumSections() { return m_iNumSections; };
137  LULCSection *GetSection(int i) { return m_pSection+i; };
138 
139  // used for making a list of these files
140  vtLULCFile *m_pNext;
141 
142 private:
143  // Don't let unsuspecting users stumble into assuming that object
144  // copy semantics will work. Declare them private and never
145  // define them.
146  vtLULCFile( const vtLULCFile & );
147  vtLULCFile &operator=( const vtLULCFile & );
148 
149  uint m_iNumSections;
150  LULCSection *m_pSection;
151  DMatrix3 m_transform;
152 // DMatrix3 m_forwards;
153 };
154 
155 #endif // LULCH