00001 #include "linedefset.h" 00002 00003 LineDefSet::LineDefSet( ) { 00004 mLDFSet.clear(); 00005 fromXMLFile( GLIMSGlobals::GLDF_FILE, "Global_LDF" ); 00006 } 00007 00008 bool LineDefSet::toXML( QDomDocument &doc, 00009 QDomElement &elem, 00010 std::string id ) { 00011 QDomElement base = doc.createElement( "LineDefSet" ); 00012 if ( id != "" ) 00013 base.setAttribute( "id", id.c_str() ); 00014 elem.appendChild( base ); 00015 00016 for ( unsigned int ildf=0; ildf < mLDFSet.size(); ildf++ ) 00017 mLDFSet[ildf].toXML( doc, base ); 00018 return true; 00019 } 00020 00021 bool LineDefSet::fromXML( QDomElement &elem ) { 00022 QDomElement e; 00023 QDomNode node; 00024 if ( std::string( "LineDefSet" ).compare( (const char*)elem.tagName() ) ) 00025 return false; 00026 00027 mLDFSet.clear(); 00028 node = elem.firstChild(); 00029 while ( !node.isNull() ) { 00030 if ( !node.isElement() ) 00031 return false; 00032 e = node.toElement(); 00033 LineDef ldf; 00034 ldf.fromXML( e ); 00035 mLDFSet.push_back( ldf ); 00036 node = node.nextSibling(); 00037 } 00038 00039 return true; 00040 } 00041 00042 00048 bool LineDefSet::validate (ValidationReport * valRep) { 00049 bool dataValid = true ; 00050 std::stringstream rptstream ; 00051 00052 if (!mLDFSet.size ()) { 00053 rptstream << "There are no line definitions to check." ; 00054 valRep->subsectionEnd( rptstream.str() ) ; 00055 rptstream.str("") ; 00056 return dataValid ; 00057 } 00058 00059 for ( unsigned int ildf = 0 ; ildf < mLDFSet.size () ; ildf++ ) { 00060 // set up line style info for report 00061 string ldfLineStyle = "undefined"; 00062 if (mLDFSet[ildf].mStyle >= 0) { 00063 switch (mLDFSet[ildf].mStyle) { 00064 case 1 : ldfLineStyle = "Solid Line" ; break ; 00065 case 2 : ldfLineStyle = "Dashed Line" ; break ; 00066 case 3 : ldfLineStyle = "Dotted Line" ; break ; 00067 default: break ; 00068 } 00069 } 00070 rptstream << "Checking line definition, description: " 00071 << GLIMSGlobals::AVAILCOLORSTR[mLDFSet[ildf].mColor].c_str() 00072 << ", width " 00073 << mLDFSet[ildf].mWidth 00074 << ", style " 00075 << ldfLineStyle 00076 << ", segment label \"" 00077 << GLIMSGlobals::mGlbGlacTypes[mLDFSet[ildf].mGlacType].value.c_str() 00078 << "\""; 00079 valRep->subsectionBegin( rptstream.str() ) ; 00080 rptstream.str("") ; 00081 00082 if ( mLDFSet[ildf].validate (valRep) ) { 00083 rptstream << "Line definition is valid." ; 00084 } 00085 else { 00086 rptstream << "Line definition is missing information or invalid." ; 00087 dataValid = false ; 00088 } 00089 valRep->subsectionEnd( rptstream.str() ) ; 00090 rptstream.str("") ; 00091 } 00092 00093 return dataValid ; 00094 } 00095
Home |
Search |
Disclaimers & Privacy |
Contact Us GLIMSView Maintainer: dsoltesz@usgs.gov |