//************************************************************************************************* //! Collects common code among all parsers //************************************************************************************************* void ossimQuickbirdRpcModel::finishConstruction() { theImageSize.line = theImageClipRect.height(); theImageSize.samp = theImageClipRect.width(); theRefImgPt.line = theImageClipRect.midPoint().y; theRefImgPt.samp = theImageClipRect.midPoint().x; theRefGndPt.lat = theLatOffset; theRefGndPt.lon = theLonOffset; theRefGndPt.hgt = theHgtOffset; //--- // NOTE: We must call "updateModel()" to set parameter used by base // ossimRpcModel prior to calling lineSampleHeightToWorld or all // the world points will be same. //--- updateModel(); ossimGpt v0, v1, v2, v3; lineSampleHeightToWorld(theImageClipRect.ul(), theHgtOffset, v0); lineSampleHeightToWorld(theImageClipRect.ur(), theHgtOffset, v1); lineSampleHeightToWorld(theImageClipRect.lr(), theHgtOffset, v2); lineSampleHeightToWorld(theImageClipRect.ll(), theHgtOffset, v3); theBoundGndPolygon = ossimPolygon (ossimDpt(v0), ossimDpt(v1), ossimDpt(v2), ossimDpt(v3)); // Set the ground reference point using the model. lineSampleHeightToWorld(theRefImgPt, theHgtOffset, theRefGndPt); if( theGSD.hasNans() ) { try { // This will set theGSD and theMeanGSD. Method throws ossimException. computeGsd(); } catch (const ossimException& e) { ossimNotify(ossimNotifyLevel_WARN) << "ossimQuickbirdRpcModel::finishConstruction -- caught exception:\n" << e.what() << std::endl; } } }
bool ossimNitfRsmModel::parseImageHeader(const ossimNitfImageHeader* ih) { static const char MODULE[] = "ossimNitfRsmModel::getRsmData"; if (traceExec()) { ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entering..." << std::endl; } bool status = false; if ( getRsmData(ih) ) { theImageID = m_iid.trim(); ossimIrect imageRect = ih->getImageRect(); // Fetch Image Size: theImageSize.line = static_cast<ossim_int32>(imageRect.height()); theImageSize.samp = static_cast<ossim_int32>(imageRect.width()); // Assign other data members: theRefImgPt.line = theImageSize.line/2.0; theRefImgPt.samp = theImageSize.samp/2.0; // Assign the bounding image space rectangle: theImageClipRect = ossimDrect(0.0, 0.0, theImageSize.samp-1, theImageSize.line-1); ossimGpt v0, v1, v2, v3; ossimDpt ip0 (0.0, 0.0); lineSampleHeightToWorld(ip0, m_znrmo, v0); ossimDpt ip1 (theImageSize.samp-1.0, 0.0); lineSampleHeightToWorld(ip1, m_znrmo, v1); ossimDpt ip2 (theImageSize.samp-1.0, theImageSize.line-1.0); lineSampleHeightToWorld(ip2, m_znrmo, v2); ossimDpt ip3 (0.0, theImageSize.line-1.0); lineSampleHeightToWorld(ip3, m_znrmo, v3); theBoundGndPolygon = ossimPolygon (ossimDpt(v0), ossimDpt(v1), ossimDpt(v2), ossimDpt(v3)); updateModel(); // Set the ground reference point. lineSampleHeightToWorld(theRefImgPt, m_znrmo, theRefGndPt); // Height could have nan if elevation is not set so check lat, lon individually. if ( ( theRefGndPt.isLatNan() == false ) && ( theRefGndPt.isLonNan() == false ) ) { //--- // This will set theGSD and theMeanGSD. This model doesn't need these but // others do. //--- try { computeGsd(); // Set return status. status = true; } catch (const ossimException& e) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimNitfRpcModel::ossimNitfRpcModel DEBUG:\n" << e.what() << std::endl; } setErrorStatus(); } } else { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimNitfRpcModel::ossimNitfRpcModel DEBUG:" << "\nGround Reference Point not valid(has nans)." << " Aborting with error..." << std::endl; } setErrorStatus(); } } else { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimNitfRpcModel::parseFile DEBUG:" << "\nError parsing rsm tags. Aborting with error." << std::endl; } setErrorStatus(); } if (traceExec()) { ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " exit status: " << ( status ? "true" : "false" ) << "\n"; } return status; } // End: ossimNitfRsmModel::parseImageHeader(const ossimNitfImageHeader* ih)
void ossimLandSatModel::initFromHeader(const ossimFfL7& head) { if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimLandSatModel::initFromHeader: entering..." << std::endl; theRefGndPt = head.theCenterGP; theRefImgPt = head.theCenterImagePoint; theImageSize.x = head.thePixelsPerLine; theImageSize.y = head.theLinesPerBand; theImageID = head.theRequestNumber; theSensorID = head.theSatName; theSensorDATE = head.theAcquisitionDate; theImageClipRect = ossimDrect(0, 0, theImageSize.x-1, theImageSize.y-1); theGSD.samp = head.theGsd; theGSD.line = head.theGsd; theIllumAzimuth = head.theSunAzimuth; theIllumElevation = head.theSunElevation; theMapZone = head.theUsgsMapZone; theWrsPathNumber = head.thePathNumber; theWrsRowNumber = head.theRowNumber; theRollOffset = head.theOffNadirAngle; theMeanGSD = head.theGsd; m_scale=head.theProjectionParams[2]; m_centerLongitude=(int)(head.theProjectionParams[4]+0.01)*1.0; m_theMapoffsetX=head.theProjectionParams[6]; m_theMapoffsetY=head.theProjectionParams[5]; semi_major=head.theProjectionParams[0]; semi_minor=head.theProjectionParams[1]; //int longcenter=(int)(head.theProjectionParams[4]+0.5); //theProjectionParams[4]=(double)longcenter; ossimString satname(head.theSatName); if (satname.contains("7")) { theOrbitAltitude = L7_ORBIT_ALTITUDE; theOrbitInclination = L7_ORBIT_INCLINATION; theNominalPosError = L7_NOMINAL_POS_ERROR; } else if (satname.contains("5")) { theOrbitAltitude = L5_ORBIT_ALTITUDE; theOrbitInclination = L5_ORBIT_INCLINATION; theNominalPosError = L5_NOMINAL_POS_ERROR; } else { theErrorStatus = 1; //MODEL_ERROR if(traceDebug()) { ossimNotify(ossimNotifyLevel_WARN) << "WARNING ossimLandSatModel::initFromHeader: " << "Unknown satellite name : " << satname << std::endl; } } double phi_c = ossim::atand(ossim::tand(theRefGndPt.lat)/ GEODETIC_2_GEOCENTRIC_FACTOR); double cos_phi_c = ossim::cosd(phi_c); theMeridianalAngle = -ossim::asind(ossim::cosd(theOrbitInclination) / cos_phi_c); theMapAzimAngle = head.theOrientationAngle; ossimDpt v[4]; // temporarily holds vertices for ground polygon v[0] = head.theUL_Corner; v[1] = head.theUR_Corner; v[2] = head.theLR_Corner; v[3] = head.theLL_Corner; theBoundGndPolygon = ossimPolygon(4, v); ossimString orient_type = head.theProductType; ossimString proj_type = head.theMapProjectionName; proj_type.trim(); if (proj_type.contains("SOM")) { if (orient_type.contains("ORBIT")) theProjectionType = SOM_ORBIT; else theProjectionType = SOM_MAP; theMapAzimAngle -= 90.0; } else if (proj_type.contains("UTM")) { if (orient_type.contains("ORBIT")) theProjectionType = UTM_ORBIT; else theProjectionType = UTM_MAP; } else if (proj_type.contains("TM")) { if (orient_type.contains("ORBIT")) theProjectionType = TM_ORBIT; else theProjectionType = TM_MAP; } else { theErrorStatus = 1; //MODEL_ERROR if(traceDebug()) { ossimNotify(ossimNotifyLevel_WARN) << "WARNING ossimLandSatModel::initFromHeader: " << "Unknown projection/orientation type." << std::endl; } return; } initMapProjection(); theMapOffset = theMapProjection->forward(head.theUL_Corner); if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimLandSatModel::initFromHeader:" << "\ntheMapProjection:\n"; theMapProjection->print(ossimNotify(ossimNotifyLevel_DEBUG)); ossimNotify(ossimNotifyLevel_DEBUG) << "\nHeader upper left ground point: " << head.theUL_Corner << std::endl; } initAdjustableParameters(); updateModel(); if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimLandSatModel::initFromHeader: returning..." << std::endl; }
void ossimH5GridModel::initializeModelParams(ossimIrect imageBounds) { theLatGrid.enableExtrapolation(); theLonGrid.enableExtrapolation(); theHeightEnabledFlag = false; // NOTE: it is assumed that the grid size and spacing is the same for ALL grids: ossimIpt gridSize (theLatGrid.size()); ossimDpt spacing (theLatGrid.spacing()); ossimDpt v[4]; v[0].lat = theLatGrid.getNode(0,0); v[0].lon = theLonGrid.getNode(0,0); v[1].lat = theLatGrid.getNode(gridSize.x-1, 0); v[1].lon = theLonGrid.getNode(gridSize.x-1, 0); v[2].lat = theLatGrid.getNode(gridSize.x-1, gridSize.y-1); v[2].lon = theLonGrid.getNode(gridSize.x-1, gridSize.y-1); v[3].lat = theLatGrid.getNode(0, gridSize.y-1); v[3].lon = theLonGrid.getNode(0, gridSize.y-1); if ( m_crossesDateline ) { // Longitude values between 0 and 360. m_boundGndPolygon = ossimPolygon(4, v); } // Guaranty longitude values are -180 to 180 for (int i=0; i<4; ++i) { if (v[i].lon > 180.0) v[i].lon -= 360.0; } theBoundGndPolygon = ossimPolygon(4, v); if ( !m_crossesDateline ) { // Longitude values between -180 and 180. m_boundGndPolygon = theBoundGndPolygon; } theImageSize = ossimDpt(imageBounds.width(), imageBounds.height()); theRefImgPt = imageBounds.midPoint(); theRefGndPt.lat = theLatGrid(theRefImgPt); theRefGndPt.lon = theLonGrid(theRefImgPt); ossimDpt ref_ip_dx (theRefImgPt.x+1.0, theRefImgPt.y ); ossimDpt ref_ip_dy (theRefImgPt.x , theRefImgPt.y+1.0); ossimGpt ref_gp_dx (theLatGrid(ref_ip_dx), theLonGrid(ref_ip_dx)); ossimGpt ref_gp_dy (theLatGrid(ref_ip_dy), theLonGrid(ref_ip_dy)); theGSD.x = theRefGndPt.distanceTo(ref_gp_dx); theGSD.y = theRefGndPt.distanceTo(ref_gp_dy); theMeanGSD = (theGSD.line + theGSD.samp)/2.0; theImageClipRect = imageBounds; // Image is clipped to valid rect so no sub image offset. theSubImageOffset = ossimDpt(0.0, 0.0); //imageBounds.ul(); theRefGndPt.limitLonTo180(); // debugDump(); } // End: initializeModelParams
bool ossimNitfRpcModel::parseImageHeader(const ossimNitfImageHeader* ih) { // Do this first so we don't waste time if not rpc image. if (getRpcData(ih) == false) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimNitfRpcModel::parseFile DEBUG:" << "\nError parsing rpc tags. Aborting with error." << std::endl; } setErrorStatus(); return false; } //--- // Get the decimation if any from the header "IMAG" field. // // Look for string like: // "/2" = 1/2 // "/4 = 1/4 // ... // "/16 = 1/16 // If it is full resolution it should be "1.0" //--- ossimString os = ih->getImageMagnification(); if ( os.contains("/") ) { os = os.after("/"); ossim_float64 d = os.toFloat64(); if (d) { theDecimation = 1.0 / d; } } //*** // Fetch Image ID: //*** theImageID = ih->getImageId(); ossimIrect imageRect = ih->getImageRect(); //--- // Fetch Image Size: //--- theImageSize.line = static_cast<ossim_int32>(imageRect.height() / theDecimation); theImageSize.samp = static_cast<ossim_int32>(imageRect.width() / theDecimation); // Search for the STDID Tag to fetch mission (satellite) name: getSensorID(ih); //*** // Assign other data members: //*** theRefImgPt.line = theImageSize.line/2.0; theRefImgPt.samp = theImageSize.samp/2.0; theRefGndPt.lat = theLatOffset; theRefGndPt.lon = theLonOffset; theRefGndPt.hgt = theHgtOffset; //*** // Assign the bounding image space rectangle: //*** theImageClipRect = ossimDrect(0.0, 0.0, theImageSize.samp-1, theImageSize.line-1); //--- // Assign the bounding ground polygon: // // NOTE: We will use the base ossimRpcModel for transformation since all // of our calls are in full image space (not decimated). //--- ossimGpt v0, v1, v2, v3; ossimDpt ip0 (0.0, 0.0); ossimRpcModel::lineSampleHeightToWorld(ip0, theHgtOffset, v0); ossimDpt ip1 (theImageSize.samp-1.0, 0.0); ossimRpcModel::lineSampleHeightToWorld(ip1, theHgtOffset, v1); ossimDpt ip2 (theImageSize.samp-1.0, theImageSize.line-1.0); ossimRpcModel::lineSampleHeightToWorld(ip2, theHgtOffset, v2); ossimDpt ip3 (0.0, theImageSize.line-1.0); ossimRpcModel::lineSampleHeightToWorld(ip3, theHgtOffset, v3); theBoundGndPolygon = ossimPolygon (ossimDpt(v0), ossimDpt(v1), ossimDpt(v2), ossimDpt(v3)); updateModel(); // Set the ground reference point. ossimRpcModel::lineSampleHeightToWorld(theRefImgPt, theHgtOffset, theRefGndPt); if ( theRefGndPt.isLatNan() || theRefGndPt.isLonNan() ) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimNitfRpcModel::ossimNitfRpcModel DEBUG:" << "\nGround Reference Point not valid." << " Aborting with error..." << std::endl; } setErrorStatus(); return false; } //--- // This will set theGSD and theMeanGSD. This model doesn't need these but // others do. //--- try { computeGsd(); } catch (const ossimException& e) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimNitfRpcModel::ossimNitfRpcModel DEBUG:\n" << e.what() << std::endl; } } if (traceExec()) { ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimNitfRpcModel::parseFile: returning..." << std::endl; } return true; }
//***************************************************************************** // METHOD: ossimIkonosRpcModel::finishConstruction() // //***************************************************************************** void ossimIkonosRpcModel::finishConstruction() { if (traceExec()) { ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimIkonosRpcModel finishConstruction(): entering..." << std::endl; } //*** // Assign other data members: //*** thePolyType = B; // This may not be true for early RPC imagery theRefImgPt.line = theLineOffset; theRefImgPt.samp = theSampOffset; theRefGndPt.lat = theLatOffset; theRefGndPt.lon = theLonOffset; theRefGndPt.hgt = theHgtOffset; //*** // Assign the bounding image space rectangle: //*** theImageClipRect = ossimDrect(0.0, 0.0, theImageSize.samp-1, theImageSize.line-1); //--- // NOTE: We must call "updateModel()" to set parameter used by base // ossimRpcModel prior to calling lineSampleHeightToWorld or all // the world points will be same. //--- updateModel(); //*** // Assign the bounding ground polygon: //*** ossimGpt v0, v1, v2, v3; ossimDpt ip0 (0.0, 0.0); lineSampleHeightToWorld(ip0, 0.0, v0); ossimDpt ip1 (theImageSize.samp-1.0, 0.0); lineSampleHeightToWorld(ip1, 0.0, v1); ossimDpt ip2 (theImageSize.samp-1.0, theImageSize.line-1.0); lineSampleHeightToWorld(ip2, 0.0, v2); ossimDpt ip3 (0.0, theImageSize.line-1.0); lineSampleHeightToWorld(ip3, 0.0, v3); theBoundGndPolygon = ossimPolygon (ossimDpt(v0), ossimDpt(v1), ossimDpt(v2), ossimDpt(v3)); //--- // Call compute gsd: // // This will set theGSD and theMeanGSD using lineSampleHeightToWorld on // three image points. Previously this was pulled from metadata. Some of // which was in US Survey feet and not converted to meters. This method // is more accurate as it uses the sensor model to compute. //--- try { // Method throws ossimException. computeGsd(); } catch (const ossimException& e) { ossimNotify(ossimNotifyLevel_WARN) << "ossimIkonosRpcModel finishConstruction Caught Exception:\n" << e.what() << std::endl; } if (traceExec()) { ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimIkonosRpcModel finishConstruction(): returning..." << std::endl; } }