Main Page   Class Hierarchy   Compound List   File List   Compound Members  

LULC.h

00001 //
00002 // Classes/structures to represent the data in a LULC file
00003 //
00004 // Copyright (c) 2001 Virtual Terrain Project
00005 // Free for all uses, see license.txt for details.
00006 //
00007 
00008 #ifndef LULCH
00009 #define LULCH
00010 
00011 #include <stdio.h>
00012 #include "MathTypes.h"
00013 
00014 #define LULC_ERR_FILE   1
00015 #define LULC_ERR_READ   2
00016 #define LULC_ERR_HEADER 3
00017 
00018 typedef struct 
00019 {
00020     short x;
00021     short y;
00022 } Coord;
00023 
00024 typedef struct
00025 {
00026     short first_coord;
00027     short last_coord;
00028     short PL;
00029     short PR;
00030     int PAL;
00031     int PAR;
00032     int Length;         // in coordinate units
00033     short StartNode;
00034     short FinishNode;
00035 } LULCArc;
00036 
00037 class LULCPoly
00038 {
00039 public:
00040     LULCPoly();
00041     ~LULCPoly();
00042 
00043     short first_arc;
00044     short last_arc;
00045     int Attribute;
00046     int PerimeterLength;
00047     short NumIslands;
00048     short SurroundingPoly;
00049 
00050     // Vertices extracted by following and decoding the Arc data
00051     int m_iCoords;
00052     DPoint2 *m_p;   // in lat-lon
00053 
00054     // store extents, in local coordinates, for speed in testing
00055     double xmin, zmin, xmax, zmax;
00056 };
00057 
00058 class LULCSection
00059 {
00060 public:
00061     ~LULCSection();
00062 
00063     int m_iNumArcs;
00064     int m_iNumCoords;
00065     int m_iNumPolys;
00066     int m_iLengthOfFAP;
00067     int m_iNumNodes;
00068 
00069     LULCArc *m_pArc;
00070     Coord *m_pCoord;
00071     LULCPoly *m_pPoly;
00072     short *m_pFAP;
00073 };
00074 
00075 class vtLULCFile 
00076 {
00077 public:
00078     // constructor - pass it the name of a LULC (GIRAS) file
00079     vtLULCFile(const char *fname);
00080 
00081     // destructor
00082     ~vtLULCFile();
00083 
00084     // attempt to determine the mapping from local to latlon
00085     void SetupMapping();
00086 
00087     // read a section (there are usually 4 sections)
00088     void ReadSection(LULCSection *pSection, FILE *fp);
00089 
00090     // read a single record from the file
00091     int GetRecord(FILE *fp, char *buf);
00092 
00093     // convert from local coordinates to latlon
00094     void LocalToLatlon(Coord &local, DPoint2 &latlon);
00095 
00096     // processing LULC
00097     void ProcessLULCPolys();
00098     void ProcessLULCPoly(LULCSection *pSection, LULCPoly *pPoly);
00099     int FindAttribute(double utm_x, double utm_y);
00100 
00101     // return error type if it didn't load successfully
00102     int m_iError;
00103     // if an error occured, return it as an English message
00104     const char *GetErrorMessage();
00105 
00106     // extent of control points, in local coordinates
00107     Coord m_cMin, m_cMax;
00108 
00109     // local coordinates of control points
00110     Coord m_cCorners[6];
00111 
00112     // latitude and longitude of control points
00113     DPoint2 m_Corners[6];
00114 
00115     // access
00116     int NumSections() { return m_iNumSections; };
00117     LULCSection *GetSection(int i) { return m_pSection+i; };
00118 
00119     // used for making a list of these files
00120     vtLULCFile *m_pNext;
00121 
00122 private:
00123     int     m_iNumSections;
00124     LULCSection *m_pSection;
00125     DMatrix3 m_transform;
00126 //  DMatrix3 m_forwards;
00127 };
00128 
00129 #endif // LULCH

Generated at Fri Aug 17 14:40:42 2001 for vtdata library by doxygen1.2.4 written by Dimitri van Heesch, © 1997-2000