bool ossimOpjCompressor::loadState(const ossimKeywordlist& kwl, const char* prefix) { const char* value = 0; value = kwl.find(prefix, ossimKeywordNames::COMPRESSION_QUALITY_KW); if(value) { setQualityTypeString( ossimString(value) ); } value = kwl.find(prefix, LEVELS_KW); if(value) { m_levels = ossimString(value).toInt32(); } value = kwl.find(prefix, REVERSIBLE_KW); if(value) { setReversibleFlag(ossimString(value).toBool()); } value = kwl.find(prefix, ADD_ALPHA_CHANNEL_KW); if(value) { m_alpha = ossimString(value).toBool(); } value = kwl.find(prefix, THREADS_KW); if(value) { m_threads = ossimString(value).toInt32(); } ossimString searchKey; if (prefix) { searchKey = prefix; } searchKey += "option"; ossim_uint32 nOptions = kwl.numberOf(searchKey); for (ossim_uint32 i = 0; i < nOptions; ++i) { ossimString key = searchKey; key += ossimString::toString(i); const char* lookup = kwl.find(key.c_str()); if (lookup) { m_options.push_back(ossimString(lookup)); } } return true; }
//***************************************************************************** // METHOD: ossimImageViewProjectionTransform::loadState //***************************************************************************** bool ossimImageViewProjectionTransform::loadState(const ossimKeywordlist& kwl, const char* prefix) { bool result = ossimImageViewTransform::loadState(kwl, prefix); if(result) { ossimString imagePrefix = ossimString(prefix)+"image_geometry."; ossimString viewPrefix = ossimString(prefix)+"view_geometry."; if(kwl.numberOf(imagePrefix.c_str())>0) { m_imageGeometry = new ossimImageGeometry(); m_imageGeometry->loadState(kwl, imagePrefix.c_str()); } if(kwl.numberOf(viewPrefix.c_str())>0) { m_viewGeometry = new ossimImageGeometry(); m_viewGeometry->loadState(kwl, viewPrefix.c_str()); } } return result; }
void ossimPiecewiseRemapper::ossimBandRemap::loadState( const ossimKeywordlist& kwl, const std::string& prefix, ossim_uint32 band ) { //--- // Band Remap set example: // band0.remap0:((0, 127, 0, 127), (128, 255, 128, 382)) // band0.remap1:((0, 382, 0, 255)) //--- // Clear the sets: m_remap.clear(); // Get the number of remaps for this band. std::string keyBase = "band"; keyBase += ossimString::toString(band).string(); keyBase += "."; keyBase += REMAP_KW; ossim_uint32 NUMBER_REMAPS = kwl.numberOf(prefix.c_str(), keyBase.c_str()); ossim_uint32 found = 0; ossim_uint32 index = 0; // Loop to find band remaps. This allows for skipping indexes. while ( found < NUMBER_REMAPS ) { std::string key = keyBase + ossimString::toString(index).string(); std::string value = kwl.findKey( prefix, key ); if ( value.size() ) { ossimPiecewiseRemapper::ossimRemapSet set; if ( initRemapSetFromString( value, set ) ) { m_remap.push_back( set ); } ++found; } ++index; if ( index > (NUMBER_REMAPS+100) ) { break; } } } // End: ossimPiecewiseRemapper::ossimBandRemap::loadState
bool ossimHistogramRemapper::loadState(const ossimKeywordlist& kwl, const char* prefix) { static const char MODULE[] = "ossimHistogramRemapper::loadState"; if (traceDebug()) { CLOG << " Entered..." << "\nprefix: " << prefix << endl; } // Load the base class states... bool status = ossimTableRemapper::loadState(kwl, prefix); if (status) { const char* lookup = 0; ossimString keyword; lookup = kwl.find(prefix, HISTOGRAM_FILENAME_KW); if (lookup) { if ( !openHistogram(ossimFilename(lookup)) ) { ossimNotify(ossimNotifyLevel_WARN) << "ossimHistogramRemapper::loadState ERROR!" << "\nCould not open file: " << lookup << "\nReturning..." << endl; return false; } } //--- // Get the band specific keywords. // NOTES: // - This loadState assumes the all keywords will have the same number // of bands. // - The set methods cannot be used here as there may not be a connection // yet that they need. //--- ossim_uint32 bands = 0; lookup = kwl.find(prefix, ossimKeywordNames::NUMBER_BANDS_KW); if (lookup) { bands = ossimString::toUInt32(lookup); } else // For backwards compatibility. { // Use the low clip to find number of bands... keyword = NORMALIZED_LOW_CLIP_POINT_KW; bands = kwl.numberOf(prefix, keyword); } if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimHistogramRemapper::loadState DEBUG:" << "\nBands: " << bands << endl; } if (bands) { // Start with fresh clips. initializeClips(bands); for (ossim_uint32 band = 0; band < bands; ++band) { // Get the low clip. keyword = NORMALIZED_LOW_CLIP_POINT_KW; keyword += "."; keyword += ossimKeywordNames::BAND_KW; keyword += ossimString::toString(band+1); lookup = kwl.find(prefix, keyword); if(lookup) { theNormalizedLowClipPoint[band] = atof(lookup); } // Get the high clip. keyword = NORMALIZED_HIGH_CLIP_POINT_KW; keyword += "."; keyword += ossimKeywordNames::BAND_KW; keyword += ossimString::toString(band+1); lookup = kwl.find(prefix, keyword); if(lookup) { theNormalizedHighClipPoint[band] = atof(lookup); } // Get the mid point. keyword = MID_POINT_KW; keyword += "."; keyword += ossimKeywordNames::BAND_KW; keyword += ossimString::toString(band+1); lookup = kwl.find(prefix, keyword); if(lookup) { theMidPoint[band] = atof(lookup); } // Get the min output value. keyword = MIN_OUTPUT_VALUE_KW; keyword += "."; keyword += ossimKeywordNames::BAND_KW; keyword += ossimString::toString(band+1); lookup = kwl.find(prefix, keyword); if(lookup) { theMinOutputValue[band] = atof(lookup); } // Get the max output value. keyword = MAX_OUTPUT_VALUE_KW; keyword += "."; keyword += ossimKeywordNames::BAND_KW; keyword += ossimString::toString(band+1); lookup = kwl.find(prefix, keyword); if(lookup) { theMaxOutputValue[band] = atof(lookup); } } } lookup = kwl.find(prefix, STRETCH_MODE_KW); if (lookup) { ossimString s = lookup; s.downcase(); if (s == STRETCH_MODE[ossimHistogramRemapper::LINEAR_ONE_PIECE]) { theStretchMode = ossimHistogramRemapper::LINEAR_ONE_PIECE; } else if (s == STRETCH_MODE[ossimHistogramRemapper::LINEAR_1STD_FROM_MEAN]) { theStretchMode = ossimHistogramRemapper::LINEAR_1STD_FROM_MEAN; } else if (s == STRETCH_MODE[ossimHistogramRemapper::LINEAR_2STD_FROM_MEAN]) { theStretchMode = ossimHistogramRemapper::LINEAR_2STD_FROM_MEAN; } else if (s == STRETCH_MODE[ossimHistogramRemapper::LINEAR_3STD_FROM_MEAN]) { theStretchMode = ossimHistogramRemapper::LINEAR_3STD_FROM_MEAN; } else if (s == STRETCH_MODE[ossimHistogramRemapper::LINEAR_AUTO_MIN_MAX]) { theStretchMode = ossimHistogramRemapper::LINEAR_AUTO_MIN_MAX; } else { theStretchMode = ossimHistogramRemapper::STRETCH_UNKNOWN; } } // Always set the dirty flag. theDirtyFlag = true; } if (traceDebug()) { CLOG << "ossimHistogramRemapper::loadState DEBUG:" << *this << "\nExited..." << endl; } return status; }
void testIpts( ossimRefPtr<ossimNitfRsmModel>& model, const ossimKeywordlist& kwl ) { if ( model.valid() ) { cout << std::setfill(' ') << setiosflags(ios::left); const std::string ID_KW = "itest_id"; const std::string IPT_KW = "itest_ipt"; const std::string IPT_GT_KW = "itest_gt"; // ground truth const std::string IPT_HGT_KW = "itest_hgt"; const ossim_uint32 POINTS = kwl.numberOf( ID_KW.c_str() ); // Test data height values can be in feet. ossimUnitType heightUnits = OSSIM_METERS; std::string key = "itest_height_units"; std::string value = kwl.findKey( key ); if ( value.size() ) { cout << key << ": " << value << "\n"; if ( value == "feet" ) { heightUnits = OSSIM_FEET; } } // Test the pixel type. ossim_float64 iptShift = 0.0; key = "pixel_type"; value = kwl.findKey( key ); if ( value.size() ) { if ( value == "area" ) { iptShift = -0.5; cout << key << ": " << value << "\n"; cout << "input_line_sample_shift: " << iptShift << "\n"; } } cout << "\nitest begin ********************************\n\n" << "number_of_line_sample_points: " << POINTS << "\n"; ossim_uint32 foundPts = 0; ossim_uint32 i = 0; while ( foundPts < POINTS ) { // ID: key = ID_KW + ossimString::toString( i ).string(); value = kwl.findKey( key ); if ( value.size() ) { cout << "itest_id" << std::setw(9) << i << ": " << value << "\n"; } // Image point, sample, line: key = IPT_KW + ossimString::toString( i ).string(); value = kwl.findKey( key ); if ( value.size() ) { ossimDpt ipt; // image point ossimGpt wpt; // world point ossimGpt gt; // ground truth ossimDpt gtd; // wpt to gt delta ossimDpt rtp; // round trip point ossimDpt rtd; // round trip delta; ipt.toPoint( value ); ipt.x += iptShift; ipt.y += iptShift; cout << "itest_ipt" << std::setw(8) << i << ": " << value << "\n"; // Get the height above ellipsoid: ossim_float64 hgt = 0.0; key = IPT_HGT_KW + ossimString::toString( i ).string(); value = kwl.findKey( key ); if ( value.size() ) { ossimString os ( value ); hgt = os.toFloat64(); if ( heightUnits == OSSIM_FEET ) { hgt *= MTRS_PER_FT; } } else { cerr << "missing height above ellipsoid for point! Using 0.0." << endl; } cout << "itest_hgt" << std::setw(8) << i << ": " << value << "\n"; model->lineSampleHeightToWorld( ipt, hgt, wpt ); cout << "itest_wpt" << std::setw(8) << i << ": " << wpt << "\n"; if ( wpt.hasNans() == false ) { model->worldToLineSample( wpt, rtp ); // Get the ground truth; key = IPT_GT_KW + ossimString::toString( i ).string(); value = kwl.findKey( key ); if ( value.size() ) { gt.toPoint( value ); cout << "itest_gt" << std::setw(9) << i << ": " << gt << "\n"; if ( gt.isNan() == false ) { gtd.x = wpt.lon - gt.lon; gtd.y = wpt.lat - gt.lat; ossimDpt mpd = wpt.metersPerDegree(); ossimDpt gtm; gtm.x = gtd.x * mpd.x; gtm.y = gtd.y * mpd.y; cout << "itest_gtd_dd" << std::setw(5) << i << ": " << gtd << "\n"; cout << "itest_gtd_mtrs" << std::setw(3) << i << ": " << gtm << "\n"; } } else { gt.makeNan(); } rtd = ipt - rtp; cout << "itest_rtp" << std::setw(8) << i << ": " << rtp << "\n" << "itest_rtd" << std::setw(8) << i << ": " << rtd << "\n\n"; } else { cerr << "model->worldToLineSample(...) result has nans!\n" << wpt << endl; } ++foundPts; } ++i; if ( i > POINTS+100 ) { break; } } cout << "\ntestIpts end **********************************\n\n"; } } // End: testIpts
void testGpts( ossimRefPtr<ossimNitfRsmModel>& model, const ossimKeywordlist& kwl ) { if ( model.valid() ) { cout << std::setfill(' ') << setiosflags(ios::left); const std::string ID_KW = "gtest_id"; const std::string GPT_KW = "gtest_gpt"; const ossim_uint32 POINTS = kwl.numberOf( ID_KW.c_str() ); cout << "\ngtest begin ********************************\n\n" << "number_of_points_world_points: " << POINTS << "\n"; ossim_uint32 foundPts = 0; ossim_uint32 i = 0; std::string key; std::string value; while ( foundPts < POINTS ) { // ID: key = ID_KW + ossimString::toString( i ).string(); value = kwl.findKey( key ); if ( value.size() ) { cout << "gtest_id" << std::setw(6) << i << ": " << value << "\n"; } // World point : key = GPT_KW + ossimString::toString( i ).string(); value = kwl.findKey( key ); if ( value.size() ) { ossimDpt ipt; // image point ossimGpt wpt; // world point ossimGpt rtp; // round trip point ossimDpt rtd; // round trip delta; wpt.toPoint( value ); cout << "gtest_gpt" << std::setw(5) << i << ": " << wpt << "\n"; model->worldToLineSample( wpt, ipt ); if ( wpt.hasNans() == false ) { model->lineSampleHeightToWorld( ipt, wpt.hgt, rtp ); rtd.x = wpt.lon - rtp.lon; rtd.y = wpt.lat - rtp.lat; cout << "gtest_ipt" << std::setw(5) << i << ": " << ipt << "\n" << "gtest_rtp" << std::setw(5) << i << ": " << rtp << "\n" << "gtest_rtd" << std::setw(5) << i << ": " << rtd << "\n\n"; } else { cerr << "model->worldToLineSample(...) result has nans!\n" << wpt << endl; } ++foundPts; } ++i; if ( i > POINTS+100 ) { break; } } cout << "\ngtest end **********************************\n\n"; } } // End: testGpts