bool ossimNitfRpcModel::loadState(const ossimKeywordlist& kwl, const char* prefix) { // Lookup decimation. const char* value = kwl.find(prefix, "decimation"); if (value) { theDecimation = ossimString(value).toFloat64(); if (theDecimation <= 0.0) { // Do not allow negative or "0.0"(divide by zero). theDecimation = 1.0; } } // Call base. return ossimRpcModel::loadState(kwl, prefix); }
bool ossimKeywordlist::operator ==(ossimKeywordlist& kwl)const { if(this==&kwl) return true; std::map<std::string, std::string>::const_iterator iter = m_map.begin(); while(iter != m_map.end()) { const char* value = kwl.find((*iter).first.c_str()); if(ossimString(value) != (*iter).second) { return false; } ++iter; } return true; }
bool ossimVanDerGrintenProjection::loadState(const ossimKeywordlist& kwl, const char* prefix) { bool flag = ossimMapProjection::loadState(kwl, prefix); const char* type = kwl.find(prefix, ossimKeywordNames::TYPE_KW); setDefaults(); if(ossimString(type) == STATIC_TYPE_NAME(ossimVanDerGrintenProjection)) { Grin_False_Easting = theFalseEastingNorthing.x; Grin_False_Northing = theFalseEastingNorthing.y; } update(); return flag; }
void ossimLasReader::initUnits(const ossimKeywordlist& geomKwl) { ossimMapProjection* proj = dynamic_cast<ossimMapProjection*>( m_proj.get() ); if ( proj ) { if ( proj->isGeographic() ) { m_units = OSSIM_DEGREES; } else { const char* lookup = geomKwl.find("image0.linear_units"); if ( lookup ) { std::string units = lookup; if ( units == "meters" ) { m_units = OSSIM_METERS; } else if ( units == "feet" ) { m_units = OSSIM_FEET; } else if ( units == "us_survey_feet" ) { m_units = OSSIM_US_SURVEY_FEET; } else { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimLibLasReader::initUnits WARN:\n" << "Unhandled linear units code: " << units << std::endl; } } } } // Don't make a unit converter for decimal degrees... if ( (m_units != OSSIM_DEGREES) && (m_units != OSSIM_METERS) && !m_unitConverter ) { m_unitConverter = new ossimUnitConversionTool(); } }
bool ossimAdjustableParameterInfo::loadState(const ossimKeywordlist& kwl, const ossimString& prefix) { const char* param = kwl.find(prefix, PARAM_KW); const char* sigma = kwl.find(prefix, PARAM_SIGMA_KW); const char* center = kwl.find(prefix, PARAM_CENTER_KW); const char* unit = kwl.find(prefix, ossimKeywordNames::UNITS_KW); const char* locked = kwl.find(prefix, PARAM_LOCK_FLAG_KW); theDescription = kwl.find(prefix, ossimKeywordNames::DESCRIPTION_KW); if(param) { theParameter = ossimString(param).toDouble(); } else { theParameter = 0.0; } if(unit) { theUnit = (ossimUnitType)(ossimUnitTypeLut::instance()->getEntryNumber(unit)); } else { theUnit = OSSIM_UNIT_UNKNOWN; } if(sigma) { theSigma = ossimString(sigma).toDouble(); } else { theSigma = 0.0; } if(center) { theCenter = ossimString(center).toDouble(); } else { theCenter = 0.0; } if(locked) { theLockFlag = ossimString(locked).toBool(); } return true; }
bool ossimplugins::ossimRadarSat2TiffReader::loadState( const ossimKeywordlist& kwl, const char* prefix) { static const char MODULE[] = "ossimplugins::ossimRadarSat2TiffReader::loadState"; if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entered...\n"; } bool result = false; // Get the product.xml file name. const char* lookup = kwl.find(prefix, PRODUCT_XML_FILE_KW); if (lookup) { theProductXmlFile = lookup; if ( isRadarSat2ProductFile(theProductXmlFile) ) { //--- // Although we can open any tiff here we only do if we have matching // RS2 product.xml. //--- result = ossimTiffTileSource::loadState(kwl, prefix); } } if (!result) { theProductXmlFile.clear(); } if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " exit status = " << (result?"true":"false\n") << std::endl; } return result; }
bool PlatformPosition::loadState(const ossimKeywordlist& kwl, const char* prefix) { bool result = true; Clear(); const char* lookup = 0; lookup = kwl.find(prefix, NUMBER_PLATFORM_POSITIONS_KW); if (lookup) { ossimString s = lookup; _nbrData = s.toInt(); if (_nbrData) { std::string s1; if (prefix) { s1 = prefix; } _data = new Ephemeris*[_nbrData]; for (int i = 0; i < _nbrData; ++i) { std::string s2 = s1; s2 += "platform_position["; s2 += ossimString::toString(i).chars(); s2+= "]"; _data[i] = new Ephemeris(); _data[i]->loadState(kwl, s2.c_str()); } } } else { result = false; } return result; }
bool ossimCassiniProjection::loadState(const ossimKeywordlist& kwl, const char* prefix) { // Must do this first. bool flag = ossimMapProjection::loadState(kwl, prefix); const char* type = kwl.find(prefix, ossimKeywordNames::TYPE_KW); setDefaults(); if(ossimString(type) == STATIC_TYPE_NAME(ossimCassiniProjection)) { Cass_False_Easting = theFalseEastingNorthing.x; Cass_False_Northing = theFalseEastingNorthing.y; } update(); return flag; }
bool ossimImageCacheBase::loadState(const ossimKeywordlist& kwl, const char* prefix) { const char* MODULE = "ossimImageCacheBase::loadState"; if(traceDebug()) { CLOG << "Entering..." << endl; } bool result = ossimImageHandler::loadState(kwl, prefix); if(!result) { if(traceDebug()) { CLOG << "Leaving..." << endl; } return false; } const char* lookup = 0; lookup = kwl.find(ossimString(prefix), "entry"); ossim_int32 entry = ossimString(lookup).toInt32(); // if an entry is specified then // call the open with an entry number if(lookup) { if(traceDebug()) { CLOG << "Leaving..." << endl; } result = ossimImageHandler::open(theImageFile); setCurrentEntry(entry); return result; } result = ossimImageHandler::open(theImageFile); return result; }
bool ossimHistogramEqualization::loadState(const ossimKeywordlist& kwl, const char* prefix) { static const char MODULE[] = "ossimHistogramEqualization::loadState"; if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << " Entered..." << "\nprefix: " << prefix << endl; } const char* lookup = kwl.find(prefix, HISTOGRAM_INVERSE_FLAG_KW); if(lookup) { theInverseFlag = ossimString(lookup).toBool(); } if(ossimImageSourceHistogramFilter::loadState(kwl, prefix)) { // computeAccumulationHistogram(); // initializeLuts(); } else { return false; } if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG:" << MODULE; this->print(ossimNotify(ossimNotifyLevel_DEBUG)); ossimNotify(ossimNotifyLevel_DEBUG) << "\nExited..." << endl; } return true; }
void ossimQtVceCanvasWidget::addAllDataManagerObjects(const ossimKeywordlist& kwl, const QPoint& location, const char* prefix) { QPoint locationPoint = location; if((locationPoint.x() == -1)&& (locationPoint.y() == -1)) { locationPoint.setX(0); locationPoint.setY(0); } ossimQtGetDataManagerEvent tempEvt; ossimQtApplicationUtility::sendEventToRoot(this, &tempEvt); if(tempEvt.getDataManager()) { ossimString regExpression = ossimString("^(") + ossimString(prefix)+ "object[0-9]+.)"; std::vector<ossimString> keys = kwl.getSubstringKeyList( regExpression ); int numberOfObjects = keys.size(); int idx = 0; for(idx = 0; idx < numberOfObjects; ++idx) { const char* id = kwl.find(keys[idx]+"id"); if(id) { ossimConnectableObject* obj = PTR_CAST(ossimConnectableObject, tempEvt.getDataManager()->getObject(ossimId(ossimString(id).toInt()))); if(addDataManagerObject(obj, locationPoint)) { locationPoint.setY(locationPoint.y() + 74); } } } } }
bool ossimLandsatTileSource::loadState(const ossimKeywordlist& kwl, const char* prefix) { const char* lookup = kwl.find(prefix, ossimKeywordNames::FILENAME_KW); if (lookup) { ossimFilename fileName = lookup; ossimString ext = fileName.ext(); if((ext.upcase() == "FST") || (ext.upcase() == "DAT")) { //--- // This will call: // ossimImageHandler::loadState() the open() //--- if (ossimGeneralRasterTileSource::loadState(kwl, prefix)) { return true; } } } return false; }
bool ossimSpectraboticsRedEdgeModel::loadState(const ossimKeywordlist& kwl, const char* prefix) { if(traceDebug()) { std::cout << "ossimSpectraboticsRedEdgeModel::loadState: ......... entered" << std::endl; } //ossimSensorModel::loadState(kwl,prefix); ossimSensorModel::loadState(kwl, prefix); if(getNumberOfAdjustableParameters() < 1) { initAdjustableParameters(); } m_ecefPlatformPosition = ossimGpt(0.0,0.0,1000.0); m_adjEcefPlatformPosition = ossimGpt(0.0,0.0,1000.0); m_roll = 0.0; m_pitch = 0.0; m_heading = 0.0; // bool computeGsdFlag = false; const char* roll = kwl.find(prefix, "Roll"); const char* pitch = kwl.find(prefix, "Pitch"); const char* heading = kwl.find(prefix, "Yaw"); const char* focalLength = kwl.find(prefix, "Focal Length"); const char* imageWidth = kwl.find(prefix, "Image Width"); const char* imageHeight = kwl.find(prefix, "Image Height"); const char* fov = kwl.find(prefix, "Field Of View"); const char* gpsPos = kwl.find(prefix, "GPS Position"); const char* gpsAlt = kwl.find(prefix, "GPS Altitude"); const char* imageCenter = kwl.find(prefix, "Image Center"); const char* fx = kwl.find(prefix, "fx"); const char* fy = kwl.find(prefix, "fy"); const char* cx = kwl.find(prefix, "cx"); const char* cy = kwl.find(prefix, "cy"); const char* k = kwl.find(prefix, "k"); const char* p = kwl.find(prefix, "p"); bool result = true; #if 0 std::cout << "roll: " << roll << "\n"; std::cout << "pitch: " << pitch << "\n"; std::cout << "heading: " << heading << "\n"; std::cout << "focalLength: " << focalLength << "\n"; std::cout << "imageWidth: " << imageWidth << "\n"; std::cout << "imageHeight: " << imageHeight << "\n"; // std::cout << "fov: " << fov << "\n"; std::cout << "gpsPos: " << gpsPos << "\n"; std::cout << "gpsAlt: " << gpsAlt << "\n"; #endif // if(k&&p) { m_lensDistortion = new ossimTangentialRadialLensDistortion(); m_lensDistortion->loadState(kwl, prefix); } if(roll&& pitch&& heading&& focalLength&& imageWidth&& imageHeight&& gpsPos&& gpsAlt) { theSensorID = "MicaSense RedEdge"; m_roll = ossimString(roll).toDouble(); m_pitch = ossimString(pitch).toDouble(); m_heading = ossimString(heading).toDouble(); m_focalLength = ossimString(focalLength).toDouble(); m_fov = fov?ossimString(fov).toDouble():48.8; theImageSize.x = ossimString(imageWidth).toDouble(); theImageSize.y = ossimString(imageHeight).toDouble(); theImageClipRect = ossimDrect(0,0,theImageSize.x-1,theImageSize.y-1); theRefImgPt = ossimDpt(theImageSize.x/2.0, theImageSize.y/2.0); m_calibratedCenter = theImageClipRect.midPoint(); // now lets use the field of view and the focal length to // calculate the pixel size on the ccd in millimeters double d = tan((m_fov*0.5)*M_PI/180.0)*m_focalLength; d*=2.0; double tempRadiusPixel = theImageSize.length(); m_pixelSize.x = (d)/tempRadiusPixel; m_pixelSize.y = m_pixelSize.x; if(imageCenter) { std::vector<ossimString> splitString; ossimString tempString(imageCenter); tempString.split(splitString, ossimString(" ")); if(splitString.size() == 2) { theRefImgPt = ossimDpt(splitString[0].toDouble(), splitString[1].toDouble()); } } else { if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "No Image Center found" << std::endl; // result = false; } } // now extract the GPS position and shift it to the ellipsoidal height. std::vector<ossimString> splitArray; ossimString(gpsPos).split(splitArray, ","); splitArray[0] = splitArray[0].replaceAllThatMatch("deg", " "); splitArray[1] = splitArray[1].replaceAllThatMatch("deg", " "); ossimDms dmsLat; ossimDms dmsLon; double h = ossimString(gpsAlt).toDouble(); dmsLat.setDegrees(splitArray[0]); dmsLon.setDegrees(splitArray[1]); double lat = dmsLat.getDegrees(); double lon = dmsLon.getDegrees(); h = h+ossimGeoidManager::instance()->offsetFromEllipsoid(ossimGpt(lat,lon)); m_ecefPlatformPosition = ossimGpt(lat,lon,h); // double height1 = ossimElevManager::instance()->getHeightAboveEllipsoid(ossimGpt(lat, lon)); //std::cout << "PLATFORM HEIGHT: " << h << "\n" // << "ELEVATION: " << height1 << "\n"; // std::cout << m_ecefPlatformPosition << std::endl; // std::cout << "POINT: " << ossimGpt(lat,lon,h) << std::endl; // std::cout << "MSL: " << height1 << "\n"; theRefGndPt = m_ecefPlatformPosition; theRefGndPt.height(0.0); m_norm = ossim::nan(); // lens parameters if(m_lensDistortion.valid()&&cx&&cy&&fx&&fy) { m_focalX = ossimString(fx).toDouble(); m_focalY = ossimString(fy).toDouble(); // our lens distorion assume center point. So // lets shift to center and then set calibrated relative to // image center. We will then normalize. // ossimDpt focal(m_focalX,m_focalY); m_norm = focal.length()*0.5; // convert from diameter to radial m_calibratedCenter = ossimDpt(ossimString(cx).toDouble(), ossimString(cy).toDouble()); m_principalPoint = m_calibratedCenter-theImageClipRect.midPoint(); m_principalPoint.x /= m_norm; m_principalPoint.y /= m_norm; // lets initialize the root to be about one pixel norm along the diagonal // and the convergence will be approximately 100th of a pixel. // double temp = m_norm; if(temp < FLT_EPSILON) temp = 1.0; else temp = 1.0/temp; m_lensDistortion->setCenter(m_principalPoint); m_lensDistortion->setDxDy(ossimDpt(temp,temp)); m_lensDistortion->setConvergenceThreshold(temp*0.001); } else { m_lensDistortion = 0; m_calibratedCenter = theImageClipRect.midPoint(); m_norm = theImageSize.length()*0.5; m_principalPoint = ossimDpt(0,0); } updateModel(); } else // load from regular save state { const char* principal_point = kwl.find(prefix, "principal_point"); const char* pixel_size = kwl.find(prefix, "pixel_size"); const char* ecef_platform_position = kwl.find(prefix, "ecef_platform_position"); const char* latlonh_platform_position = kwl.find(prefix, "latlonh_platform_position"); // const char* compute_gsd_flag = kwl.find(prefix, "compute_gsd_flag"); roll = kwl.find(prefix, "roll"); pitch = kwl.find(prefix, "pitch"); heading = kwl.find(prefix, "heading"); fov = kwl.find(prefix, "field_of_view"); focalLength = kwl.find(prefix, "focal_length"); if(roll) { m_roll = ossimString(roll).toDouble(); } if(pitch) { m_pitch = ossimString(pitch).toDouble(); } if(heading) { m_heading = ossimString(heading).toDouble(); } if(cx&&cy) { m_calibratedCenter = ossimDpt(ossimString(cx).toDouble(), ossimString(cy).toDouble()); } if(principal_point) { std::vector<ossimString> splitString; ossimString tempString(principal_point); tempString.split(splitString, ossimString(" ")); if(splitString.size() == 2) { m_principalPoint.x = splitString[0].toDouble(); m_principalPoint.y = splitString[1].toDouble(); } } else { if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "No principal_point found" << std::endl; // result = false; } } if(pixel_size) { std::vector<ossimString> splitString; ossimString tempString(pixel_size); tempString.split(splitString, ossimString(" ")); if(splitString.size() == 1) { m_pixelSize.x = splitString[0].toDouble(); m_pixelSize.y = m_pixelSize.x; } else if(splitString.size() == 2) { m_pixelSize.x = splitString[0].toDouble(); m_pixelSize.y = splitString[1].toDouble(); } } else { if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "No pixel size found" << std::endl; // result = false; } } if(ecef_platform_position) { std::vector<ossimString> splitString; ossimString tempString(ecef_platform_position); tempString.split(splitString, ossimString(" ")); if(splitString.size() > 2) { m_ecefPlatformPosition = ossimEcefPoint(splitString[0].toDouble(), splitString[1].toDouble(), splitString[2].toDouble()); } } else if(latlonh_platform_position) { std::vector<ossimString> splitString; ossimString tempString(latlonh_platform_position); tempString.split(splitString, ossimString(" ")); std::string datumString; double lat=0.0, lon=0.0, h=0.0; if(splitString.size() > 2) { lat = splitString[0].toDouble(); lon = splitString[1].toDouble(); h = splitString[2].toDouble(); } m_ecefPlatformPosition = ossimGpt(lat,lon,h); } if(focalLength) { m_focalLength = ossimString(focalLength).toDouble(); } else { if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "No focal length found" << std::endl; result = false; } } if(fov) { m_fov = ossimString(fov).toDouble(); } else { if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "No field of view found" << std::endl; result = false; } } theRefGndPt = m_ecefPlatformPosition; if(m_lensDistortion.valid()&&cx&&cy&&fx&&fy) { m_focalX = ossimString(fx).toDouble(); m_focalY = ossimString(fy).toDouble(); // our lens distorion assume center point. So // lets shift to center and then set calibrated relative to // image center. We will then normalize. // ossimDpt focal(m_focalX,m_focalY); m_norm = focal.length()*0.5; m_calibratedCenter = ossimDpt(ossimString(cx).toDouble(), ossimString(cy).toDouble()); // m_principalPoint = m_calibratedCenter-theImageClipRect.midPoint(); // m_principalPoint.x /= m_norm; // m_principalPoint.y /= m_norm; // lets initialize the root to be about one pixel norm along the diagonal // and the convergence will be approximately 100th of a pixel. // double temp = m_norm; if(temp < FLT_EPSILON) temp = 1.0; else temp = 1.0/temp; m_lensDistortion->setCenter(m_principalPoint); m_lensDistortion->setDxDy(ossimDpt(temp,temp)); m_lensDistortion->setConvergenceThreshold(temp*0.001); } else { m_lensDistortion = 0; } updateModel(); } try { //--- // This will set theGSD and theMeanGSD. Method throws // ossimException. //--- computeGsd(); } catch (const ossimException& e) { ossimNotify(ossimNotifyLevel_WARN) << "ossimSpectraboticsRedEdgeModel::loadState Caught Exception:\n" << e.what() << std::endl; } // std::cout << "METERS PER PIXEL : " << getMetersPerPixel() << std::endl; if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << std::setprecision(15) << std::endl; ossimNotify(ossimNotifyLevel_DEBUG) << "roll: " << m_roll << std::endl << "pitch: " << m_pitch << std::endl << "heading: " << m_heading << std::endl << "platform: " << m_ecefPlatformPosition << std::endl << "latlon Platform: " << ossimGpt(m_ecefPlatformPosition) << std::endl << "focal len: " << m_focalLength << std::endl << "FOV : " << m_fov << std::endl << "principal: " << m_principalPoint << std::endl << "Ground: " << ossimGpt(m_ecefPlatformPosition) << std::endl; } // ossimGpt wpt; // ossimDpt dpt(100,100); // lineSampleToWorld(dpt, wpt); // std::cout << "dpt: " << dpt << "\n" // << "wpt: " << wpt << "\n"; // worldToLineSample(wpt,dpt); // std::cout << "dpt: " << dpt << "\n" // << "wpt: " << wpt << "\n"; return result; }
//***************************************************************************** // METHOD: ossimRpcModel::loadState() // // Restores the model's state from the KWL. This KWL also serves as a // geometry file. // //***************************************************************************** bool ossimRpcModel::loadState(const ossimKeywordlist& kwl, const char* prefix) { if (traceExec()) { ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimRpcModel::loadState(): entering..." << std::endl; } const char* value; const char* keyword; //*** // Pass on to the base-class for parsing first: //*** bool success = ossimSensorModel::loadState(kwl, prefix); if (!success) { theErrorStatus++; if (traceExec()) { ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimRpcModel::loadState(): returning with error..." << std::endl; } return false; } //--- // Continue parsing for local members: //--- value = kwl.find(prefix, BIAS_ERROR_KW); if (value) { theBiasError = ossimString(value).toDouble(); } value = kwl.find(prefix, RAND_ERROR_KW); if (value) { theRandError = ossimString(value).toDouble(); } keyword = POLY_TYPE_KW; value = kwl.find(prefix, keyword); if (!value) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimRpcModel::loadState(): Error encountered parsing the following required keyword: " << "<" << keyword << ">. Check the keywordlist for proper syntax." << std::endl; return false; } thePolyType = (PolynomialType) value[0]; keyword = LINE_SCALE_KW; value = kwl.find(prefix, keyword); if (!value) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimRpcModel::loadState(): Error encountered parsing the following required keyword: " << "<" << keyword << ">. Check the keywordlist for proper syntax." << std::endl; return false; } theLineScale = atof(value); keyword = SAMP_SCALE_KW; value = kwl.find(prefix, keyword); if (!value) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimRpcModel::loadState(): Error encountered parsing the following required keyword: " << "<" << keyword << ">. Check the keywordlist for proper syntax." << std::endl; return false; } theSampScale = atof(value); keyword = LAT_SCALE_KW; value = kwl.find(prefix, keyword); if (!value) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimRpcModel::loadState(): Error encountered parsing the following required keyword: " << "<" << keyword << ">. Check the keywordlist for proper syntax." << std::endl; return false; } theLatScale = atof(value); keyword = LON_SCALE_KW; value = kwl.find(prefix, keyword); if (!value) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimRpcModel::loadState(): Error encountered parsing the following required keyword: " << "<" << keyword << ">. Check the keywordlist for proper syntax." << std::endl; return false; } theLonScale = atof(value); keyword = HGT_SCALE_KW; value = kwl.find(prefix, keyword); if (!value) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimRpcModel::loadState(): Error encountered parsing the following required keyword: " << "<" << keyword << ">. Check the keywordlist for proper syntax." << std::endl; return false; } theHgtScale = atof(value); keyword = LINE_OFFSET_KW; value = kwl.find(prefix, keyword); if (!value) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimRpcModel::loadState(): Error encountered parsing the following required keyword: " << "<" << keyword << ">. Check the keywordlist for proper syntax." << std::endl; return false; } theLineOffset = atof(value); keyword = SAMP_OFFSET_KW; value = kwl.find(prefix, keyword); if (!value) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimRpcModel::loadState(): Error encountered parsing the following required keyword: " << "<" << keyword << ">. Check the keywordlist for proper syntax." << std::endl; return false; } theSampOffset = atof(value); keyword = LAT_OFFSET_KW; value = kwl.find(prefix, keyword); if (!value) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimRpcModel::loadState(): Error encountered parsing the following required keyword: " << "<" << keyword << ">. Check the keywordlist for proper syntax." << std::endl; return false; } theLatOffset = atof(value); keyword = LON_OFFSET_KW; value = kwl.find(prefix, keyword); if (!value) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimRpcModel::loadState(): Error encountered parsing the following required keyword: " << "<" << keyword << ">. Check the keywordlist for proper syntax." << std::endl; return false; } theLonOffset = atof(value); keyword = HGT_OFFSET_KW; value = kwl.find(prefix, keyword); if (!value) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimRpcModel::loadState(): Error encountered parsing the following required keyword: " << "<" << keyword << ">. Check the keywordlist for proper syntax." << std::endl; return false; } theHgtOffset = atof(value); for (int i=0; i<NUM_COEFFS; i++) { ossimString keyword; ostringstream os; os << setw(2) << setfill('0') << right << i; keyword = LINE_NUM_COEF_KW; keyword += os.str(); value = kwl.find(prefix, keyword.c_str()); if (!value) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimRpcModel::loadState(): Error encountered parsing the following required keyword: " << "<" << keyword << ">. Check the keywordlist for proper syntax." << std::endl; return false; } theLineNumCoef[i] = atof(value); keyword = LINE_DEN_COEF_KW; keyword += os.str(); value = kwl.find(prefix, keyword.c_str()); if (!value) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimRpcModel::loadState(): Error encountered parsing the following required keyword: " << "<" << keyword << ">. Check the keywordlist for proper syntax." << std::endl; return false; } theLineDenCoef[i] = atof(value); keyword = SAMP_NUM_COEF_KW; keyword += os.str(); value = kwl.find(prefix, keyword.c_str()); if (!value) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimRpcModel::loadState(): Error encountered parsing the following required keyword: " << "<" << keyword << ">. Check the keywordlist for proper syntax." << std::endl; return false; } theSampNumCoef[i] = atof(value); keyword = SAMP_DEN_COEF_KW; keyword += os.str(); value = kwl.find(prefix, keyword.c_str()); if (!value) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimRpcModel::loadState(): Error encountered parsing the following required keyword: " << "<" << keyword << ">. Check the keywordlist for proper syntax." << std::endl; return false; } theSampDenCoef[i] = atof(value); } //*** // Initialize other data members given quantities read in KWL: //*** theCosMapRot = 1.0; theSinMapRot = 0.0; updateModel(); if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimRpcModel::loadState(): returning..." << std::endl; return true; }
void ossimQtVceCanvasWidget::addAllObjects(const ossimKeywordlist& kwl, const QPoint& location, const char* prefix) { unselectItems(); QPoint locationPoint = location; ossimString copyPrefix = prefix; std::vector<QCanvasItem*> newItemList; ossimString regExpression = ossimString("^(") + copyPrefix + "object[0-9]+.)"; vector<ossimString> keys = kwl.getSubstringKeyList( regExpression ); long numberOfObjets = keys.size();//kwl.getNumberOfSubstringKeys(regExpression); int offset = (copyPrefix+"object").size(); int idx = 0; std::vector<int> theNumberList(numberOfObjets); for(idx = 0; idx < (int)theNumberList.size();++idx) { ossimString numberStr(keys[idx].begin() + offset, keys[idx].end()); theNumberList[idx] = numberStr.toInt(); } std::sort(theNumberList.begin(), theNumberList.end()); for(idx=0;idx < (int)theNumberList.size();++idx) { ossimString newPrefix = copyPrefix; newPrefix += ossimString("object"); newPrefix += ossimString::toString(theNumberList[idx]); newPrefix += ossimString("."); ossimString objType = kwl.find(newPrefix, ossimKeywordNames::TYPE_KW); QCanvasItem* item = NULL; if(objType == "ossimQtImageWindow") { item = new ossimQtVceImageDisplayObject(canvas(), this); item->setX(locationPoint.x()); item->setY(locationPoint.y()); item->show(); emit itemAdded(item); } else if(objType == "ossimImageHandler") { QStringList filenames = QFileDialog::getOpenFileNames("Images (*.adf *.ccf *.dem *.DEM *.dt1 *.dt0 *.dt2 *.hdr *.hgt *.jpg *.jpeg *.img *.doqq *.fst *.FST *.nitf *.NTF *.ntf *.ras *.sid *.tif *.tiff *.toc *.TOC);;Vectors(*.shp dht *.tab);;All Files(*)", QString::null, this, "open file dialog", "Choose a file to open"); QStringList::Iterator it; for(it = filenames.begin(); it != filenames.end(); ++it) { std::vector<QCanvasItem*> newItems; openImageFile((*it).ascii(), locationPoint, newItems); if(newItems.size()) { // QRect bounds = newItems[newItems.size()-1]->boundingRect(); // locationPoint.setY(locationPoint.y() + bounds.height() + 10); newItemList.insert(newItemList.end(), newItems.begin(), newItems.end()); } } // we will make sure that we don't adjust the location point any further // item = NULL; } else { ossimObject* object = ossimObjectFactoryRegistry::instance()->createObject(objType); if(object) { item = addObject(object, locationPoint); } } if(item) { newItemList.push_back(item); QRect bounds = item->boundingRect(); locationPoint.setY(locationPoint.y() + bounds.height() + 10); emit itemAdded(item); } } if(newItemList.size() > 0) { for(idx = 0; idx < (int)newItemList.size(); ++idx) { newItemList[idx]->setSelected(true); theSelectedItems.push_back(newItemList[idx]); emit itemSelected(newItemList[idx]); } } }
/** * Method to the load (recreate) the state of an object from a keyword * list. Return true if ok or false on error. */ bool ossimElevManager::loadState(const ossimKeywordlist& kwl, const char* prefix) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimElevManager::loadState: Entered..." << std::endl; } if(!ossimElevSource::loadState(kwl, prefix)) { return false; } ossimString copyPrefix(prefix); ossimString elevationOffset = kwl.find(copyPrefix, "elevation_offset"); ossimString defaultHeightAboveEllipsoid = kwl.find(copyPrefix, "default_height_above_ellipsoid"); ossimString useGeoidIfNull = kwl.find(copyPrefix, "use_geoid_if_null"); ossimString elevRndRbnSize = kwl.find(copyPrefix, "threads"); if(!elevationOffset.empty()) { m_elevationOffset = elevationOffset.toDouble(); } if(!defaultHeightAboveEllipsoid.empty()) { m_defaultHeightAboveEllipsoid = defaultHeightAboveEllipsoid.toDouble(); } if(!useGeoidIfNull.empty()) { m_useGeoidIfNullFlag = useGeoidIfNull.toBool(); } ossim_uint32 numThreads = 1; if(!elevRndRbnSize.empty()) { if (elevRndRbnSize.contains("yes") || elevRndRbnSize.contains("true")) numThreads = ossim::getNumberOfThreads(); else if (elevRndRbnSize.contains("no") || elevRndRbnSize.contains("false")) numThreads = 1; else { numThreads = elevRndRbnSize.toUInt32(); numThreads = numThreads > 0 ? numThreads : 1; } } setRoundRobinMaxSize(numThreads); ossimString regExpression = ossimString("^(") + copyPrefix + "elevation_source[0-9]+.)"; vector<ossimString> keys = kwl.getSubstringKeyList( regExpression ); long numberOfSources = (long)keys.size(); ossim_uint32 offset = (ossim_uint32)(copyPrefix+"elevation_source").size(); ossim_uint32 idx = 0; std::vector<int> theNumberList(numberOfSources); for(idx = 0; idx < theNumberList.size();++idx) { ossimString numberStr(keys[idx].begin() + offset, keys[idx].end()); theNumberList[idx] = numberStr.toInt(); } std::sort(theNumberList.begin(), theNumberList.end()); for(idx=0;idx < theNumberList.size();++idx) { ossimString newPrefix = copyPrefix; newPrefix += ossimString("elevation_source"); newPrefix += ossimString::toString(theNumberList[idx]); if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimElevManager::loadState:" << "\nLooking for key: " << newPrefix << std::endl; } //--- // Check for enabled key first. Default, if not found is true for // legacy compatibility. //--- bool enabled = true; std::string key = newPrefix.string(); key += "."; key += ossimKeywordNames::ENABLED_KW; std::string value = kwl.findKey( key ); if ( value.size() ) { enabled = ossimString(value).toBool(); } if ( enabled ) { // first check if new way is supported ossimRefPtr<ossimElevationDatabase> database = ossimElevationDatabaseRegistry::instance()->createDatabase(kwl, newPrefix+"."); if(database.valid()) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimElevManager::loadState:" << "\nadding elevation database: " << database->getClassName() << ": " << database->getConnectionString() << std::endl; } addDatabase(database.get()); } else { // if not new elevation load verify the old way by // looking at the filename // ossimString fileKey = newPrefix; fileKey += "."; fileKey += ossimKeywordNames::FILENAME_KW; ossimString lookup = kwl.find(prefix, fileKey.c_str()); if (!lookup.empty()) { loadElevationPath(ossimFilename(lookup)); } // end if lookup } } } // end for loop return true; }
bool ossimAtCorrRemapper::loadState(const ossimKeywordlist& kwl, const char* prefix) { static const char MODULE[] = "ossimAtCorrRemapper::loadState()"; if (traceDebug()) CLOG << "entering..." << endl; if (!theTile || !theSurfaceReflectance) { cerr << MODULE << " ERROR:" << "Not initialized..." << endl; return false; } ossim_uint32 bands = theTile->getNumberOfBands(); // Clear out the old values. theMinPixelValue.clear(); theMaxPixelValue.clear(); theXaArray.clear(); theXbArray.clear(); theXcArray.clear(); theBiasArray.clear(); theGainArray.clear(); theCalCoefArray.clear(); theBandWidthArray.clear(); // Now resize them. // Start with arbitrary big number. theMinPixelValue.resize(bands, 1.0); // Start with arbitrary small number. theMaxPixelValue.resize(bands, 0.0); theXaArray.resize(bands, 1.0); theXbArray.resize(bands, 1.0); theXcArray.resize(bands, 1.0); theBiasArray.resize(bands, 0.0); theGainArray.resize(bands, 1.0); theCalCoefArray.resize(bands); theBandWidthArray.resize(bands); for(ossim_uint32 band = 0; band < bands; ++band) { const char* lookup = NULL; ossimString band_string = ".band"; band_string += ossimString::toString(band+1); ossimString kw = AT_CORR_XA_KW; kw += band_string; lookup = kwl.find(prefix, kw.c_str()); if (lookup) { theXaArray[band] = atof(lookup); } else { if (traceDebug()) { CLOG << "DEBUG:" << "\nlookup failed for keyword: " << kw.c_str() << endl; } } kw = AT_CORR_XB_KW; kw += band_string; lookup = kwl.find(prefix, kw.c_str()); if (lookup) { theXbArray[band] = atof(lookup); } else { if (traceDebug()) { CLOG << "DEBUG:" << "\nlookup failed for keyword: " << kw.c_str() << endl; } } kw = AT_CORR_XC_KW; kw += band_string; lookup = kwl.find(prefix, kw.c_str()); if (lookup) { theXcArray[band] = atof(lookup); } else { if (traceDebug()) { CLOG << "DEBUG:" << "\nlookup failed for keyword: " << kw.c_str() << endl; } } if(theSensorType == "ls7ms") { kw = AT_CORR_BIAS_KW; kw += band_string; lookup = kwl.find(prefix, kw.c_str()); if (lookup) { theBiasArray[band] = atof(lookup); } else { if (traceDebug()) { CLOG << "DEBUG:" << "\nlookup failed for keyword: " << kw.c_str() << endl; } } kw = AT_CORR_GAIN_KW; kw += band_string; lookup = kwl.find(prefix, kw.c_str()); if (lookup) { theGainArray[band] = atof(lookup); } else { if (traceDebug()) { CLOG << "DEBUG:" << "\nlookup failed for keyword: " << kw.c_str() << endl; } } } if(theSensorType == "qbms") { kw = AT_CORR_CALCOEF_KW; kw += band_string; lookup = kwl.find(prefix, kw.c_str()); if (lookup) { theCalCoefArray[band] = atof(lookup); } else { if (traceDebug()) { CLOG << "DEBUG:" << "\nlookup failed for keyword: " << kw.c_str() << endl; } } kw = AT_CORR_BANDWIDTH_KW; kw += band_string; lookup = kwl.find(prefix, kw.c_str()); if (lookup) { theBandWidthArray[band] = atof(lookup); } else { if (traceDebug()) { CLOG << "DEBUG:" << "\nlookup failed for keyword: " << kw.c_str() << endl; } } } if(theSensorType == "ikms") { kw = AT_CORR_CALCOEF_KW; kw += band_string; lookup = kwl.find(prefix, kw.c_str()); if (lookup) { theCalCoefArray[band] = atof(lookup); } else { if (traceDebug()) { CLOG << "DEBUG:" << "\nlookup failed for keyword: " << kw.c_str() << endl; } } kw = AT_CORR_BANDWIDTH_KW; kw += band_string; lookup = kwl.find(prefix, kw.c_str()); if (lookup) { theBandWidthArray[band] = atof(lookup); } else { if (traceDebug()) { CLOG << "DEBUG:" << "\nlookup failed for keyword: " << kw.c_str() << endl; } } } } verifyEnabled(); if (theEnableFlag) { //*** // Call the base class to pick up the enable flag. Note that this // can override the state set from verifyEnabled() method. //*** ossimString pref; if (prefix) pref += prefix; pref += "atmospheric_correction."; } if (traceDebug()) { CLOG << "DEBUG:" << *this << "returning..." << endl; } return true; }
//******************************************************************* // Public Method: //******************************************************************* ossimString ossimLookUpTable::getEntryString(const ossimKeywordlist& kwl, const char* prefix) const { ossimString s = kwl.find(prefix, getKeyword()); return s; }
bool ossimPpjFrameSensor::loadState(const ossimKeywordlist& kwl, const char* prefix) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimPpjFrameSensor::loadState DEBUG:" << std::endl; } theGSD.makeNan(); theRefImgPt.makeNan(); ossimSensorModel::loadState(kwl, prefix); if(getNumberOfAdjustableParameters() < 1) { initAdjustableParameters(); } ossimString principal_point = kwl.find(prefix, "principal_point"); ossimString focal_length_x = kwl.find(prefix, "focal_length_x"); ossimString focal_length_y = kwl.find(prefix, "focal_length_y"); ossimString number_samples = kwl.find(prefix, "number_samples"); ossimString number_lines = kwl.find(prefix, "number_lines"); ossimString ecf_to_cam_row1 = kwl.find(prefix, "ecf_to_cam_row1"); ossimString ecf_to_cam_row2 = kwl.find(prefix, "ecf_to_cam_row2"); ossimString ecf_to_cam_row3 = kwl.find(prefix, "ecf_to_cam_row3"); ossimString platform_position = kwl.find(prefix, "ecef_camera_position"); ossimString averageProjectedHeight = kwl.find(prefix, "average_projected_height"); // ossimString roll; // ossimString pitch; // ossimString yaw; // m_roll = 0; // m_pitch = 0; // m_yaw = 0; // roll = kwl.find(prefix, "roll"); // pitch = kwl.find(prefix, "pitch"); // yaw = kwl.find(prefix, "yaw"); bool result = (!principal_point.empty()&& !focal_length_x.empty()&& !platform_position.empty()&& !ecf_to_cam_row1.empty()&& !ecf_to_cam_row2.empty()&& !ecf_to_cam_row3.empty()); if(!averageProjectedHeight.empty()) { m_averageProjectedHeight = averageProjectedHeight.toDouble(); } if(!number_samples.empty()) { theImageSize = ossimIpt(number_samples.toDouble(), number_lines.toDouble()); theRefImgPt = ossimDpt(theImageSize.x*.5, theImageSize.y*.5); theImageClipRect = ossimDrect(0,0,theImageSize.x-1, theImageSize.y-1); } if(theImageClipRect.hasNans()) { theImageClipRect = ossimDrect(0,0,theImageSize.x-1,theImageSize.y-1); } if(theRefImgPt.hasNans()) { theRefImgPt = theImageClipRect.midPoint(); } if(!focal_length_x.empty()) { m_focalLengthX = focal_length_x.toDouble(); m_focalLength = m_focalLengthX; } if(!focal_length_y.empty()) { m_focalLengthY = focal_length_y.toDouble(); } std::vector<ossimString> row; if(!ecf_to_cam_row1.empty()) { row = ecf_to_cam_row1.explode(" "); for (int i=0; i<3; ++i) m_ecef2Cam[0][i] = row[i].toDouble(); row = ecf_to_cam_row2.explode(" "); for (int i=0; i<3; ++i) m_ecef2Cam[1][i] = row[i].toDouble(); row = ecf_to_cam_row3.explode(" "); for (int i=0; i<3; ++i) m_ecef2Cam[2][i] = row[i].toDouble(); m_ecef2CamInverse = m_ecef2Cam.t(); } // if(!roll.empty()) // { // m_roll = roll.toDouble(); // } // if(!pitch.empty()) // { // m_pitch = pitch.toDouble(); // } // if(!yaw.empty()) // { // m_yaw = yaw.toDouble(); // } if(!principal_point.empty()) { m_principalPoint.toPoint(principal_point); } if(!platform_position.empty()) { m_ecefCameraPosition.toPoint(platform_position); m_cameraPositionEllipsoid = ossimGpt(m_ecefCameraPosition); } updateModel(); if(theGSD.isNan()) { try { computeGsd(); } catch (const ossimException& e) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimPpjFrameSensor::loadState Caught Exception:\n" << e.what() << std::endl; } } } if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimPpjFrameSensor::loadState complete..." << std::endl; } return result; }
bool ossimErsSarModel::InitRefPoint(const ossimKeywordlist &kwl, const char *prefix) { const char* sc_lin_str = kwl.find(prefix, "sc_lin"); double sc_lin = atof(sc_lin_str); const char* sc_pix_str = kwl.find(prefix, "sc_pix"); double sc_pix = atof(sc_pix_str); const char* inp_sctim_str = kwl.find(prefix, "inp_sctim"); const char* rng_gate_str = kwl.find(prefix, "zero_dop_range_time_f_pixel"); double rng_gate = atof(rng_gate_str); if (_refPoint == NULL) { _refPoint = new RefPoint(); } _refPoint->set_pix_col(sc_pix); _refPoint->set_pix_line(sc_lin); char year_str[5]; for (int i = 0; i < 4; i++) { year_str[i] = inp_sctim_str[i]; } year_str[4] = '\0'; char month_str[3]; for (int i = 4; i < 6; i++) { month_str[i-4] = inp_sctim_str[i]; } month_str[2] = '\0'; char day_str[3]; for (int i = 6; i < 8; i++) { day_str[i-6] = inp_sctim_str[i]; } day_str[2] = '\0'; char hour_str[3]; for (int i = 8; i < 10; i++) { hour_str[i-8] = inp_sctim_str[i]; } hour_str[2] = '\0'; char min_str[3]; for (int i = 10; i < 12; i++) { min_str[i-10] = inp_sctim_str[i]; } min_str[2] = '\0'; char sec_str[3]; for (int i = 12; i < 14; i++) { sec_str[i-12] = inp_sctim_str[i]; } sec_str[2] = '\0'; char mili_str[4]; for (int i = 14; i < 17; i++) { mili_str[i-14] = inp_sctim_str[i]; } mili_str[3] = '\0'; int year = atoi(year_str); int month = atoi(month_str); int day = atoi(day_str); int hour = atoi(hour_str); int min = atoi(min_str); int sec = atoi(sec_str); double mili = atof(mili_str); CivilDateTime date(year, month, day, hour * 3600 + min * 60 + sec, mili / 1000.0); if (_platformPosition != NULL) { Ephemeris * ephemeris = _platformPosition->Interpolate((JSDDateTime)date); if (ephemeris == NULL) return false ; _refPoint->set_ephemeris(ephemeris); delete ephemeris; } else { return false; } double c = 2.99792458e+8; double distance = (rng_gate * 1e-3 + ((double)sc_pix) * _sensor->get_nRangeLook() / _sensor->get_sf()) * (c / 2.0); _refPoint->set_distance(distance); // in order to use ossimSensorModel::lineSampleToWorld const char* nbCol_str = kwl.find(prefix, "num_pix"); const char* nbLin_str = kwl.find(prefix, "num_lines"); theImageSize.x = atoi(nbCol_str); theImageSize.y = atoi(nbLin_str); theImageClipRect = ossimDrect(0, 0, theImageSize.x - 1, theImageSize.y - 1); // Ground Control Points extracted from the model : corner points std::list<ossimGpt> groundGcpCoordinates ; std::list<ossimDpt> imageGcpCoordinates ; // first line first pix const char* lon_str = kwl.find("first_line_first_pixel_lon"); double lon = atof(lon_str); const char* lat_str = kwl.find("first_line_first_pixel_lat"); double lat = atof(lat_str); if (lon > 180.0) lon -= 360.0; ossimDpt imageGCP1(0, 0); ossimGpt groundGCP1(lat, lon, 0.0); groundGcpCoordinates.push_back(groundGCP1) ; imageGcpCoordinates.push_back(imageGCP1) ; // first line last pix lon_str = kwl.find("first_line_last_pixel_lon"); lon = atof(lon_str); lat_str = kwl.find("first_line_last_pixel_lat"); lat = atof(lat_str); if (lon > 180.0) lon -= 360.0; ossimDpt imageGCP2(theImageSize.x - 1, 0); ossimGpt groundGCP2(lat, lon, 0.0); groundGcpCoordinates.push_back(groundGCP2) ; imageGcpCoordinates.push_back(imageGCP2) ; // last line last pix lon_str = kwl.find("last_line_last_pixel_lon"); lon = atof(lon_str); lat_str = kwl.find("last_line_last_pixel_lat"); lat = atof(lat_str); if (lon > 180.0) lon -= 360.0; ossimDpt imageGCP3(theImageSize.x - 1, theImageSize.y - 1); ossimGpt groundGCP3(lat, lon, 0.0); groundGcpCoordinates.push_back(groundGCP3) ; imageGcpCoordinates.push_back(imageGCP3) ; // last line first pix lon_str = kwl.find("last_line_first_pixel_lon"); lon = atof(lon_str); lat_str = kwl.find("last_line_first_pixel_lat"); lat = atof(lat_str); if (lon > 180.0) lon -= 360.0; ossimDpt imageGCP4(0, theImageSize.y - 1); ossimGpt groundGCP4(lat, lon, 0.0); groundGcpCoordinates.push_back(groundGCP4) ; imageGcpCoordinates.push_back(imageGCP4) ; // Default optimization optimizeModel(groundGcpCoordinates, imageGcpCoordinates) ; return true; }
bool ossimErsSarModel::InitPlatformPosition(const ossimKeywordlist &kwl, const char *prefix) { // const double PI = 3.14159265358979323846 ; CivilDateTime ref_civil_date; /* * Ephemerisis reference date retrieval */ const char* eph_year_str = kwl.find(prefix, "eph_year"); int eph_year = atoi(eph_year_str); const char* eph_month_str = kwl.find(prefix, "eph_month"); int eph_month = atoi(eph_month_str); const char* eph_day_str = kwl.find(prefix, "eph_day"); int eph_day = atoi(eph_day_str); const char* eph_sec_str = kwl.find(prefix, "eph_sec"); double eph_sec = atof(eph_sec_str); ref_civil_date.set_year(eph_year); ref_civil_date.set_month(eph_month); ref_civil_date.set_day(eph_day); ref_civil_date.set_second((int)eph_sec); ref_civil_date.set_decimal(eph_sec - (double)((int)eph_sec)); JSDDateTime ref_jsd_date(ref_civil_date); /* * Ephemerisis time interval retrieval */ const char* eph_int_str = kwl.find(prefix, "eph_int"); double eph_int = atof(eph_int_str); /* * Ephemerisis number retrieval */ const char* neph_str = kwl.find(prefix, "neph"); int neph = atoi(neph_str); Ephemeris** ephemeris = new Ephemeris*[neph]; /* * Ephemerisis retrieval */ for (int i = 0; i < neph; i++) { double pos[3]; double vit[3]; char name[64]; sprintf(name, "eph%i_posX", i); const char* px_str = kwl.find(prefix, name); pos[0] = atof(px_str); sprintf(name, "eph%i_posY", i); const char* py_str = kwl.find(prefix, name); pos[1] = atof(py_str); sprintf(name, "eph%i_posZ", i); const char* pz_str = kwl.find(prefix, name); pos[2] = atof(pz_str); sprintf(name, "eph%i_velX", i); const char* vx_str = kwl.find(prefix, name); vit[0] = atof(vx_str); sprintf(name, "eph%i_velY", i); const char* vy_str = kwl.find(prefix, name); vit[1] = atof(vy_str); sprintf(name, "eph%i_velZ", i); const char* vz_str = kwl.find(prefix, name); vit[2] = atof(vz_str); /* * Ephemerisis date */ JSDDateTime date(ref_jsd_date); date.set_second(date.get_second() + i * eph_int); date.NormDate(); GeographicEphemeris* eph = new GeographicEphemeris(date, pos, vit); ephemeris[i] = eph; } /* * Antenna position interpolator creation */ if (_platformPosition != NULL) { delete _platformPosition; } _platformPosition = new PlatformPosition(ephemeris, neph); /* * Free of memory used by the ephemerisis list */ for (int i = 0; i < neph; i++) { delete ephemeris[i]; } delete[] ephemeris; return true; }
//***************************************************************************** // METHOD: ossimRpcProjection::loadState() // // Restores the model's state from the KWL. This KWL also serves as a // geometry file. // //***************************************************************************** bool ossimRpcProjection::loadState(const ossimKeywordlist& kwl, const char* prefix) { if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimRpcProjection::loadState(): entering..." << std::endl; const char* value; const char* keyword; //*** // Pass on to the base-class for parsing first: //*** bool success = ossimProjection::loadState(kwl, prefix); if (!success) { theErrorStatus++; if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimRpcProjection::loadState(): returning with error..." << std::endl; return false; } //*** // Continue parsing for local members: //*** keyword = POLY_TYPE_KW; value = kwl.find(prefix, keyword); if (!value) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimRpcProjection::loadState(): Error encountered parsing the following required keyword: " << "<" << keyword << ">. Check the keywordlist for proper syntax." << std::endl; return false; } thePolyType = (PolynomialType) value[0]; keyword = LINE_SCALE_KW; value = kwl.find(prefix, keyword); if (!value) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimRpcProjection::loadState(): Error encountered parsing the following required keyword: " << "<" << keyword << ">. Check the keywordlist for proper syntax." << std::endl; return false; } theLineScale = ossimString(value).toDouble(); keyword = SAMP_SCALE_KW; value = kwl.find(prefix, keyword); if (!value) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimRpcProjection::loadState(): Error encountered parsing the following required keyword: " << "<" << keyword << ">. Check the keywordlist for proper syntax." << std::endl; return false; } theSampScale = ossimString(value).toDouble(); keyword = LAT_SCALE_KW; value = kwl.find(prefix, keyword); if (!value) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimRpcProjection::loadState(): Error encountered parsing the following required keyword: " << "<" << keyword << ">. Check the keywordlist for proper syntax." << std::endl; return false; } theLatScale = ossimString(value).toDouble(); keyword = LON_SCALE_KW; value = kwl.find(prefix, keyword); if (!value) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimRpcProjection::loadState(): Error encountered parsing the following required keyword: " << "<" << keyword << ">. Check the keywordlist for proper syntax." << std::endl; return false; } theLonScale = ossimString(value).toDouble(); keyword = HGT_SCALE_KW; value = kwl.find(prefix, keyword); if (!value) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimRpcProjection::loadState(): Error encountered parsing the following required keyword: " << "<" << keyword << ">. Check the keywordlist for proper syntax." << std::endl; return false; } theHgtScale = ossimString(value).toDouble(); keyword = LINE_OFFSET_KW; value = kwl.find(prefix, keyword); if (!value) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimRpcProjection::loadState(): Error encountered parsing the following required keyword: " << "<" << keyword << ">. Check the keywordlist for proper syntax." << std::endl; return false; } theLineOffset = ossimString(value).toDouble(); keyword = SAMP_OFFSET_KW; value = kwl.find(prefix, keyword); if (!value) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimRpcProjection::loadState(): Error encountered parsing the following required keyword: " << "<" << keyword << ">. Check the keywordlist for proper syntax." << std::endl; return false; } theSampOffset = ossimString(value).toDouble(); keyword = LAT_OFFSET_KW; value = kwl.find(prefix, keyword); if (!value) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimRpcProjection::loadState(): Error encountered parsing the following required keyword: " << "<" << keyword << ">. Check the keywordlist for proper syntax." << std::endl; return false; } theLatOffset = ossimString(value).toDouble(); keyword = LON_OFFSET_KW; value = kwl.find(prefix, keyword); if (!value) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimRpcProjection::loadState(): Error encountered parsing the following required keyword: " << "<" << keyword << ">. Check the keywordlist for proper syntax." << std::endl; return false; } theLonOffset = ossimString(value).toDouble(); keyword = HGT_OFFSET_KW; value = kwl.find(prefix, keyword); if (!value) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimRpcProjection::loadState(): Error encountered parsing the following required keyword: " << "<" << keyword << ">. Check the keywordlist for proper syntax." << std::endl; return false; } theHgtOffset = ossimString(value).toDouble(); for (int i=0; i<NUM_COEFFS; i++) { value = kwl.find(prefix, (LINE_NUM_COEF_KW+ossimString::toString(i)).c_str()); if (!value) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimRpcProjection::loadState(): Error encountered parsing the following required keyword: " << "<" << keyword << ">. Check the keywordlist for proper syntax." << std::endl; return false; } theLineNumCoef[i] = ossimString(value).toDouble(); value = kwl.find(prefix, (LINE_DEN_COEF_KW+ossimString::toString(i)).c_str()); if (!value) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimRpcProjection::loadState(): Error encountered parsing the following required keyword: " << "<" << keyword << ">. Check the keywordlist for proper syntax." << std::endl; return false; } theLineDenCoef[i] = ossimString(value).toDouble(); value = kwl.find(prefix, (SAMP_NUM_COEF_KW+ossimString::toString(i)).c_str()); if (!value) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimRpcProjection::loadState(): Error encountered parsing the following required keyword: " << "<" << keyword << ">. Check the keywordlist for proper syntax." << std::endl; return false; } theSampNumCoef[i] = ossimString(value).toDouble(); value = kwl.find(prefix, (SAMP_DEN_COEF_KW+ossimString::toString(i)).c_str()); if (!value) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimRpcProjection::loadState(): Error encountered parsing the following required keyword: " << "<" << keyword << ">. Check the keywordlist for proper syntax." << std::endl; return false; } theSampDenCoef[i] = ossimString(value).toDouble(); } loadAdjustments(kwl, prefix); if(getNumberOfAdjustableParameters() < 1) { initAdjustableParameters(); } if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimRpcProjection::loadState(): returning..." << std::endl; return true; }
bool Ephemeris::loadState(const ossimKeywordlist& kwl, const char* prefix) { static const char MODULE[] = "Ephemeris::loadState"; bool result = true; std::string pfx; if (prefix) { pfx = prefix; } pfx += "ephemeris."; const char* lookup = 0; ossimString s; double d; lookup = kwl.find(pfx.c_str(), DATE_JULIAN_KW); if (lookup) { s = lookup; d = s.toDouble(); JulianDate jd(d); _date.set_day0hTU(jd); } else { ossimNotify(ossimNotifyLevel_WARN) << MODULE << " Keyword not found: " << DATE_JULIAN_KW << "\n"; result = false; } lookup = kwl.find(pfx.c_str(), DATE_SECOND_KW); if (lookup) { s = lookup; d = s.toDouble(); _date.set_second(d); } else { ossimNotify(ossimNotifyLevel_WARN) << MODULE << " Keyword not found: " << DATE_SECOND_KW << "\n"; result = false; } lookup = kwl.find(pfx.c_str(), DATE_DECIMAL_KW); if (lookup) { s = lookup; d = s.toDouble(); _date.set_decimal(d); } else { ossimNotify(ossimNotifyLevel_WARN) << MODULE << " Keyword not found: " << DATE_DECIMAL_KW << "\n"; result = false; } lookup = kwl.find(pfx.c_str(), POSITION_KW); if (lookup) { std::string ps = lookup; ossimDpt3d pt; pt.toPoint(ps); _position[0] = pt.x; _position[1] = pt.y; _position[2] = pt.z; } else { ossimNotify(ossimNotifyLevel_WARN) << MODULE << " Keyword not found: " << POSITION_KW << "\n"; result = false; } lookup = kwl.find(pfx.c_str(), VELOCITY_KW); if (lookup) { std::string ps = lookup; ossimDpt3d pt; pt.toPoint(ps); _vitesse[0] = pt.x; _vitesse[1] = pt.y; _vitesse[2] = pt.z; } else { ossimNotify(ossimNotifyLevel_WARN) << MODULE << " Keyword not found: " << VELOCITY_KW << "\n"; result = false; } return result; }
bool ossimViewshedUtil::initialize(const ossimKeywordlist& kwl) { // Base class first: if (!ossimUtility::initialize(kwl)) return false; ossimString value; m_demFile = kwl.find("dem_file"); if (m_demFile.empty()) m_demFile = kwl.find(ossimKeywordNames::ELEVATION_CELL_KW); value = kwl.find("fov"); if (!value.empty()) { vector <ossimString> coordstr; value.split(coordstr, ossimString(" ,"), false); if (coordstr.size() == 2) { m_startFov = coordstr[0].toDouble(); m_stopFov = coordstr[1].toDouble(); if (m_startFov < 0) m_startFov += 360.0; } } value = kwl.find("gsd"); if (value.empty()) value = kwl.find(ossimKeywordNames::METERS_PER_PIXEL_KW); if (!value.empty()) m_gsd = value.toDouble(); value = kwl.find("height_of_eye"); if (!value.empty()) m_obsHgtAbvTer = value.toDouble(); m_horizonFile = kwl.find("horizon_file"); m_lutFile = kwl.find("lut_file"); value = kwl.find("observer"); if (!value.empty()) { vector <ossimString> coordstr; value.split(coordstr, ossimString(" ,"), false); if (coordstr.size() == 2) { m_observerGpt.lat = coordstr[0].toDouble(); m_observerGpt.lon = coordstr[1].toDouble(); m_observerGpt.hgt = 0.0; } } value = kwl.find("radius"); if (!value.empty()) m_visRadius = value.toDouble(); value = kwl.find("reticle"); if (!value.empty()) m_reticleSize = value.toInt32(); kwl.getBoolKeywordValue(m_threadBySector, "thread_by_sector"); kwl.getBoolKeywordValue(m_simulation, "simulation"); kwl.getBoolKeywordValue(m_outputSummary, "summary"); value = kwl.find("size"); if (!value.empty()) m_halfWindow = value.toInt32(); value = kwl.find(ossimKeywordNames::THREADS_KW); if (!value.empty()) m_numThreads = value.toInt32(); value = kwl.find("values"); if (!value.empty()) { vector <ossimString> coordstr; value.split(coordstr, ossimString(" ,"), false); if (coordstr.size() == 3) { m_visibleValue = coordstr[0].toUInt8(); m_hiddenValue = coordstr[1].toUInt8(); m_observerValue = coordstr[2].toUInt8(); } } m_filename = kwl.find(ossimKeywordNames::OUTPUT_FILE_KW); if (value.empty()) { ostringstream msg; msg <<"No output file name provided."<<ends; ossimException e (msg.str()); throw e; } // Verify minimum required args were specified: if (m_demFile.empty() && (m_visRadius == 0) && (m_halfWindow == 0)) { ostringstream msg; msg << "ossimViewshedUtil::initialize ERR: Keywordlist is underspecified." << ends; ossimException e (msg.str()); throw e; } return initializeChain(); }
bool ossimGeometricSarSensorModel::loadState(const ossimKeywordlist &kwl, const char *prefix) { static const char MODULE[] = "ossimGeometricSarSensorModel::loadState"; if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entered...\n"; } bool result = true; // Load the base class; if ( ossimSensorModel::loadState(kwl, prefix) == false ) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_WARN) << MODULE << "\nossimSensorModel::loadState failed!\n"; } result = false; } // Load the platform position state. if ( !_platformPosition) { _platformPosition = new PlatformPosition(); } if ( _platformPosition->loadState(kwl, prefix) == false ) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_WARN) << MODULE << "\n_platformPosition->loadState failed!\n"; } result = false; } // Load the sensor position state. if ( !_sensor) { _sensor = new SensorParams(); } if ( _sensor->loadState(kwl, prefix) == false ) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_WARN) << MODULE << "\n_sensor->loadState failed!\n"; } result = false; } // Load the ref point. if ( !_refPoint) { _refPoint = new RefPoint(); } if ( _refPoint->loadState(kwl, prefix) == false ) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_WARN) << MODULE << "\n_refPoint->loadState failed!\n"; } result = false; } const char* lookup = 0; ossimString s; lookup = kwl.find(prefix, PRODUCT_GEOREFERENCED_FLAG_KW); if (lookup) { s = lookup; _isProductGeoreferenced = s.toBool(); } else { if (traceDebug()) { ossimNotify(ossimNotifyLevel_WARN) << MODULE << "\nRequired keyword not found: " << PRODUCT_GEOREFERENCED_FLAG_KW << "\n"; } result = false; } lookup = kwl.find(prefix, OPTIMIZATION_FACTOR_X_KW); if (lookup) { s = lookup; _optimizationFactorX = s.toDouble(); } else { if (traceDebug()) { ossimNotify(ossimNotifyLevel_WARN) << MODULE << "\nRequired keyword not found: " << OPTIMIZATION_FACTOR_X_KW << "\n"; } result = false; } lookup = kwl.find(prefix, OPTIMIZATION_FACTOR_Y_KW); if (lookup) { s = lookup; _optimizationFactorY = s.toDouble(); } else { if (traceDebug()) { ossimNotify(ossimNotifyLevel_WARN) << MODULE << "\nRequired keyword not found: " << OPTIMIZATION_FACTOR_Y_KW << "\n"; } result = false; } lookup = kwl.find(prefix,OPTIMIZATION_BIAS_X_KW); if (lookup) { s = lookup; _optimizationBiasX= s.toDouble(); } else { if (traceDebug()) { ossimNotify(ossimNotifyLevel_WARN) << MODULE << "\nRequired keyword not found: " << OPTIMIZATION_BIAS_X_KW << "\n"; } result = false; } lookup = kwl.find(prefix,OPTIMIZATION_BIAS_Y_KW); if (lookup) { s = lookup; _optimizationBiasY = s.toDouble(); } else { if (traceDebug()) { ossimNotify(ossimNotifyLevel_WARN) << MODULE << "\nRequired keyword not found: " << OPTIMIZATION_BIAS_X_KW << "\n"; } result = false; } // if (result && traceDebug()) // if (result) // { // ossimNotify(ossimNotifyLevel_DEBUG) // << "calling saveState to verify loadState..." << endl; // ossimKeywordlist kwl2; // saveState(kwl2, 0); // ossimNotify(ossimNotifyLevel_DEBUG) // << "saveState result after loadState:" << kwl2 << endl; // } if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " exit status = " << (result?"true":"false\n") << std::endl; } return result; }
bool ossimApplanixUtmModel::loadState(const ossimKeywordlist& kwl, const char* prefix) { if(traceDebug()) { std::cout << "ossimApplanixUtmModel::loadState: ......... entered" << std::endl; } theImageClipRect = ossimDrect(0,0,4076,4091); theRefImgPt = ossimDpt(2046.0, 2038.5); ossimSensorModel::loadState(kwl, prefix); if(getNumberOfAdjustableParameters() < 1) { initAdjustableParameters(); } const char* eo_file = kwl.find(prefix, "eo_file"); const char* eo_id = kwl.find(prefix, "eo_id"); const char* omega = kwl.find(prefix, "omega"); const char* phi = kwl.find(prefix, "phi"); const char* kappa = kwl.find(prefix, "kappa"); const char* bore_sight_tx = kwl.find(prefix, "bore_sight_tx"); const char* bore_sight_ty = kwl.find(prefix, "bore_sight_ty"); const char* bore_sight_tz = kwl.find(prefix, "bore_sight_tz"); const char* principal_point = kwl.find(prefix, "principal_point"); const char* pixel_size = kwl.find(prefix, "pixel_size"); const char* focal_length = kwl.find(prefix, "focal_length"); const char* latlonh_platform_position = kwl.find(prefix, "latlonh_platform_position"); const char* utm_platform_position = kwl.find(prefix, "utm_platform_position"); const char* compute_gsd_flag = kwl.find(prefix, "compute_gsd_flag"); const char* utm_zone = kwl.find(prefix, "utm_zone"); const char* utm_hemisphere = kwl.find(prefix, "utm_hemisphere"); const char* camera_file = kwl.find(prefix, "camera_file"); const char* shift_values = kwl.find(prefix, "shift_values"); theCompositeMatrix = ossimMatrix3x3::createIdentity(); theCompositeMatrixInverse = ossimMatrix3x3::createIdentity(); theOmega = 0.0; thePhi = 0.0; theKappa = 0.0; theBoreSightTx = 0.0; theBoreSightTy = 0.0; theBoreSightTz = 0.0; theFocalLength = 55.0; thePixelSize = ossimDpt(.009, .009); theEcefPlatformPosition = ossimGpt(0.0,0.0, 1000.0); bool loadedFromEoFile = false; if(eo_id) { theImageID = eo_id; } // loading from standard eo file with given record id // if(eo_file) { ossimApplanixEOFile eoFile; if(eoFile.parseFile(ossimFilename(eo_file))) { ossimRefPtr<ossimApplanixEORecord> record = eoFile.getRecordGivenId(theImageID); if(record.valid()) { loadedFromEoFile = true; theBoreSightTx = eoFile.getBoreSightTx()/60.0; theBoreSightTy = eoFile.getBoreSightTy()/60.0; theBoreSightTz = eoFile.getBoreSightTz()/60.0; theShiftValues = ossimEcefVector(eoFile.getShiftValuesX(), eoFile.getShiftValuesY(), eoFile.getShiftValuesZ()); ossim_int32 easting = eoFile.getFieldIdxLike("EASTING"); ossim_int32 northing = eoFile.getFieldIdxLike("NORTHING"); ossim_int32 height = eoFile.getFieldIdxLike("HEIGHT"); ossim_int32 omega = eoFile.getFieldIdxLike("OMEGA"); ossim_int32 phi = eoFile.getFieldIdxLike("PHI"); ossim_int32 kappa = eoFile.getFieldIdxLike("KAPPA"); if((omega>=0)&& (phi>=0)&& (kappa>=0)&& (height>=0)&& (easting>=0)&& (northing>=0)) { theOmega = (*record)[omega].toDouble(); thePhi = (*record)[phi].toDouble(); theKappa = (*record)[kappa].toDouble(); double h = (*record)[height].toDouble(); ossimString heightType = kwl.find(prefix, "height_type"); if(eoFile.isUtmFrame()) { theUtmZone = eoFile.getUtmZone(); theUtmHemisphere = eoFile.getUtmHemisphere()=="North"?'N':'S'; ossimUtmProjection utmProj; utmProj.setZone(theUtmZone); utmProj.setHemisphere((char)theUtmHemisphere); theUtmPlatformPosition.x = (*record)[easting].toDouble(); theUtmPlatformPosition.y = (*record)[northing].toDouble(); theUtmPlatformPosition.z = h; thePlatformPosition = utmProj.inverse(ossimDpt(theUtmPlatformPosition.x, theUtmPlatformPosition.y)); thePlatformPosition.height(h); if(eoFile.isHeightAboveMSL()) { double offset = ossimGeoidManager::instance()->offsetFromEllipsoid(thePlatformPosition); if(!ossim::isnan(offset)) { thePlatformPosition.height(h + offset); theUtmPlatformPosition.z = h + offset; } } } else { return false; } } theEcefPlatformPosition = thePlatformPosition; } else { return false; } } } if(!loadedFromEoFile) { if(shift_values) { std::vector<ossimString> splitString; ossimString tempString(shift_values); tempString = tempString.trim(); tempString.split(splitString, " " ); if(splitString.size() == 3) { theShiftValues = ossimEcefVector(splitString[0].toDouble(), splitString[1].toDouble(), splitString[2].toDouble()); } } if(omega&&phi&&kappa) { theOmega = ossimString(omega).toDouble(); thePhi = ossimString(phi).toDouble(); theKappa = ossimString(kappa).toDouble(); } if(bore_sight_tx&&bore_sight_ty&&bore_sight_tz) { theBoreSightTx = ossimString(bore_sight_tx).toDouble()/60.0; theBoreSightTy = ossimString(bore_sight_ty).toDouble()/60.0; theBoreSightTz = ossimString(bore_sight_tz).toDouble()/60.0; } double lat=0.0, lon=0.0, h=0.0; if(utm_zone) { theUtmZone = ossimString(utm_zone).toInt32(); } if(utm_hemisphere) { ossimString hem = utm_hemisphere; hem = hem.trim(); hem = hem.upcase(); theUtmHemisphere = *(hem.begin()); } if(utm_platform_position) { ossimUtmProjection utmProj; std::vector<ossimString> splitString; ossimString tempString(utm_platform_position); tempString = tempString.trim(); ossimString datumString; utmProj.setZone(theUtmZone); utmProj.setHemisphere((char)theUtmHemisphere); tempString.split(splitString, " "); if(splitString.size() > 2) { theUtmPlatformPosition.x = splitString[0].toDouble(); theUtmPlatformPosition.y = splitString[1].toDouble(); theUtmPlatformPosition.z = splitString[2].toDouble(); } if(splitString.size() > 3) { datumString = splitString[3]; } const ossimDatum* datum = ossimDatumFactory::instance()->create(datumString); if(datum) { utmProj.setDatum(datum); } thePlatformPosition = utmProj.inverse(ossimDpt(theUtmPlatformPosition.x, theUtmPlatformPosition.y)); thePlatformPosition.height(theUtmPlatformPosition.z); ossimString heightType = kwl.find(prefix, "height_type"); if(heightType == "msl") { double offset = ossimGeoidManager::instance()->offsetFromEllipsoid(thePlatformPosition); if(ossim::isnan(offset) == false) { thePlatformPosition.height(thePlatformPosition.height() + offset); theUtmPlatformPosition.z = thePlatformPosition.height(); } } theEcefPlatformPosition = thePlatformPosition; } else if(latlonh_platform_position) { std::vector<ossimString> splitString; ossimString tempString(latlonh_platform_position); std::string datumString; tempString = tempString.trim(); tempString.split(splitString, " "); if(splitString.size() > 2) { lat = splitString[0].toDouble(); lon = splitString[1].toDouble(); h = splitString[2].toDouble(); } if(splitString.size() > 3) { datumString = splitString[3]; } thePlatformPosition.latd(lat); thePlatformPosition.lond(lon); thePlatformPosition.height(h); const ossimDatum* datum = ossimDatumFactory::instance()->create(datumString); if(datum) { thePlatformPosition.datum(datum); } ossimString heightType = kwl.find(prefix, "height_type"); if(heightType == "msl") { double offset = ossimGeoidManager::instance()->offsetFromEllipsoid(thePlatformPosition); if(ossim::isnan(offset) == false) { thePlatformPosition.height(thePlatformPosition.height() + offset); } } theEcefPlatformPosition = thePlatformPosition; } } if(principal_point) { std::vector<ossimString> splitString; ossimString tempString(principal_point); tempString = tempString.trim(); tempString.split(splitString, " "); if(splitString.size() == 2) { thePrincipalPoint.x = splitString[0].toDouble(); thePrincipalPoint.y = splitString[1].toDouble(); } } if(pixel_size) { std::vector<ossimString> splitString; ossimString tempString(principal_point); tempString = tempString.trim(); tempString.split(splitString, " "); if(splitString.size() == 2) { thePixelSize.x = splitString[0].toDouble(); thePixelSize.y = splitString[1].toDouble(); } } if(focal_length) { theFocalLength = ossimString(focal_length).toDouble(); } if(camera_file) { ossimKeywordlist cameraKwl; ossimKeywordlist lensKwl; cameraKwl.add(camera_file); const char* sensor = cameraKwl.find("sensor"); const char* image_size = cameraKwl.find(prefix, "image_size"); principal_point = cameraKwl.find("principal_point"); focal_length = cameraKwl.find("focal_length"); pixel_size = cameraKwl.find(prefix, "pixel_size"); focal_length = cameraKwl.find(prefix, "focal_length"); const char* distortion_units = cameraKwl.find(prefix, "distortion_units"); ossimUnitConversionTool tool; ossimUnitType unitType = OSSIM_MILLIMETERS; if(distortion_units) { unitType = (ossimUnitType)ossimUnitTypeLut::instance()->getEntryNumber(distortion_units); if(unitType == OSSIM_UNIT_UNKNOWN) { unitType = OSSIM_MILLIMETERS; } } if(image_size) { std::vector<ossimString> splitString; ossimString tempString(image_size); tempString = tempString.trim(); tempString.split(splitString, " "); double w=1, h=1; if(splitString.size() == 2) { w = splitString[0].toDouble(); h = splitString[1].toDouble(); } theImageClipRect = ossimDrect(0,0,w-1,h-1); theRefImgPt = ossimDpt(w/2.0, h/2.0); } if(sensor) { theSensorID = sensor; } if(principal_point) { std::vector<ossimString> splitString; ossimString tempString(principal_point); tempString = tempString.trim(); tempString.split(splitString, " "); if(splitString.size() == 2) { thePrincipalPoint.x = splitString[0].toDouble(); thePrincipalPoint.y = splitString[1].toDouble(); } } if(pixel_size) { std::vector<ossimString> splitString; ossimString tempString(pixel_size); tempString = tempString.trim(); tempString.split(splitString, " "); if(splitString.size() == 1) { thePixelSize.x = splitString[0].toDouble(); thePixelSize.y = thePixelSize.x; } else if(splitString.size() == 2) { thePixelSize.x = splitString[0].toDouble(); thePixelSize.y = splitString[1].toDouble(); } } if(focal_length) { theFocalLength = ossimString(focal_length).toDouble(); } ossim_uint32 idx = 0; for(idx = 0; idx < 26; ++idx) { const char* value = cameraKwl.find(ossimString("d")+ossimString::toString(idx)); if(value) { std::vector<ossimString> splitString; ossimString tempString(value); double distance=0.0, distortion=0.0; tempString = tempString.trim(); tempString.split(splitString, " "); if(splitString.size() == 2) { distance = splitString[0].toDouble(); distortion = splitString[1].toDouble(); } tool.setValue(distortion, unitType); lensKwl.add(ossimString("distance") + ossimString::toString(idx), distance, true); lensKwl.add(ossimString("distortion") + ossimString::toString(idx), tool.getMillimeters(), true); } lensKwl.add("convergence_threshold", .00001, true); if(pixel_size) { lensKwl.add("dxdy", ossimString(pixel_size) + " " + ossimString(pixel_size), true); } else { lensKwl.add("dxdy", ".009 .009", true); } } if(theLensDistortion.valid()) { theLensDistortion->loadState(lensKwl,""); } } else { if(principal_point) { std::vector<ossimString> splitString; ossimString tempString(principal_point); tempString = tempString.trim(); tempString.split(splitString, " "); if(splitString.size() == 2) { thePrincipalPoint.x = splitString[0].toDouble(); thePrincipalPoint.y = splitString[1].toDouble(); } } else { if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "No principal_point found" << std::endl; return false; } } if(pixel_size) { std::vector<ossimString> splitString; ossimString tempString(pixel_size); tempString = tempString.trim(); tempString.split(splitString, " "); if(splitString.size() == 1) { thePixelSize.x = splitString[0].toDouble(); thePixelSize.y = thePixelSize.x; } else if(splitString.size() == 2) { thePixelSize.x = splitString[0].toDouble(); thePixelSize.y = splitString[1].toDouble(); } } else { if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "No pixel size found" << std::endl; return false; } } if(focal_length) { theFocalLength = ossimString(focal_length).toDouble(); } else { if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "No focal length found" << std::endl; return false; } } if(theLensDistortion.valid()) { ossimString lensPrefix = ossimString(prefix)+"distortion."; theLensDistortion->loadState(kwl, lensPrefix.c_str()); } } theRefGndPt = thePlatformPosition; updateModel(); lineSampleToWorld(theRefImgPt, theRefGndPt); if(compute_gsd_flag) { if(ossimString(compute_gsd_flag).toBool()) { ossimGpt right; ossimGpt top; lineSampleToWorld(theRefImgPt + ossimDpt(1.0, 0.0), right); lineSampleToWorld(theRefImgPt + ossimDpt(1.0, 0.0), top); ossimEcefVector horizontal = ossimEcefPoint(theRefGndPt)-ossimEcefPoint(right); ossimEcefVector vertical = ossimEcefPoint(theRefGndPt)-ossimEcefPoint(top); theGSD.x = horizontal.length(); theGSD.y = vertical.length(); theMeanGSD = (theGSD.x+theGSD.y)*.5; } } if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "theOmega: " << theOmega << std::endl << "thePhi: " << thePhi << std::endl << "theKappa: " << theKappa << std::endl; std::cout << "platform position: " << thePlatformPosition << std::endl; std::cout << "platform position ECF: " << theEcefPlatformPosition << std::endl; std::cout << "ossimApplanixModel::loadState: ......... leaving" << std::endl; } return true; }
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; }
//************************************************************************************************* // Fetches the state of the original chain and regenerates the clones. Special handling is required // when the image handlers are to be shared among all clones. //************************************************************************************************* bool ossimImageChainMtAdaptor::loadState(const ossimKeywordlist& kwl, const char* prefix) { bool succeeded; // Reset this object: deleteReplicas(); // Fetch this object's data members before moving onto original chain: ossimString value = kwl.find(prefix, NUM_THREADS_KW); if (value.empty()) return false; m_numThreads = value.toUInt32(); if (m_numThreads == 0) return false; // The chain ID needs to be read from KWL: ossimId orig_source_id (ossimId::INVALID_ID); value = kwl.find(prefix, ORIGINAL_SOURCE_ID_KW); if (value.empty()) return false; orig_source_id.setId(value.toInt64()); // This loadState may be called for the purpose of replicating the existing original, or it can // be intended as an adapter to a yet-to-be-instantiated original chain. Check if we already // have a valid original chain: ossimConnectableObject* candidate = 0; ossimImageSource* original_source = 0; if (!m_adaptedChain.valid() || m_chainContainers.empty()) { m_chainContainers.clear(); m_chainContainers.push_back(new ossimConnectableContainer); m_chainContainers[0]->loadState(kwl, prefix); // Need to instantiate a new original. This is a bootstrap for a full initialization of this // object. We'll need to replicate the clones afterwards: ossimIdVisitor visitor (orig_source_id); m_chainContainers[0]->accept(visitor); candidate = visitor.getObject(); original_source = dynamic_cast<ossimImageSource*>(candidate); if (original_source == NULL) return false; m_clones.push_back(original_source); // original is always in first position of clones list // The original "chain" is morphed into a chain with a single child (original first source). // This source is the one maintaining the connection to the rest of the sources in the real // processing chain: m_adaptedChain = new ossimImageChain; m_adaptedChain->add(original_source); // Now that we have an original chain, Recursive code to replicate clones: succeeded = replicate(); if (!succeeded) return false; } // We may be done: if (m_numThreads == 1) return true; // In preparation for multi-threading jobs, loop to instantiate all clone chains. The container // class is used to perform a deep copy of the original chain with all connections established. // It would have been cleaner to just use the ossimImageChain::dup() but that method was not // traversing the full chain, resulting in missing input sources: succeeded = true; for (ossim_uint32 i=1; (i<m_numThreads) && succeeded; ++i) { // Use original container's kwl to dup clone container, and pull out our chain of interest: m_chainContainers.push_back(new ossimConnectableContainer); m_chainContainers[i]->loadState(kwl, prefix); // Special handling required if the handlers are being shared. In this case, the handler had // been removed from the original chain, so connections need to be identified and made: if (d_useSharedHandlers) { succeeded = connectSharedHandlers(i); if (!succeeded) return false; } // Find the first (right-most) source in the chain and store it in the clone list. Need to // Modify all IDs ossimIdVisitor visitor (orig_source_id); m_chainContainers[i]->accept(visitor); candidate = visitor.getObject(); m_chainContainers[i]->makeUniqueIds(); ossimRefPtr<ossimImageSource> clone_source = dynamic_cast<ossimImageSource*>(candidate); if (clone_source == NULL) return false; m_clones.push_back(clone_source); } return succeeded; }
bool ossimErsSarModel::loadState(const ossimKeywordlist &kwl, const char *prefix) { static const char MODULE[] = "ossimErsSarModel::loadState"; if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entered...\n"; } const char* lookup = 0; ossimString s; // Check the type first. lookup = kwl.find(prefix, ossimKeywordNames::TYPE_KW); if (lookup) { s = lookup; if (s != getClassName()) { return false; } } // Load the base class. // bool result = ossimGeometricSarSensorModel::loadState(kwl, prefix); bool result = false; result = InitPlatformPosition(kwl, prefix); if (!result) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_WARN) << MODULE << "\nCan't init platform position \n"; } } if (result) { result = InitSensorParams(kwl, prefix); if (!result) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_WARN) << MODULE << "\nCan't init sensor parameters \n"; } } } if (result) { result = InitRefPoint(kwl, prefix); if (!result) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_WARN) << MODULE << "\nCan't init ref point \n"; } } } if (result) { result = InitSRGR(kwl, prefix); if (!result) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_WARN) << MODULE << "\nCan't init ref point \n"; } } } return result; }
bool ossimNdfTileSource::loadState(const ossimKeywordlist& kwl, const char* prefix) { const char* lookup = kwl.find(prefix, "header_filename"); if (lookup) { theHeaderFile = lookup; return ossimGeneralRasterTileSource::loadState(kwl, prefix); } theErrorStatus = ossimErrorCodes::OSSIM_ERROR; return false; #if 0 if(lookup) { // Validate Header to ensure we support this data type ossimNdfHeader lnh(lookup); if(lnh.getErrorStatus()) { theErrorStatus = ossimErrorCodes::OSSIM_ERROR; return false; } // Use General Raster classes to build NLAPS imagery ossimGeneralRasterInfo generalRasterInfo; if(lnh.getNumOfBands() == 1) { generalRasterInfo = ossimGeneralRasterInfo(lnh.getImageFileList(), OSSIM_UINT8, OSSIM_BSQ, lnh.getNumOfBands(), lnh.getLines(), lnh.getSamples(), 0, ossimGeneralRasterInfo::NONE, 0); } else { generalRasterInfo = ossimGeneralRasterInfo(lnh.getImageFileList(), OSSIM_UINT8, OSSIM_BSQ_MULTI_FILE, lnh.getNumOfBands(), lnh.getLines(), lnh.getSamples(), 0, ossimGeneralRasterInfo::NONE, 0); } return open(generalRasterInfo); } else { theErrorStatus = ossimErrorCodes::OSSIM_ERROR; return false; } #endif }