00001 #ifndef __LINEDEF_H 00002 #define __LINEDEF_H 00003 00004 #include "xmlserializeable.h" 00005 #include "ValidationReport.h" 00006 00027 class LineDef : public XMLSerializeable { 00028 public: 00029 int mGlacType; // GLACIER TYPE 00030 int mType; // SEGMENT TYPE 00031 int mLabel; // SEGMENT LABEL 00032 int mLMat, mRMat; // LEFT/RIGHT MATERIAL 00033 float mLXUncert, mLYUncert; // LOCAL X/Y UNCERTAINTY 00034 float mGXUncert, mGYUncert; // GLOBAL X/Y UNCERTAINTY 00035 int mLFeature, mRFeature; // LEFT/RIGHT FEATURE 00036 int mColor; // LINE COLOR 00037 int mStyle; // LINE STYLE 00038 int mWidth; // LINE WIDTH 00039 char* mName; // LINE NAME 00040 00047 LineDef( ) { 00048 mGlacType = 0; 00049 mType = 0; 00050 mLabel = 0; 00051 mLMat = 0; 00052 mRMat = 0; 00053 mLXUncert = -999.0f; 00054 mLYUncert = -999.0f; 00055 mGXUncert = -999.0f; 00056 mGYUncert = -999.0f; 00057 mLFeature = 0; 00058 mRFeature = 0; 00059 mColor = 0; 00060 mStyle = 0; 00061 mWidth = 0; 00062 mName = ""; 00063 } 00064 00065 virtual bool fromXML( QDomElement &elem ) { 00066 if ( std::string( "LineDefinition" ).compare( (const char*)elem.tagName() ) ) 00067 return false; 00068 00069 mGlacType = readIntTag( elem, "GlacType" ); 00070 mType = readIntTag( elem, "Type" ); 00071 mLabel = readIntTag( elem, "Label" ); 00072 mLMat = readIntTag( elem, "LMat" ); 00073 mRMat = readIntTag( elem, "RMat" ); 00074 mLXUncert = readDoubleTag( elem, "LXUncert" ); 00075 mLYUncert = readDoubleTag( elem, "LYUncert" ); 00076 mGXUncert = readDoubleTag( elem, "GXUncert" ); 00077 mGXUncert = readDoubleTag( elem, "GYUncert" ); 00078 mLFeature = readIntTag( elem, "LFeature" ); 00079 mRFeature = readIntTag( elem, "RFeature" ); 00080 mColor = readIntTag( elem, "Color" ); 00081 mStyle = readIntTag( elem, "Style" ); 00082 mWidth = readIntTag( elem, "Width" ); 00083 mName = (char*)readTextTag(elem, "Name" ).c_str(); 00084 00085 return true; 00086 } 00087 00088 virtual bool toXML( QDomDocument &doc, 00089 QDomElement &elem, 00090 std::string id = "" ) { 00091 QDomElement base = doc.createElement( "LineDefinition" ); 00092 if ( id != "" ) 00093 base.setAttribute( "id", (char*)id.c_str() ); 00094 elem.appendChild( base ); 00095 00096 writeIntTag( doc, base, "GlacType", mGlacType ); 00097 writeIntTag( doc, base, "Type", mType ); 00098 writeIntTag( doc, base, "Label", mLabel ); 00099 writeIntTag( doc, base, "LMat", mLMat ); 00100 writeIntTag( doc, base, "RMat", mRMat ); 00101 writeDoubleTag( doc, base, "LXUncert", mLXUncert ); 00102 writeDoubleTag( doc, base, "LYUncert", mLYUncert ); 00103 writeDoubleTag( doc, base, "GXUncert", mGXUncert ); 00104 writeDoubleTag( doc, base, "GYUncert", mGYUncert ); 00105 writeIntTag( doc, base, "LFeature", mLFeature ); 00106 writeIntTag( doc, base, "RFeature", mRFeature ); 00107 writeIntTag( doc, base, "Color", mColor ); 00108 writeIntTag( doc, base, "Style", mStyle ); 00109 writeIntTag( doc, base, "Width", mWidth ); 00110 writeTextTag( doc, base, "Name", mName ); // dls 5/20/04 - was set to GlacType instead of Name 00111 00112 return true; 00113 } 00114 00115 bool operator==( LineDef &ldf ) { 00116 00117 if ( ldf.mGlacType == mGlacType && 00118 ldf.mGXUncert == mGXUncert && 00119 ldf.mGYUncert == mGYUncert && 00120 ldf.mLabel == mLabel && 00121 ldf.mLFeature == mLFeature && 00122 ldf.mLMat == mLMat && 00123 ldf.mLXUncert == mLXUncert && 00124 ldf.mLYUncert == mLYUncert && 00125 ldf.mName == mName && 00126 ldf.mRFeature == mRFeature && 00127 ldf.mRMat == mRMat && 00128 ldf.mType == mType ) 00129 return true; 00130 return false; 00131 } 00132 00133 bool operator!=( LineDef &ldf ) { 00134 return !(*this == ldf); 00135 } 00136 00137 00138 00144 bool validate (ValidationReport * valRep) { 00145 bool dataValid = true ; 00146 std::stringstream rptstream ; 00147 00148 00149 // Glacier type 00150 if ( mGlacType < 0 ) { 00151 valRep->reportError( "Glacier type is invalid." ) ; 00152 dataValid = false ; 00153 } 00154 00155 // Segment type 00156 if ( mType < 0 ) { 00157 valRep->reportError( "Segment type is not defined." ) ; 00158 dataValid = false ; 00159 } 00160 00161 // Segment label 00162 if ( !mLabel ) { 00163 valRep->reportWarning( "Segment label is not defined." ) ; 00164 } 00165 00166 // Local X uncertainty 00167 if ( mLXUncert == -999.0 ) { 00168 valRep->reportWarning( "Local X uncertainty is not defined. This attribute is required." ) ; 00169 } 00170 00171 // Local Y uncertainty 00172 if ( mLYUncert == -999.0 ) { 00173 valRep->reportWarning( "Local Y uncertainty is not defined. This attribute is required." ) ; 00174 } 00175 00176 // Global X uncertainty 00177 if ( mGXUncert == -999.0 ) { 00178 valRep->reportWarning( "Global X uncertainty is not defined. This attribute is required." ) ; 00179 } 00180 00181 // Global Y uncertainty 00182 if ( mGYUncert == -999.0 ) { 00183 valRep->reportWarning( "Global Y uncertainty is not defined. This attribute is required." ) ; 00184 } 00185 00186 // Left material 00187 if ( !mLMat ) { 00188 valRep->reportWarning( "Left material is set to NULL." ) ; 00189 } 00190 00191 // Right material 00192 if ( !mRMat ) { 00193 valRep->reportWarning( "Right material is set to NULL." ) ; 00194 } 00195 00196 // Left feature 00197 if ( !mLFeature ) { 00198 valRep->reportWarning( "Left feature is set to NULL." ) ; 00199 } 00200 00201 // Right feature 00202 if ( !mRFeature ) { 00203 valRep->reportWarning( "Right feature is set to NULL." ) ; 00204 } 00205 00207 /* 00208 // Definition name 00209 if ( !mName || mName[0] == '\0') { 00210 valRep->reportWarning( "Definition name is not defined." ) ; 00211 } 00212 */ 00213 00214 /* 00215 // end line definition check 00216 if (dataValid) { 00217 rptstream << "Line definition is valid." ; 00218 valRep->subsectionEnd( rptstream.str() ) ; 00219 } 00220 else { 00221 rptstream << "Line definition has missing or invalid information." ; 00222 valRep->subsectionEnd( rptstream.str() ) ; 00223 } 00224 */ 00225 00226 // return status of check 00227 return dataValid ; 00228 } 00229 00230 00231 }; 00232 00233 #endif 00234 00235 00236
Home |
Search |
Disclaimers & Privacy |
Contact Us GLIMSView Maintainer: dsoltesz@usgs.gov |