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