00001 #include "l7a_nlaps.h" 00002 #include <iostream> 00003 #include "TraceLog.h" 00004 00005 bool L7A_Nlaps::open( std::string fname ) { 00006 const int name_len = 29; 00007 const std::string strnum[] = { "1", "2", "3"}; 00008 00009 if ( (int)fname.length() < name_len ) 00010 return false; 00011 00012 std::string dir = fname.substr( 0, fname.length()-name_len ); 00013 fname = fname.substr( fname.length()-name_len, name_len ); 00014 std::string pre = fname.substr( 0, fname.length()-1 ); 00015 std::string testname; 00016 bool opened = false; 00017 00018 for ( int iband=0; iband < 3; iband++ ) { 00019 testname = dir + pre + strnum[iband]; 00020 NlapsFrmt *nlaps = new NlapsFrmt; 00021 if ( nlaps->open( testname ) ) { 00022 mFormatSet.push_back( nlaps ); 00023 std::vector<BandInf> &bset = nlaps->getBandInfSet(); 00024 for ( int i=0; i < (int)bset.size(); i++ ) 00025 mBandSet.push_back( bset[i] ); 00026 opened = true; 00027 } else { 00028 delete nlaps; 00029 } 00030 } 00031 00032 if ((int)mBandSet.size()) { 00033 double x = mBandSet[0].width / 2; 00034 double y = mBandSet[0].height / 2; 00035 getLL( 0, x, y ); 00036 mImageInf.mCenterLat = y; 00037 mImageInf.mCenterLon = x; 00038 } 00039 mImageInf.mLocURL = fname ; 00040 00041 // delete pdlg; 00042 return opened; 00043 } 00044 00045 void L7A_Nlaps::getLL( int iband, double &i, double &j ) { 00046 if ( iband < 0 || iband > (int)mBandSet.size() ) 00047 return; 00048 00049 int ifrmt = getFrmt( iband ); 00050 mFormatSet[ifrmt]->getLL( iband, i, j ); 00051 } 00052 00053 void L7A_Nlaps::getXY( int iband, double &i, double &j ) { 00054 if ( iband < 0 || iband > (int)mBandSet.size() ) 00055 return; 00056 00057 int ifrmt = getFrmt( iband ); 00058 mFormatSet[ifrmt]->getXY( iband, i, j ); 00059 } 00060 00061 void* L7A_Nlaps::getBand( int iband, 00062 int x1, 00063 int y1, 00064 int w1, 00065 int h1, 00066 int w2, 00067 int h2, 00068 ScaleType st ) const { 00069 if ( iband < 0 || iband > (int)mBandSet.size() ) 00070 return NULL; 00071 00072 int fiband = iband; 00073 int ifrmt = getFrmt( fiband ); 00074 00075 return mFormatSet[ifrmt]->getBand( fiband, x1, y1, w1, h1, w2, h2, st ); 00076 } 00077 00078 int L7A_Nlaps::getFrmt( int &iband ) const { 00079 int ifrmt = 0; 00080 if ( iband < 0 || iband > (int)mBandSet.size() ) 00081 return -1; 00082 00083 00084 for ( int i=0; i < (int)mFormatSet.size(); i++ ) { 00085 int nband = (int)mFormatSet[i]->getNumBands(); 00086 if ( iband >= nband ) { 00087 ifrmt++; 00088 iband -= nband; 00089 } else { 00090 break; 00091 } 00092 } 00093 00094 return ifrmt; 00095 } 00096 00097 00098 00099
Home |
Search |
Disclaimers & Privacy |
Contact Us GLIMSView Maintainer: dsoltesz@usgs.gov |