ossim_int32 ossimNitfTextInfoRecordV2_0::getImageLength()const { return ossimString(theTextLength).toInt32(); }
bool ossimQuickbirdMetaData::getMapProjectionKwl( const ossimFilename& imd_file, ossimKeywordlist& kwl ) { static const char MODULE[] = "ossimQuickbirdMetaData::getMapProjectionKwl"; if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entered...\n"; } bool result = false; if( imd_file.exists() ) { FILE* fptr = fopen (imd_file.c_str(), "r"); if (fptr) { char* strptr(NULL); //--- // Read the file into a buffer: //--- ossim_int32 fileSize = static_cast<ossim_int32>(imd_file.fileSize()); char* filebuf = new char[fileSize]; fread(filebuf, 1, fileSize, fptr); strptr = filebuf; fclose(fptr); ossimString imd_key; ossimString tempStr; std::string key; std::string value; // Loop until we find all our keys or bust out with error. while ( 1 ) { // Verify map projected. imd_key = "BEGIN_GROUP = MAP_PROJECTED_PRODUCT"; if ( strstr( filebuf, imd_key.c_str() ) == NULL ) { break; // Not a map projected product. } // Get datum: if( getEndOfLine( strptr, ossimString("\n\tdatumName = "), "%13c %s", tempStr) ) { if ( tempStr.contains("WE") ) { key = "dataum"; value = "WGE"; kwl.addPair(key, value); } else { if(traceDebug()) { ossimNotify(ossimNotifyLevel_WARN) << "Unhandled datum: " << tempStr << "\n"; } } } // Get projection: if( getEndOfLine( strptr, ossimString("\n\tmapProjName = "), "%15c %s", tempStr) ) { if ( tempStr.contains("UTM") ) { key = "type"; value = "ossimUtmProjection"; kwl.addPair(key, value); } else { if(traceDebug()) { ossimNotify(ossimNotifyLevel_WARN) << "Unhandled projection name: " << tempStr << "\n"; } } } // Get projection: if( getEndOfLine( strptr, ossimString("\n\tmapProjName = "), "%15c %s", tempStr) ) { if ( tempStr.contains("UTM") ) { key = "type"; value = "ossimUtmProjection"; kwl.addPair(key, value); // Get UTM zone: if( getEndOfLine( strptr, ossimString("\n\tmapZone = "), "%11c %s", tempStr) ) { key = "zone"; value = tempStr.trim(";").string(); kwl.addPair(key, value); } else { break; } // Get UTM hemisphere: if( getEndOfLine( strptr, ossimString("\n\tmapHemi = "), "%11c %s", tempStr) ) { key = "hemisphere"; tempStr = tempStr.trim(";"); tempStr = tempStr.trim("\""); value = tempStr.string(); kwl.addPair(key, value); } else { break; } } // End UTM: } // Get projection units: std::string units; if( getEndOfLine( strptr, ossimString("\n\tproductUnits = "), "%16c %s", tempStr) ) { if ( tempStr == "\"M\";" ) { key = "units"; units = "meters"; kwl.addPair(key, units); } else { if(traceDebug()) { ossimNotify(ossimNotifyLevel_WARN) << "Unhandled units: " << tempStr << "\n"; } } } // Get projection tie point: ossimDpt dpt; dpt.makeNan(); if( getEndOfLine( strptr, ossimString("\n\toriginX = "), "%11c %s", tempStr) ) { tempStr = tempStr.trim(";"); dpt.x = tempStr.toFloat64(); } else { break; } if( getEndOfLine( strptr, ossimString("\n\toriginY = "), "%11c %s", tempStr) ) { tempStr = tempStr.trim(";"); dpt.y = tempStr.toFloat64(); } else { break; } if ( dpt.hasNans() == false ) { key = "tie_point_units"; kwl.addPair(key, units); key = "tie_point_xy"; value = dpt.toString().string(); kwl.addPair( key, value ); } else { if(traceDebug()) { ossimNotify(ossimNotifyLevel_WARN) << "tie point has nans!"; } break; } // Get projection scale: dpt.makeNan(); if( getEndOfLine( strptr, ossimString("\n\tcolSpacing = "), "%14c %s", tempStr) ) { tempStr = tempStr.trim(";"); dpt.x = tempStr.toFloat64(); } else { break; } if( getEndOfLine( strptr, ossimString("\n\trowSpacing = "), "%14c %s", tempStr) ) { tempStr = tempStr.trim(";"); dpt.y = tempStr.toFloat64(); } else { break; } if ( dpt.hasNans() == false ) { key = "pixel_scale_units"; kwl.addPair(key, units); key = "pixel_scale_xy"; value = dpt.toString().string(); kwl.addPair( key, value ); } else { if(traceDebug()) { ossimNotify(ossimNotifyLevel_WARN) << "scale has nans!"; } break; } //--- // End of key look up. If we get here set the status to true and // bust out of loop. //--- result = true; break; } if ( result == false ) { if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ERROR: Missing or unhandled key in metadat: " << imd_key << "\n"; } } delete [] filebuf; filebuf = 0; } else { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimQuickbirdRpcModel::parseMetaData(imd_file) DEBUG:" << "\nCould not open Meta data file: " << imd_file << "\nreturning with error...\n"; } } } if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " exit status = " << (result?"true":"false") << "\n"; } return result; }
//--- // File: ossimNitfRsmecaTag.cpp //--- #include <ossim/support_data/ossimNitfRsmecaTag.h> #include <ossim/support_data/ossimNitfCommon.h> #include <ossim/base/ossimNotifyContext.h> #include <ossim/base/ossimTrace.h> #include <ossim/base/ossimStringProperty.h> #include <iostream> #include <iomanip> static const ossimTrace traceDebug(ossimString("ossimNitfRsmecaTag:debug")); static const ossimString RNPCF_KW = "RNPCF"; static const ossimString RDPCF_KW = "RDPCF"; // "0 1 2"; // "123456789012345678901"; static const ossimString FILL21 = " "; ossimNitfRsmecaIsg::ossimNitfRsmecaIsg() : m_numopg(), m_errcvg(), m_tcdf(), m_ncseg(), m_corseg(), m_tauseg(), m_errCovNum(0), m_opgNum(0),
bool ossimNitfProjectionFactory::getBlockaPoints( const ossimNitfImageHeader* hdr, std::vector<ossimGpt>& gpts) const { if (!hdr) { return false; } ossimRefPtr<ossimNitfRegisteredTag> tag = hdr->getTagData(ossimString("BLOCKA")); if (!tag) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimNitfProjectionFactory::getBlockaPoints DEBUG:" << "\nBLOCKA tag not found." << std::endl; } return false; } if (gpts.size()) { gpts.clear(); } ossimNitfBlockaTag* blockaTag = PTR_CAST(ossimNitfBlockaTag, tag.get()); if (!blockaTag) { return false; } ossimDpt dpt; ossimGpt gpt; // Get the upper left or first row first column. blockaTag->getFrfcLoc(dpt); gpt.latd(dpt.y); gpt.lond(dpt.x); gpts.push_back(gpt); // Get the upper right or first row last column. blockaTag->getFrlcLoc(dpt); gpt.latd(dpt.y); gpt.lond(dpt.x); gpts.push_back(gpt); // Get the lower right or last row last column. blockaTag->getLrlcLoc(dpt); gpt.latd(dpt.y); gpt.lond(dpt.x); gpts.push_back(gpt); // Get the lower left or last row first column. blockaTag->getLrfcLoc(dpt); gpt.latd(dpt.y); gpt.lond(dpt.x); gpts.push_back(gpt); if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimNitfProjectionFactory::getBlockaPoints DEBUG:" << std::endl; for (int i=0; i<4; ++i) { ossimNotify(ossimNotifyLevel_DEBUG) << "gpt[" << i << "] " << gpts[i] << std::endl; } } return true; }
void ossimDtedHdr::getPropertyNames( std::vector<ossimString>& propertyNames) const { propertyNames.push_back(ossimString("dted_hdr_record")); }
// Create histogram for entry: void ossimImageUtil::createHistogram(ossimRefPtr<ossimImageHandler>& ih, ossim_uint32 entry, bool useEntryIndex) { static const char M[] = "ossimImageUtil::createHistogram #2"; if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << M << " entered...\n"; } if ( ih.valid() ) { if (useEntryIndex) { // Set entry before deriving file name. ih->setCurrentEntry(entry); ossimNotify(ossimNotifyLevel_NOTICE) << "entry number: "<< entry << std::endl; } ossimFilename outputFile = ih->getFilenameWithThisExtension(ossimString(".his"), useEntryIndex); // Only build if needed: if ( (outputFile.exists() == false) || rebuildHistogram() ) { ossimNotify(ossimNotifyLevel_NOTICE) << "Computing histogram for file: " << ih->getFilename() << std::endl; // Check handler to see if it's filtering bands. std::vector<ossim_uint32> originalBandList(0); if ( ih->isBandSelector() ) { // Capture for finalize method. ih->getOutputBandList( originalBandList ); // Set output list to input. ih->setOutputToInputBandList(); } ossimRefPtr<ossimImageHistogramSource> histoSource = new ossimImageHistogramSource; ossimRefPtr<ossimHistogramWriter> writer = new ossimHistogramWriter; histoSource->setMaxNumberOfRLevels(1); // Currently hard coded... #if 0 /* TODO tmp drb */ if( !ossim::isnan(histoMin) ) { histoSource->setMinValueOverride(histoMin); } if( !ossim::isnan(histoMax) ) { histoSource->setMaxValueOverride(histoMax); } if(histoBins > 0) { histoSource->setNumberOfBinsOverride(histoBins); } #endif if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "Histogram mode: " << getHistogramMode() << "\n"; } // Connect histogram source to image handler. histoSource->setComputationMode( getHistogramMode() ); histoSource->connectMyInputTo(0, ih.get() ); histoSource->enableSource(); // Connect writer to histogram source. writer->connectMyInputTo(0, histoSource.get()); writer->setFilename(outputFile); theStdOutProgress.setFlushStreamFlag(true); writer->addListener(&theStdOutProgress); // Compute... writer->execute(); writer=0; // Reset the band list. if ( ih->isBandSelector() && originalBandList.size() ) { ih->setOutputBandList( originalBandList ); } } // Matches: if ( (outputFile.exists() == false) || rebuildHistogram() ) } // Matches: if ( ih.valid() ) if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << M << " exited...\n"; } } // End: ossimImageUtil::createHistogram #2
bool ossimBuckeyeSensor::loadState(const ossimKeywordlist& kwl, const char* prefix) { if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimBuckeyeSensor::loadState: entering..." << std::endl; theImageClipRect = ossimDrect(0,0,8984,6732); theRefImgPt = ossimDpt(4492, 3366); ossimSensorModel::loadState(kwl, prefix); if(getNumberOfAdjustableParameters() < 1) { initAdjustableParameters(); } theEcefPlatformPosition = ossimGpt(0.0,0.0,1000.0); theAdjEcefPlatformPosition = ossimGpt(0.0,0.0,1000.0); theRoll = 0.0; thePitch = 0.0; theHeading = 0.0; ossimString framemeta_gsti = kwl.find(prefix, "framemeta_gsti"); ossimString framemeta = kwl.find(prefix,"framemeta"); ossimString frame_number = kwl.find(prefix, "frame_number"); ossimString pixel_size = kwl.find(prefix, "pixel_size"); ossimString principal_point = kwl.find(prefix, "principal_point"); ossimString focal_length = kwl.find(prefix, "focal_length"); ossimString smac_radial = kwl.find(prefix, "smac_radial"); ossimString smac_decent = kwl.find(prefix, "smac_decent"); ossimString roll; ossimString pitch; ossimString yaw; ossimString platform_position; ossimFilename file_to_load; ossimString FRAME_STRING = "Frame#"; ossimString ROLL_STRING = "Roll(deg)"; ossimString PITCH_STRING = "Pitch(deg)"; ossimString YAW_STRING = "Yaw(deg)"; ossimString LAT_STRING = "Lat(deg)"; ossimString LON_STRING = "Lon(deg)"; ossimString HAE_STRING = "HAE(m)"; // Deal with the fact that there are 3 different types of 'FrameMeta' file if (framemeta_gsti.empty() && !framemeta.empty() && !frame_number.empty()) { file_to_load.setFile(framemeta); YAW_STRING = "Azimuth(deg)"; } else if (!framemeta_gsti.empty() && framemeta.empty() && !frame_number.empty()) { file_to_load.setFile(framemeta_gsti); } if (file_to_load.exists() && !frame_number.empty()) { ossimCsvFile csv(" \t"); // we will use tab or spaces as seaparator if(csv.open(file_to_load)) { if(csv.readHeader()) { ossimCsvFile::StringListType heads = csv.fieldHeaderList(); // Try to see if you can find the first header item, if not, then you either have a file that doesn't work in this case, or it's uppercase if (std::find(heads.begin(), heads.end(), FRAME_STRING) == heads.end()) { FRAME_STRING = FRAME_STRING.upcase(); ROLL_STRING = ROLL_STRING.upcase(); PITCH_STRING = PITCH_STRING.upcase(); YAW_STRING = YAW_STRING.upcase(); LAT_STRING = LAT_STRING.upcase(); LON_STRING = LON_STRING.upcase(); HAE_STRING = HAE_STRING.upcase(); } ossimRefPtr<ossimCsvFile::Record> record; bool foundFrameNumber = false; while( ((record = csv.nextRecord()).valid()) && !foundFrameNumber) { if( (*record)[FRAME_STRING] == frame_number) { foundFrameNumber = true; roll = (*record)[ROLL_STRING]; pitch = (*record)[PITCH_STRING]; yaw = (*record)[YAW_STRING]; platform_position = (*record)[LAT_STRING] + " " + (*record)[LON_STRING]+ " " + (*record)[HAE_STRING] + " WGE"; } } } } csv.close(); } else { roll = kwl.find(prefix, "roll"); pitch = kwl.find(prefix, "pitch"); yaw = kwl.find(prefix, "heading"); platform_position = kwl.find(prefix, "ecef_platform_position"); } bool result = (!pixel_size.empty()&& !principal_point.empty()&& !focal_length.empty()&& !platform_position.empty()); if(!focal_length.empty()) { theFocalLength = focal_length.toDouble(); } if(!pixel_size.empty()) { thePixelSize.toPoint(pixel_size); } if(!roll.empty()) { theRoll = roll.toDouble(); } if(!pitch.empty()) { thePitch = pitch.toDouble(); } if(!yaw.empty()) { theHeading = yaw.toDouble(); } if(!principal_point.empty()) { thePrincipalPoint.toPoint(principal_point); } if(platform_position.contains("WGE")) { std::vector<ossimString> splitString; ossimString tempString(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(); } theEcefPlatformPosition = ossimGpt(lat,lon,h); } else { std::vector<ossimString> splitString; ossimString tempString(platform_position); tempString.split(splitString, ossimString(" ")); std::string datumString; double x=0.0, y=0.0, z=0.0; if(splitString.size() > 2) { x = splitString[0].toDouble(); y = splitString[1].toDouble(); z = splitString[2].toDouble(); } theEcefPlatformPosition = ossimEcefPoint(x, y, z); } theLensDistortion = 0; if(!smac_radial.empty()&& !smac_decent.empty()) { std::vector<ossimString> radial; std::vector<ossimString> decent; smac_radial.split(radial, " "); smac_decent.split(decent, " "); if((radial.size() == 5)&& (decent.size() == 4)) { // Just for debugging really.. optomization will make this sleeker double k0 = radial[0].toDouble(); double k1 = radial[1].toDouble(); double k2 = radial[2].toDouble(); double k3 = radial[3].toDouble(); double k4 = radial[4].toDouble(); double p0 = decent[0].toDouble(); double p1 = decent[1].toDouble(); double p2 = decent[2].toDouble(); double p3 = decent[3].toDouble(); //theLensDistortion = new ossimSmacCallibrationSystem(radial[0].toDouble(), // radial[1].toDouble(), // radial[2].toDouble(), // radial[3].toDouble(), // radial[4].toDouble(), // decent[0].toDouble(), // decent[1].toDouble(), // decent[2].toDouble(), // decent[3].toDouble()); theLensDistortion = new ossimSmacCallibrationSystem(k0,k1,k2,k3,k4,p0,p1,p2,p3); } } theImageSize = ossimDpt(theImageClipRect.width(), theImageClipRect.height()); updateModel(); if(theGSD.isNan()) { try { // This will set theGSD and theMeanGSD. Method throws ossimException. computeGsd(); } catch (const ossimException& e) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimBuckeyeSensor::loadState Caught Exception:\n" << e.what() << std::endl; } } } if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimBuckeyeSensor::loadState: returning..." << std::endl; return result; }
ossim_uint64 ossimNitfImageInfoRecordV2_0::getImageLength()const { return ossimString(theImageLength).toInt32(); }
void ossimPngReader::getPropertyNames(std::vector<ossimString>& propertyNames)const { propertyNames.push_back( ossimString(USE_ALPHA_KW) ); ossimImageHandler::getPropertyNames(propertyNames); }
void ossimNitfFileHeaderV2_0::writeStream(std::ostream &out) { // identification and origination group out.write(theFileTypeVersion, 9); out.write(theComplexityLevel, 2); out.write(theSystemType, 4); out.write(theOriginatingStationId, 10); out.write(theDateTime, 14); out.write(theFileTitle, 80); // read security group out.write(theSecurityClassification, 1); out.write(theCodewords, 40); out.write(theControlAndHandling, 40); out.write(theReleasingInstructions, 40); out.write(theClassificationAuthority, 20); out.write(theSecurityControlNumber, 20); out.write(theSecurityDowngrade, 6); if(ossimString(theSecurityDowngrade) == "999998") { out.write(theDowngradingEvent, 40); } out.write(theCopyNumber, 5); out.write(theNumberOfCopies, 5); out.write(theEncryption, 1); out.write(theOriginatorsName, 27); out.write(theOriginatorsPhone, 18); out.write(theFileLength, 12); out.write(theHeaderLength, 6); ossim_uint32 idx = 0; { ostringstream outString; outString << std::setw(3) << std::setfill('0') << std::setiosflags(ios::right) << theNitfImageInfoRecords.size(); out.write(outString.str().c_str(), 3); for(idx = 0; idx < theNitfImageInfoRecords.size(); ++idx) { out.write(theNitfImageInfoRecords[idx].theImageSubheaderLength, 6); out.write(theNitfImageInfoRecords[idx].theImageLength, 10); } } { ostringstream outString; outString << std::setw(3) << std::setfill('0') << std::setiosflags(ios::right) << theNitfSymbolInfoRecords.size(); out.write(outString.str().c_str(), 3); for(idx = 0; idx < theNitfSymbolInfoRecords.size(); ++idx) { out.write(theNitfSymbolInfoRecords[idx].theSymbolSubheaderLength, 4); out.write(theNitfSymbolInfoRecords[idx].theSymbolLength, 6); } } { ostringstream outString; outString << std::setw(3) << std::setfill('0') << std::setiosflags(ios::right) << theNitfLabelInfoRecords.size(); out.write(outString.str().c_str(), 3); for(idx = 0; idx < theNitfLabelInfoRecords.size(); ++idx) { out.write(theNitfLabelInfoRecords[idx].theLabelSubheaderLength, 4); out.write(theNitfLabelInfoRecords[idx].theLabelLength, 3); } } { ostringstream outString; outString << std::setw(3) << std::setfill('0') << std::setiosflags(ios::right) << theNitfTextInfoRecords.size(); out.write(outString.str().c_str(), 3); for(idx = 0; idx < theNitfTextInfoRecords.size(); ++idx) { out.write(theNitfTextInfoRecords[idx].theTextSubheaderLength, 4); out.write(theNitfTextInfoRecords[idx].theTextLength, 5); } } { ostringstream outString; outString << std::setw(3) << std::setfill('0') << std::setiosflags(ios::right) << theNitfDataExtSegInfoRecords.size(); out.write(outString.str().c_str(), 3); for(idx = 0; idx < theNitfDataExtSegInfoRecords.size(); ++idx) { out.write(theNitfDataExtSegInfoRecords[idx].theDataExtSegSubheaderLength, 4); out.write(theNitfDataExtSegInfoRecords[idx].theDataExtSegLength, 9); } } { ostringstream outString; outString << std::setw(3) << std::setfill('0') << std::setiosflags(ios::right) << theNitfResExtSegInfoRecords.size(); out.write(outString.str().c_str(), 3); for(idx = 0; idx < theNitfResExtSegInfoRecords.size(); ++idx) { out.write(theNitfResExtSegInfoRecords[idx].theResExtSegSubheaderLength, 4); out.write(theNitfResExtSegInfoRecords[idx].theResExtSegLength, 7); } } out.write(theUserDefinedHeaderDataLength, 5); if(ossimString(theUserDefinedHeaderDataLength).toInt32() > 0) { out.write(theUserDefinedHeaderOverflow, 3); } ossim_uint32 totalLength = getTotalTagLength(); if(totalLength <= 99999) { std::ostringstream tempOut; tempOut << std::setw(5) << std::setfill('0') << std::setiosflags(ios::right) << totalLength; memcpy(theExtendedHeaderDataLength, tempOut.str().c_str(), 5); out.write(theExtendedHeaderDataLength, 5); // for now we hard code te 000 for we do not currently support writing to the DES if the total tag length is // larger than supported // memset(theExtendedHeaderOverflow, '0', 3); if(totalLength > 0) { ossim_uint32 i = 0; out.write(theExtendedHeaderOverflow, 3); for(i = 0; i < theTagList.size(); ++i) { theTagList[i].writeStream(out); } } } else { ossimNotify(ossimNotifyLevel_WARN) << "WARNING ossimNitfFileHeaderV2_0::writeStream: Only support writing of total tag length < 99999" << std::endl; } }
ossim_uint32 ossimNitfImageInfoRecordV2_0::getHeaderLength()const { return ossimString(theImageSubheaderLength).toInt32(); }
void ossimNitfFileHeaderV2_0::parseStream(std::istream &in) { if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimNitfFileHeaderV2_0::parseStream: entered ......." << std::endl; } clearFields(); // identification and origination group in.read(theFileTypeVersion, 9); theHeaderSize+=9; in.read(theComplexityLevel, 2); theHeaderSize+=2; in.read(theSystemType, 4); theHeaderSize+=4; in.read(theOriginatingStationId, 10); theHeaderSize+=10; in.read(theDateTime, 14); theHeaderSize+=14; in.read(theFileTitle, 80); theHeaderSize+=80; // read security group in.read(theSecurityClassification, 1); theHeaderSize++; in.read(theCodewords, 40); theHeaderSize+=40; in.read(theControlAndHandling, 40); theHeaderSize+=40; in.read(theReleasingInstructions, 40); theHeaderSize+=40; in.read(theClassificationAuthority, 20); theHeaderSize+=20; in.read(theSecurityControlNumber, 20); theHeaderSize+=20; in.read(theSecurityDowngrade, 6); theHeaderSize+=6; if(ossimString(theSecurityDowngrade) == "999998") { in.read(theDowngradingEvent, 40); theHeaderSize+=40; } in.read(theCopyNumber, 5); theHeaderSize+=5; in.read(theNumberOfCopies, 5); theHeaderSize+=5; in.read(theEncryption, 1); theHeaderSize++; in.read(theOriginatorsName, 27); theHeaderSize+=27; in.read(theOriginatorsPhone, 18); theHeaderSize+=18; in.read(theFileLength, 12); theHeaderSize+=12; in.read(theHeaderLength, 6); theHeaderSize+=6; // image description group in.read(theNumberOfImageInfoRecords, 3); theHeaderSize+=3; readImageInfoRecords(in); // symbol description group in.read(theNumberOfSymbolInfoRecords, 3); theHeaderSize+=3; readSymbolInfoRecords(in); // label description group in.read(theNumberOfLabelInfoRecords, 3); theHeaderSize+=3; readLabelInfoRecords(in); // text file information group in.read(theNumberOfTextFileInfoRecords, 3); theHeaderSize+=3; readTextFileInfoRecords(in); // Data extension group in.read(theNumberOfDataExtSegInfoRecords, 3); theHeaderSize+=3; readDataExtSegInfoRecords(in); // Reserve Extension Segment group in.read(theNumberOfResExtSegInfoRecords, 3); theHeaderSize+=3; readResExtSegInfoRecords(in); in.read(theUserDefinedHeaderDataLength, 5); theHeaderSize+=5; theTagList.clear(); // only get the header overflow if there even exists // user defined data. ossim_int32 userDefinedHeaderLength = ossimString(theUserDefinedHeaderDataLength).toInt32(); ossimNitfTagInformation headerTag; std::streampos start = in.tellg(); std::streampos current = in.tellg(); theHeaderSize+=userDefinedHeaderLength; if(userDefinedHeaderLength > 0) { in.read(theUserDefinedHeaderOverflow, 3); while((current - start) < userDefinedHeaderLength) { headerTag.parseStream(in); theTagList.push_back(headerTag); // in.ignore(headerTag.getTagLength()); // headerTag.clearFields(); //--- // We will check the stream here as there have been instances of // rpf's with bad stream offsets. //--- if (!in) { std::string e = "ossimNitfFileHeaderV2_0::parseStream stream error!"; throw ossimException(e); } current = in.tellg(); } } in.read(theExtendedHeaderDataLength, 5); theHeaderSize+=5; ossim_int32 extendedHeaderDataLength = ossimString(theExtendedHeaderDataLength).toInt32(); theHeaderSize+=extendedHeaderDataLength; start = in.tellg(); current = in.tellg(); // for now let's just ignore it if(extendedHeaderDataLength > 0) { in.read(theExtendedHeaderOverflow, 3); while((current - start) < extendedHeaderDataLength) { headerTag.parseStream(in); theTagList.push_back(headerTag); in.ignore(headerTag.getTagLength()); headerTag.clearFields(); current = in.tellg(); } } // this need to be re-thought initializeAllOffsets(); if(traceDebug()) { ossimNitfFileHeader::print( ossimNotify(ossimNotifyLevel_DEBUG) ); } if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimNitfFileHeaderV2_0::parseStream: Leaving......." << std::endl; } // initializeDisplayLevels(in); }
ossim_int32 ossimNitfDataExtSegInfoRecordV2_0::getImageLength()const { return ossimString(theDataExtSegLength).toInt32(); }
ossim_int32 ossimNitfDataExtSegInfoRecordV2_0::getHeaderLength()const { return ossimString(theDataExtSegSubheaderLength).toInt32(); }
bool ossimImageUtil::initialize(ossimArgumentParser& ap) { static const char M[] = "ossimImageUtil::initialize(ossimArgumentParser&)"; if ( traceDebug() ) { ossimNotify(ossimNotifyLevel_DEBUG) << M << " entered...\n"; } bool result = true; if ( (ap.argc() == 1) || ap.read("-h") || ap.read("--help") ) { usage(ap); // continue_after_init to false result = false; } else { //--- // Start with clean options keyword list. //--- m_kwl->clear(); while ( 1 ) // While forever loop... { // Used throughout below: std::string ts1; ossimArgumentParser::ossimParameter sp1(ts1); std::string ts2; ossimArgumentParser::ossimParameter sp2(ts2); if( ap.read("-a") || ap.read("--include-fullres") ) { setCopyAllFlag( true ); if ( ap.argc() < 2 ) { break; } } if( ap.read("--compression-quality", sp1) ) { if ( ts1.size() ) { setCompressionQuality( ts1 ); } if ( ap.argc() < 2 ) { break; } } if( ap.read("--compression-type", sp1) ) { if ( ts1.size() ) { setCompressionType( ts1 ); } if ( ap.argc() < 2 ) { break; } } if( ap.read("--ch") || ap.read("--create-histogram") ) { setCreateHistogramFlag( true ); if ( ap.argc() < 2 ) { break; } } if( ap.read("--chf") || ap.read("--create-histogram-fast") ) { setCreateHistogramFastFlag( true ); if ( ap.argc() < 2 ) { break; } } if( ap.read("--create-histogram-r0") ) { setCreateHistogramR0Flag( true ); if ( ap.argc() < 2 ) { break; } } if( ap.read("-d", sp1) ) { setOutputDirectory( ts1 ); if ( ap.argc() < 2 ) { break; } } if( ap.read("--dump-filtered-image-list") ) { setDumpFilteredImageListFlag( true ); if ( ap.argc() < 2 ) { break; } } if( ap.read("-i") || ap.read("--internal-overviews") ) { setInternalOverviewsFlag( true ); if ( ap.argc() < 2 ) { break; } } if( ap.read("--of") || ap.read("--output-files") ) { setOutputFileNamesFlag( true ); if ( ap.argc() < 2 ) { break; } } if( ap.read("-o") ) { setCreateOverviewsFlag( true ); if ( ap.argc() < 2 ) { break; } } if( ap.read("--ot", sp1) ) { setOverviewType( ts1 ); if ( ap.argc() < 2 ) { break; } } if( ap.read("--override-filtered-images") ) { setOverrideFilteredImagesFlag( true ); if ( ap.argc() < 2 ) { break; } } if( ap.read("-r") || ap.read("--rebuild-overviews") ) { setRebuildOverviewsFlag( true ); if ( ap.argc() < 2 ) { break; } } if( ap.read("--rebuild-histogram") ) { setRebuildHistogramFlag( true ); if ( ap.argc() < 2 ) { break; } } while(ap.read("--reader-prop", sp1)) { if (ts1.size()) { std::string key = READER_PROP_KW; key += ossimString::toString( getNextReaderPropIndex() ).string(); addOption( key, ts1 ); } } if ( ap.argc() < 2 ) { break; } if( ap.read("--scanForMinMax" ) ) { setScanForMinMax( true ); if ( ap.argc() < 2 ) { break; } } if( ap.read("--scanForMinMaxNull" ) ) { setScanForMinMaxNull( true ); if ( ap.argc() < 2 ) { break; } } if( ap.read("-s", sp1) ) { setOverviewStopDimension( ts1 ); if ( ap.argc() < 2 ) { break; } } if ( ap.read("-tile-size", sp1)) { setTileSize( ossimString(ts1).toInt32() ); if ( ap.argc() < 2 ) { break; } } if( ap.read("--threads", sp1) ) { m_kwl->addPair( THREADS_KW, ts1 ); if ( ap.argc() < 2 ) { break; } } while(ap.read("--writer-prop", sp1)) { if (ts1.size()) { std::string key = WRITER_PROP_KW; key += ossimString::toString( getNextWriterPropIndex() ).string(); addOption( key, ts1 ); } } if ( ap.argc() < 2 ) { break; } // End of arg parsing. ap.reportRemainingOptionsAsUnrecognized(); if ( ap.errors() ) { ap.writeErrorMessages(ossimNotify(ossimNotifyLevel_NOTICE)); std::string errMsg = "Unknown option..."; throw ossimException(errMsg); } break; // Break from while forever. } // End while (forever) loop. if(ap.argc() > 1) { for (ossim_int32 i = 0; i < (ap.argc()-1); ++i) { ossimString kw = "file"; kw += ossimString::toString(i); std::string value = ap[i+1]; m_kwl->addPair(kw.string(), value, true); } } else { if ( getDumpFilterImagesFlag() ) { // Caller wants to see filtered image names: dumpFilteredImageList(); } else { usage(ap); result = false; } } } // not usage if ( traceDebug() ) { ossimNotify(ossimNotifyLevel_DEBUG) << "m_kwl:\n" << *(m_kwl.get()) << "\n" << M << " exit result = " << (result?"true":"false") << "\n"; } return result; }
ossimString ossimPngReader::getShortName()const { return ossimString("ossim_png_reader"); }
// Create overview for entry: void ossimImageUtil::createOverview(ossimRefPtr<ossimImageHandler>& ih, ossimRefPtr<ossimOverviewBuilderBase>& ob, ossim_uint32 entry, bool useEntryIndex, bool& consumedHistogramOptions) { static const char M[] = "ossimImageUtil::createOverview #2"; if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << M << " entered...\n"; } if ( ih.valid() && ob.valid() ) { if (useEntryIndex) { // Set entry before deriving file name. ih->setCurrentEntry(entry); ossimNotify(ossimNotifyLevel_NOTICE) << "entry number: "<< entry << std::endl; } ossimFilename outputFile = ih->getFilenameWithThisExtension(ossimString(".ovr"), useEntryIndex); if ( rebuildOverviews() ) { ih->closeOverview(); if ( outputFile.exists() ) { outputFile.remove(); } } if ( getInternalOverviewsFlag() ) { if ( ih->getClassName() == "ossimTiffTileSource") { //--- // INTERNAL_OVERVIEWS_FLAG_KW is set to true: // Tiff reader can handle internal overviews. Set the output file to // input file. Do it after the above remove so that if there were // external overviews they will get removed. //--- outputFile = ih->getFilename(); } else { ossimNotify(ossimNotifyLevel_NOTICE) << "Internal overviews not supported for reader type: " <<ih->getClassName() << "\nIgnoring option..." << endl; } } if ( hasRequiredOverview( ih, ob ) == false ) { //--- // Set create histogram code... // // Notes: // 1) Must put this logic after any removal of external overview file. // // 2) Base file could have built in overviews, e.g. jp2 files. So the sequensor could // start at R6 even if there is no external overview file. // // 3) If user want the histogram from R0 the overview builder can do as long as // ossimImageHandler::getNumberOfDecimationLevels returns 1. If we are starting // overview building at R6 then we must do the create histogram in a separate path. //--- ossimHistogramMode histoMode = OSSIM_HISTO_MODE_UNKNOWN; if ( createHistogram() || ( createHistogramR0() && ( ih->getNumberOfDecimationLevels() == 1 ) ) ) { histoMode = OSSIM_HISTO_MODE_NORMAL; } else if ( createHistogramFast() ) { histoMode = OSSIM_HISTO_MODE_FAST; } if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "Histogram mode: " << histoMode << "\n"; } if ( histoMode != OSSIM_HISTO_MODE_UNKNOWN ) { consumedHistogramOptions = true; ob->setHistogramMode(histoMode); ossimNotify(ossimNotifyLevel_NOTICE) << "Creating overviews with histogram for file: " << ih->getFilename() << std::endl; } else { if ( histoMode != OSSIM_HISTO_MODE_UNKNOWN ) { consumedHistogramOptions = false; ossimNotify(ossimNotifyLevel_NOTICE) << "Creating overviews for file: " << ih->getFilename() << std::endl; } } ob->setOutputFile(outputFile); ob->setInputSource(ih.get()); // Create the overview for this entry in this file: if ( ob->execute() == false ) { setErrorStatus( ossimErrorCodes::OSSIM_ERROR ); ossimNotify(ossimNotifyLevel_WARN) << "Error returned creating overviews for file: " << ih->getFilename() << std::endl; } } else { consumedHistogramOptions = false; ossimNotify(ossimNotifyLevel_NOTICE) << "Image has required reduced resolution data sets." << std::endl; } } if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << M << " exited...\n"; } }
ossimString ossimPngReader::getLongName()const { return ossimString("ossim png reader"); }
// $Id: ossimNitfCommon.cpp 17978 2010-08-24 16:17:00Z dburken $ #include <cstring> /* for memcpy */ #include <sstream> #include <iomanip> #include <sstream> #include <stdexcept> #include <iostream> #include <ossim/support_data/ossimNitfCommon.h> #include <ossim/base/ossimDms.h> #include <ossim/base/ossimDpt.h> #include <ossim/base/ossimIrect.h> #include <ossim/base/ossimNotify.h> #include <ossim/base/ossimTrace.h> static const ossimTrace traceDebug(ossimString("ossimNitfCommon:debug")); ossimNitfCommon::ossimNitfCommon(){} ossimNitfCommon::~ossimNitfCommon(){} ossimString ossimNitfCommon::convertToScientificString( const ossim_float64& aValue, ossim_uint32 size) { // Precision cannot hit 0 for this to work... if ( ((aValue < 0.0) && (size < 8)) || ((aValue >= 0.0) && (size < 7)) ) { if (traceDebug())
ossimString ossimNetCdfReader::getShortName()const { return ossimString("ossim_netcdf_reader"); }
#include <ossim/imaging/ossimNitfTileSource.h> #include <ossim/projection/ossimBilinearProjection.h> #include <ossim/projection/ossimEquDistCylProjection.h> #include <ossim/projection/ossimMgrs.h> #include <ossim/projection/ossimProjection.h> #include <ossim/projection/ossimProjectionFactoryRegistry.h> #include <ossim/projection/ossimUtmProjection.h> #include <ossim/support_data/ossimNitfBlockaTag.h> #include <ossim/support_data/ossimNitfFile.h> #include <ossim/support_data/ossimNitfFileHeader.h> #include <ossim/support_data/ossimNitfImageHeader.h> #include <fstream> #include <cmath> // Define Trace flags for use within this file: static ossimTrace traceDebug(ossimString("ossimNitfProjectionFactory:debug")); ossimNitfProjectionFactory* ossimNitfProjectionFactory::theInstance = 0; ossimNitfProjectionFactory::ossimNitfProjectionFactory() { } ossimNitfProjectionFactory::~ossimNitfProjectionFactory() { } ossimNitfProjectionFactory* ossimNitfProjectionFactory::instance() { if(!theInstance) {
ossimString ossimNetCdfReader::getLongName()const { return ossimString("ossim netcdf reader"); }
void ossimNitfProjectionFactory::parseUtmString(const ossimString& utmLocation, ossim_uint32& zone, std::vector<ossimDpt>& utmPoints)const { ossim_uint32 idx = 0; ossimString z; ossimString east; ossimString north; z = ossimString(utmLocation.begin() + idx, utmLocation.begin() + idx + 2); idx += 2; east = ossimString(utmLocation.begin() + idx, utmLocation.begin() + idx + 6); idx += 6; north = ossimString(utmLocation.begin() + idx, utmLocation.begin() + idx + 7); idx += 7; utmPoints.push_back(ossimDpt(east.toDouble(), north.toDouble())); z = ossimString(utmLocation.begin() + idx, utmLocation.begin() + idx + 2); idx += 2; east = ossimString(utmLocation.begin() + idx, utmLocation.begin() + idx + 6); idx += 6; north = ossimString(utmLocation.begin() + idx, utmLocation.begin() + idx + 7); idx += 7; utmPoints.push_back(ossimDpt(east.toDouble(), north.toDouble())); z = ossimString(utmLocation.begin() + idx, utmLocation.begin() + idx + 2); idx += 2; east = ossimString(utmLocation.begin() + idx, utmLocation.begin() + idx + 6); idx += 6; north = ossimString(utmLocation.begin() + idx, utmLocation.begin() + idx + 7); idx += 7; utmPoints.push_back(ossimDpt(east.toDouble(), north.toDouble())); z = ossimString(utmLocation.begin() + idx, utmLocation.begin() + idx + 2); idx += 2; east = ossimString(utmLocation.begin() + idx, utmLocation.begin() + idx + 6); idx += 6; north = ossimString(utmLocation.begin() + idx, utmLocation.begin() + idx + 7); idx += 7; utmPoints.push_back(ossimDpt(east.toDouble(), north.toDouble())); zone = z.toUInt32(); }
ossimString ossimNetCdfReader::getClassName()const { return ossimString("ossimNetCdfReader"); }
//***************************************************************************** // PROTECTED METHOD: ossimQuickbirdMetaData::parseMetaData() // // Parses the Quickbird IMD file. // //***************************************************************************** bool ossimQuickbirdMetaData::parseMetaData(const ossimFilename& data_file) { if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimQuickbirdMetaData::parseMetaData(data_file): entering..." << std::endl; if( !data_file.exists() ) { if (traceExec()) ossimNotify(ossimNotifyLevel_WARN) << "ossimQuickbirdMetaData::parseMetaData(data_file) WARN:" << "\nmetadate data file <" << data_file << ">. " << "doesn't exist..." << std::endl; return false; } FILE* fptr = fopen (data_file, "r"); if (!fptr) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimQuickbirdRpcModel::parseMetaData(data_file) DEBUG:" << "\nCould not open Meta data file: " << data_file << "\nreturning with error..." << std::endl; } return false; } char* strptr(NULL); //--- // Read the file into a buffer: //--- ossim_int32 fileSize = static_cast<ossim_int32>(data_file.fileSize()); char* filebuf = new char[fileSize]; fread(filebuf, 1, fileSize, fptr); strptr = filebuf; fclose(fptr); ossimString temp; //--- // Generation time: //--- if(getEndOfLine( strptr, ossimString("\ngenerationTime ="), "%17c %s", temp)) theGenerationDate = ossimString(temp).before(";"); else { if(traceDebug()) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): " << "\n\tAborting construction. Error encountered parsing " << "presumed meta-data file." << std::endl; delete [] filebuf; return false; } } // Number of rows and columns in full image: if(getEndOfLine( strptr, ossimString("\nnumRows ="), "%10c %s", temp)) theImageSize.line = ossimString(temp).before("\";").toInt(); if(getEndOfLine( strptr, ossimString("\nnumColumns ="), "%13c %s", temp)) theImageSize.samp = ossimString(temp).before("\";").toInt(); //--- // BandId: //--- if(getEndOfLine( strptr, ossimString("\nbandId ="), "%9c %s", temp)) theBandId = ossimString(temp).after("\"").before("\";"); else { if(traceDebug()) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): " << "\n\tAborting construction. Error encountered parsing " << "presumed meta-data file." << std::endl; delete [] filebuf; return false; } } //--- // BitsPerPixel: //--- if(getEndOfLine( strptr, ossimString("\nbitsPerPixel = "), "%16c %s", temp)) theBitsPerPixel = ossimString(temp).before(";").toInt(); else { if(traceDebug()) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): " << "\n\tAborting construction. Error encountered parsing " << "presumed meta-data file." << std::endl; delete [] filebuf; return false; } } //--- // absCalFactors: //--- char *iter = (char *)filebuf; unsigned int nbBand = 0; theBandNameList = ""; for(iter = strstr(iter, "BEGIN_GROUP = BAND_"); iter ; iter = strstr(iter, "BEGIN_GROUP = BAND_")) { ++nbBand; char dummy[80], nameChar[80]; sscanf(iter, "%19c %s", dummy, nameChar); ossimString bandCur = ossimString(nameChar).before("\n"); theBandNameList = theBandNameList + bandCur + " "; ++iter; } theBandNameList.trim(); //--- Multispectral if(theBandId=="Multi") { std::vector<ossimString> bandList; bandList = theBandNameList.split(" "); theAbsCalFactors = std::vector<double>(bandList.size(), 1.); for(unsigned int j=0; j<bandList.size(); j++) { ossimString begin_group = "BEGIN_GROUP = BAND_" + bandList[j]; strptr = strstr(filebuf, begin_group.c_str()); if(!strptr && traceDebug()) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): " << "\n\tAborting construction. Error encountered parsing " << "presumed meta-data file." << std::endl; delete [] filebuf; return false; } else { char dummy[80], nameChar[80]; sscanf(strptr, "%19c %s", dummy, nameChar); ossimString bandCur = ossimString(nameChar).before("\n"); if(!strptr && traceDebug()) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): " << "\n\tAborting construction. Error encountered parsing " << "presumed meta-data file." << std::endl; delete [] filebuf; return false; } else { if(bandList[j] == bandCur) { strptr = strstr(strptr, "\tabsCalFactor = "); sscanf(strptr, "%16c %s", dummy, nameChar); theAbsCalFactors[j] = ossimString(nameChar).before(";").toDouble(); } } } } } //--- Panchromatic else { theAbsCalFactors = std::vector<double>(1, 1.); if(getEndOfLine( strptr, ossimString("\tabsCalFactor = "), "%16c %s", temp)) theAbsCalFactors[0] = ossimString(temp).before(";").toDouble(); else { if(traceDebug()) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): " << "\n\tAborting construction. Error encountered parsing " << "presumed meta-data file." << std::endl; delete [] filebuf; return false; } } } //--- // SatID: //--- if(getEndOfLine( strptr, ossimString("\n\tsatId ="), "%9c %s", temp)) theSatID = ossimString(temp).after("\"").before("\";"); else { if(traceDebug()) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): " << "\n\tAborting construction. Error encountered parsing " << "presumed meta-data file." << std::endl; delete [] filebuf; return false; } } //--- // TLCTime: //--- if(getEndOfLine( strptr, ossimString("\n\tTLCTime ="), "%11c %s", temp)) theTLCDate = ossimString(temp).before("\";"); else { if(getEndOfLine( strptr, ossimString("\n\tfirstLineTime ="), "%17c %s", temp)) theTLCDate = ossimString(temp).before("\";"); else { if(traceDebug()) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): " << "\n\tAborting construction. Error encountered parsing " << "presumed meta-data file." << std::endl; delete [] filebuf; return false; } } } //--- // Sun Azimuth: //--- if(getEndOfLine( strptr, ossimString("\n\tsunAz ="), "%9c %s", temp)) theSunAzimuth = ossimString(temp).before(";").toFloat64(); else { if(getEndOfLine( strptr, ossimString("\n\tmeanSunAz ="), "%13c %s", temp)) theSunAzimuth = ossimString(temp).before(";").toFloat64(); else { if(traceDebug()) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): " << "\n\tAborting construction. Error encountered parsing " << "presumed meta-data file." << std::endl; delete [] filebuf; return false; } } } //--- // Sun Elevation: //--- if(getEndOfLine( filebuf, ossimString("\n\tsunEl ="), "%9c %s", temp)) theSunElevation = ossimString(temp).before(";").toFloat64(); else { if(getEndOfLine( filebuf, ossimString("\n\tmeanSunEl ="), "%13c %s", temp)) theSunElevation = ossimString(temp).before(";").toFloat64(); else { if(traceDebug()) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): " << "\n\tAborting construction. Error encountered parsing " << "presumed meta-data file." << std::endl; delete [] filebuf; return false; } } } //--- // Sun Azimuth: //--- if(getEndOfLine( strptr, ossimString("\n\tsunAz ="), "%9c %s", temp)) theSunAzimuth = ossimString(temp).before(";").toFloat64(); else { if(getEndOfLine( strptr, ossimString("\n\tmeanSunAz ="), "%13c %s", temp)) theSunAzimuth = ossimString(temp).before(";").toFloat64(); else { if(traceDebug()) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): " << "\n\tAborting construction. Error encountered parsing " << "presumed meta-data file." << std::endl; delete [] filebuf; return false; } } } //--- // Sun Elevation: //--- if(getEndOfLine( filebuf, ossimString("\n\tsunEl ="), "%9c %s", temp)) theSunElevation = ossimString(temp).before(";").toFloat64(); else { if(getEndOfLine( filebuf, ossimString("\n\tmeanSunEl ="), "%13c %s", temp)) theSunElevation = ossimString(temp).before(";").toFloat64(); else { if(traceDebug()) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): " << "\n\tAborting construction. Error encountered parsing " << "presumed meta-data file." << std::endl; delete [] filebuf; return false; } } } //--- // Sat Azimuth: //--- if(getEndOfLine( strptr, ossimString("\n\tsatAz ="), "%9c %s", temp)) theSatAzimuth = ossimString(temp).before(";").toFloat64(); else { if(getEndOfLine( strptr, ossimString("\n\tmeanSatAz ="), "%13c %s", temp)) theSatAzimuth = ossimString(temp).before(";").toFloat64(); else { if(traceDebug()) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): " << "\n\tAborting construction. Error encountered parsing " << "presumed meta-data file." << std::endl; delete [] filebuf; return false; } } } //--- // Sat Elevation: //--- if(getEndOfLine( filebuf, ossimString("\n\tsatEl ="), "%9c %s", temp)) theSatElevation = ossimString(temp).before(";").toFloat64(); else { if(getEndOfLine( filebuf, ossimString("\n\tmeanSatEl ="), "%13c %s", temp)) theSatElevation = ossimString(temp).before(";").toFloat64(); else { if(traceDebug()) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): " << "\n\tAborting construction. Error encountered parsing " << "presumed meta-data file." << std::endl; delete [] filebuf; return false; } } } //--- // TDILevel: //--- if(getEndOfLine( strptr, ossimString("\n\tTDILevel = "), "%13c %s", temp)) theTDILevel = ossimString(temp).before(";").toInt(); else { if(traceDebug()) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimQuickbirdRpcModel::parseMetaData(data_file): " << "\n\tAborting construction. Error encountered parsing " << "presumed meta-data file." << std::endl; delete [] filebuf; return false; } } delete [] filebuf; filebuf = 0; if (traceExec()) { ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimQuickbirdRpcModel::parseMetaData(data_file): returning..." << std::endl; } return true; }
void runTestForFileVariations() { std::cout << "------------------ Running tests on different file variations ---------------- \n"; ossimTempFilename tempFile(".", "temp","txt",true,false); tempFile.generateRandomFile(); { std::ofstream out(tempFile.c_str()); out<< ""; out.close(); ossimKeywordlist kwl; std::cout << "Empty File Test? "; if(kwl.addFile(tempFile)) { std::cout << "passed" << std::endl; } else { std::cout << "failed" << std::endl; } } { ossimTempFilename tempFileDos(".", "tempDos","txt",true,false); tempFileDos.generateRandomFile(); std::ofstream outUnix(tempFile.c_str()); std::ofstream outDos(tempFileDos.c_str()); outUnix<< "key1: value1\n"; outUnix<< "key2: value2\n"; outUnix<< "key3: value3\n"; outUnix<< "key4: value4\n"; outUnix<< "key5: value5\n"; outUnix.close(); outDos<< "key1: value1\r"; outDos<< "key2: value2\r"; outDos<< "key3: value3\r"; outDos<< "key4: value4\r"; outDos<< "key5: value5\r"; outDos.close(); ossimKeywordlist kwlUnix; ossimKeywordlist kwlDos; std::cout << "Dos carriage returns and unix returns? "; if((kwlUnix.addFile(tempFile)&&kwlDos.addFile(tempFileDos))&& (kwlUnix.getMap() == kwlDos.getMap())) { std::cout << "passed" << std::endl; } else { std::cout << "failed" << std::endl; } } { std::ofstream out(tempFile.c_str()); out<< "/adfakdfhkadkjh\n"; out.close(); ossimKeywordlist kwl; std::cout << "bad comment? "; if(!kwl.addFile(tempFile)) { std::cout << "passed" << std::endl; } else { std::cout << "failed" << std::endl; } } { std::ofstream out(tempFile.c_str()); out<< "//adfakdfhkadkjh\n"; out.close(); ossimKeywordlist kwl; std::cout << "good comment? "; if(kwl.addFile(tempFile)) { std::cout << "passed" << std::endl; } else { std::cout << "failed" << std::endl; } } { std::ofstream out(tempFile.c_str()); out<< "//adfakdfhkadkjh"; out.close(); ossimKeywordlist kwl; std::cout << "good comment no end of line? "; if(kwl.addFile(tempFile)) { std::cout << "passed" << std::endl; } else { std::cout << "failed" << std::endl; } } { std::ofstream out(tempFile.c_str()); out<< "/test:"; out.close(); ossimKeywordlist kwl; std::cout << "----------- 1 token lookahead problem, single slash start of line with valid key but no value ------------ \n"; std::cout << "Accepted file? "; if(kwl.addFile(tempFile)) { std::cout << "passed" << std::endl; } else { std::cout << "failed" << std::endl; } std::cout << "Verify key? " << (kwl.find("/test")?"passed\n":"failed\n"); } { std::ofstream out(tempFile.c_str()); out<< "test :"; out.close(); std::cout << "----------- trailing spaces for key trimmed ------------ \n"; ossimKeywordlist kwl; std::cout << "Accepted file? "; if(kwl.addFile(tempFile)) { std::cout << "passed" << std::endl; } else { std::cout << "failed" << std::endl; } std::cout << "Verify key? " << (kwl.find("test")?"passed\n":"failed\n"); } { ossimKeywordlist kwl; ossimString value1 =" --leading and trailing--- "; ossimString value2 =" --trailing---"; ossimString value3 ="--leading--- "; kwl.add("","key1", value1); kwl.add("","key2", value2); kwl.add("","key3", value3); kwl.trimAllValues(); std::cout << "----------- Testing utility method trimAll values ------------ \n"; std::cout << "Verify value1? " << ((value1.trim() == ossimString(kwl.find("key1")))?"passed":"failed") << std::endl; std::cout << "Verify value2? " << ((value2.trim() == ossimString(kwl.find("key2")))?"passed":"failed") << std::endl; std::cout << "Verify value3? " << ((value3.trim() == ossimString(kwl.find("key3")))?"passed":"failed") << std::endl; } }
int main(int argc, char* argv[]) { static const char MODULE[] = "band_merge:main"; std::string tempString; ossimArgumentParser::ossimParameter stringParam(tempString); ossimArgumentParser argumentParser(&argc, argv); ossimInit::instance()->addOptions(argumentParser); ossimInit::instance()->initialize(argumentParser); argumentParser.getApplicationUsage()->setApplicationName(argumentParser.getApplicationName()); argumentParser.getApplicationUsage()->setDescription(argumentParser.getApplicationName()+" merges band separate images to one image"); argumentParser.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); argumentParser.getApplicationUsage()->addCommandLineOption("-o or --create-overiew", "Creates and overview for the output image"); argumentParser.getApplicationUsage()->addCommandLineOption("-w or --tile-width", "Defines the tile width for the handlers that support tiled output"); if (traceDebug()) CLOG << " Entered..." << std::endl; if (argumentParser.read("-h") || argumentParser.read("--help")||(argumentParser.argc() < 2)) { argumentParser.getApplicationUsage()->write(std::cout); usage(); // for writer output types exit(0); } // Keyword list to initialize image writers with. ossimKeywordlist kwl; const char* PREFIX = "imagewriter."; ossim_uint32 tile_width = 32; bool create_overview = false; if (argumentParser.read("-o") || argumentParser.read("--crate-overview")) { create_overview = true; std::cout << "\nOutput overview building enabled." << std::endl; } if (argumentParser.read("-w", stringParam) || argumentParser.read("-tile-width", stringParam)) { tile_width = ossimString(tempString).toInt(); if ((tile_width % 16) != 0) { cerr << MODULE << " NOTICE:" << "\nTile width must be a multiple of 16!" << "\nDefaulting to 128" << std::endl; tile_width = 0; } std::cout << "Tile width set to: " << tile_width << std::endl; } argumentParser.reportRemainingOptionsAsUnrecognized(); // Three required args: output_type, input file, and output file. if (argumentParser.errors()) { argumentParser.writeErrorMessages(std::cout); exit(0); } if (argumentParser.argc() == 1) { argumentParser.getApplicationUsage()->write(std::cout); usage(); // for writer output types exit(0); } ossim_uint32 number_of_source_images = argumentParser.argc() - 3; if (traceDebug()) { CLOG << "DEBUG:" << "\nargc: " << argumentParser.argc() << "\nnumber_of_source_images: " << number_of_source_images << "\ntile_width: " << tile_width << "\ncreate_overview: " << (create_overview?"true":"false") << std::endl; } ossimString output_type = argv[1]; output_type.downcase(); std::cout << "Output type: " << output_type << std::endl; // Create the vector of image handlers. ossimConnectableObject::ConnectableObjectList ihs; for(ossim_uint32 h = 0; h < number_of_source_images; ++h) { ossimFilename f = argv[h + 2]; std::cout << "Input_image[" << h << "]: " << f << std::endl; ihs.push_back(ossimImageHandlerRegistry::instance()->open(f)); } // Get the output file. ossimFilename output_file = argv[argumentParser.argc() - 1]; std::cout << "Output file: " << output_file << std::endl; //--- // Set the output writer type and the image type. //--- kwl.add(PREFIX, ossimKeywordNames::TYPE_KW, output_type.c_str()); ossimRefPtr<ossimBandMergeSource> bm = new ossimBandMergeSource(ihs); ossimRefPtr<ossimImageFileWriter> fileWriter = ossimImageWriterFactoryRegistry::instance()->createWriter(kwl, PREFIX); if(!fileWriter) { bm->disconnect(); bm = 0; ossimConnectableObject::ConnectableObjectList::iterator i = ihs.begin(); while (i != ihs.end()) { (*i)->disconnect(); (*i) = 0; ++i; } cerr << "Error making an image writer..." << "\nExiting application..." << std::endl; exit(1); } // Write out a geometry file for new image. ossimKeywordlist bm_geom; ossimRefPtr<ossimImageGeometry> geom = bm->getImageGeometry(); geom->saveState(bm_geom); ossimFilename geom_file = output_file; geom_file.setExtension("geom"); bm_geom.write(geom_file); fileWriter->connectMyInputTo(0, bm.get()); if (tile_width) { // Set the tile size... fileWriter->setTileSize(ossimIpt(tile_width, tile_width)); } fileWriter->open(output_file); ossimStdOutProgress prog(2); fileWriter->addListener(&prog); fileWriter->setAreaOfInterest(bm->getBoundingRect()); if( fileWriter->canCastTo("ossimTiffWriter") ) { // ossimTiffWriter* twriter = PTR_CAST(ossimTiffWriter, fileWriter); if(fileWriter.valid()) { try { fileWriter->execute(); } catch(std::exception& e) { ossimNotify(ossimNotifyLevel_DEBUG) << "band_merge: ERROR exception caught:\n" << e.what() << std::endl; } catch (...) { ossimNotify(ossimNotifyLevel_DEBUG) << "band_merge: ERROR - Unknown exception caught!" << std::endl; } } } else if(fileWriter->canCastTo("ossimJpegWriter")) { ossimRefPtr<ossimScalarRemapper> remapper = NULL; if(PTR_CAST(ossimJpegWriter, fileWriter.get()) && (bm->getOutputScalarType() != OSSIM_UCHAR)) { remapper = new ossimScalarRemapper(bm.get(), OSSIM_UCHAR); remapper->initialize(); fileWriter->connectMyInputTo(0, remapper.get()); } fileWriter->initialize(); try { fileWriter->execute(); } catch(std::exception& e) { ossimNotify(ossimNotifyLevel_DEBUG) << "band_merge: ERROR exception caught:\n" << e.what() << std::endl; } catch (...) { ossimNotify(ossimNotifyLevel_DEBUG) << "band_merge: ERROR - Unknown exception caught!" << std::endl; } } else { try { fileWriter->execute(); } catch(std::exception& e) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "band_merge: ERROR exception caught:\n" << e.what() << std::endl; } } catch (...) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "band_merge: ERROR - Unknown exception caught!" << std::endl; } } } if (create_overview == true) { fileWriter->writeOverviewFile(); } fileWriter->disconnect(); fileWriter = 0; bm = 0; ossimConnectableObject::ConnectableObjectList::iterator it = ihs.begin(); while (it != ihs.end()) { (*it)->disconnect(); (*it) = 0; ++it; } exit(0); }
bool ImageNoise::loadState(const ossimKeywordlist& kwl, const char* prefix) { static const char MODULE[] = "ImageNoise::loadState"; bool result = true; std::string pfx; std::string pfx2; if (prefix) { pfx = prefix; } ossimString s; const char* lookup = 0; pfx += PREFIX; lookup = kwl.find(pfx.c_str(), TIME_UTC); if (lookup) { s = lookup; _timeUTC = s; } else { ossimNotify(ossimNotifyLevel_WARN) << MODULE << " Keyword not found: " << TIME_UTC << " in "<<pfx.c_str()<<" path.\n"; result = false; } pfx2 = pfx + NOISE_ESTIMATE; lookup = kwl.find(pfx2.c_str(), VALIDITY_RANGE_MIN); if (lookup) { s = lookup; _validityRangeMin = s.toDouble(); } else { ossimNotify(ossimNotifyLevel_WARN) << MODULE << " Keyword not found: " << VALIDITY_RANGE_MIN << " in "<<pfx2.c_str()<<" path.\n"; result = false; } lookup = kwl.find(pfx2.c_str(), VALIDITY_RANGE_MAX); if (lookup) { s = lookup; _validityRangeMax = s.toDouble(); } else { ossimNotify(ossimNotifyLevel_WARN) << MODULE << " Keyword not found: " << VALIDITY_RANGE_MAX << " in "<<pfx2.c_str()<<" path\n"; result = false; } lookup = kwl.find(pfx2.c_str(), REFERENCE_POINT); if (lookup) { s = lookup; _referencePoint = s.toDouble(); } else { ossimNotify(ossimNotifyLevel_WARN) << MODULE << " Keyword not found: " << REFERENCE_POINT << " in "<<pfx2.c_str()<<" path\n"; result = false; } lookup = kwl.find(pfx2.c_str(), POLYNOMIAL_DEGREE); if (lookup) { s = lookup; _polynomialDegree = s.toInt32(); } else { ossimNotify(ossimNotifyLevel_WARN) << MODULE << " Keyword not found: " << POLYNOMIAL_DEGREE << " in "<<pfx2.c_str()<<" path\n"; result = false; } for(unsigned int i=0 ; i<_polynomialDegree+1;i++) { ossimString iStr = ossimString::toString(i); ossimString kw = ossimString(COEFFICIENT) + "["+iStr+ "]"; lookup = kwl.find(pfx2.c_str(), kw.c_str()); if (lookup) { s = lookup; _polynomialCoefficients.push_back( s.toDouble() ); } else { ossimNotify(ossimNotifyLevel_WARN) << MODULE << " Keyword not found: " << kw.c_str() << " in "<<pfx2.c_str()<<" path\n"; result = false; } } /* pfx += "ImageNoise."; 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); _speed[0] = pt.x; _speed[1] = pt.y; _speed[2] = pt.z; } else { ossimNotify(ossimNotifyLevel_WARN) << MODULE << " Keyword not found: " << VELOCITY_KW << "\n"; result = false; } */ return result; }
ossimString ossimNitfRsmecaTag::getUrr() const { return ossimString(m_urr); }
ossim_int32 ossimNitfTextInfoRecordV2_0::getHeaderLength()const { return ossimString(theTextSubheaderLength).toInt32(); }