//************************************************************************************************* //! Parses a tagged TIFF image file for RPC info. Returns TRUE if successful. //************************************************************************************************* bool rspfQuickbirdRpcModel::parseTiffFile(const rspfFilename& file) { setErrorStatus(); // Make the gsd nan so it gets computed. theGSD.makeNan(); rspfFilename tiffFile = file; rspfRefPtr<rspfTiffTileSource> tiff = new rspfTiffTileSource(); if (!tiff->open(file)) { return false; } theImageClipRect = tiff->getImageRectangle(); parseMetaData(file); if (!parseRpcData(file)) return false; if (!parseTileData(file)) return false; finishConstruction(); clearErrorStatus(); return true; }
//************************************************************************************************* //! Constructor for multiple tile-files sharing common RPC model initializes given pointer //! to multi-tile-files handler. //************************************************************************************************* rspfQuickbirdRpcModel::rspfQuickbirdRpcModel(const rspfQbTileFilesHandler* handler) : rspfRpcModel(), theSupportData(new rspfQuickbirdMetaData()) { setErrorStatus(); if (!handler) return; // Make the gsd nan so it gets computed. theGSD.makeNan(); theImageClipRect = handler->getImageRectangle(); rspfFilename imageFile = handler->getFilename(); if (!parseRpcData(imageFile)) return; //loong if(!theSupportData->open(imageFile)) return; finishConstruction(); clearErrorStatus(); return; }
void ossimAtCorrRemapper::initialize() { if(theInputConnection) { theTile = ossimImageDataFactory::instance()->create(this, theInputConnection); theTile->initialize(); if(theSurfaceReflectance) { delete []theSurfaceReflectance; theSurfaceReflectance = NULL; } ossim_uint32 tw = theTile->getWidth(); ossim_uint32 th = theTile->getHeight(); ossim_uint32 bands = theTile->getNumberOfBands(); ossim_uint32 size = tw*th*bands; if (traceDebug()) { cout << "ossimAtCorrRemapper::initialize DEBUG:" << "\ntile width: " << tw << "\ntile height: " << th << "\nbands: " << bands << "\nBuffer size: " << size << endl; } theSurfaceReflectance = new double[size]; setInitializedFlag(true); clearErrorStatus(); } else { setInitializedFlag(false); setErrorStatus(); }; verifyEnabled(); if (traceDebug()) { cout << "ossimAtCorrRemapper::initialize DEBUG:" << *this << endl; } }
void ossimDtedVol::parse(std::istream& in) { clearErrorStatus(); theStartOffset = in.tellg(); theStopOffset = theStartOffset; // Parse theRecSen in.read(theRecSen, FIELD1_SIZE); theRecSen[FIELD1_SIZE] = '\0'; if(!(strncmp(theRecSen, "VOL", 3) == 0)) { // Not a volume header label. theErrorStatus = ossimErrorCodes::OSSIM_ERROR; in.seekg(theStartOffset); return; } // Parse Field 2 in.read(theField2, FIELD2_SIZE); theField2[FIELD2_SIZE] = '\0'; // Parse theReelNumber in.read(theReelNumber, FIELD3_SIZE); theReelNumber[FIELD3_SIZE] = '\0'; // Parse Field 4 in.read(theField4, FIELD4_SIZE); theField4[FIELD4_SIZE] = '\0'; // Parse Field 5 in.read(theField5, FIELD5_SIZE); theField5[FIELD5_SIZE] = '\0'; // Parse theAccountNumber in.read(theAccountNumber, FIELD6_SIZE); theAccountNumber[FIELD6_SIZE] = '\0'; // Parse Field 7 in.read(theField7, FIELD7_SIZE); theField7[FIELD7_SIZE] = '\0'; // Parse Field 8 in.read(theField8, FIELD8_SIZE); theField8[FIELD8_SIZE] = '\0'; // Set the stop offset. theStopOffset = theStartOffset + VOL_LENGTH; }
//************************************************************************************************* //! Constructor for multiple tile-files sharing common RPC model initializes given pointer //! to multi-tile-files handler. //************************************************************************************************* ossimQuickbirdRpcModel::ossimQuickbirdRpcModel(const ossimQbTileFilesHandler* handler) : ossimRpcModel(), theSupportData(0) { setErrorStatus(); if (!handler) return; // Make the gsd nan so it gets computed. theGSD.makeNan(); theImageClipRect = handler->getImageRectangle(); ossimFilename imageFile = handler->getFilename(); if (!parseRpcData(imageFile)) return; finishConstruction(); clearErrorStatus(); return; }
void ofxStateMachine<T>::setState(T newState, bool clearErrors){ float timeInPrevState = stateTime; if(!isSetup){ isSetup = true; ofAddListener(ofEvents().update, this, &ofxStateMachine::update); } if(clearErrors){ stateTime = waitTime = 0.0f; clearErrorStatus(); } if(firstState){ prevState = state = newState; firstState = false; } prevState = state; state = newState; StateChangedEventArgs eventArgs = {prevState, state, timeInPrevState}; ofNotifyEvent(eventStateChanged, eventArgs, this); }
bool rspfSrtmHandler::open(const rspfFilename& file, bool memoryMapFlag) { theFilename = file; clearErrorStatus(); if (!m_supportData.setFilename(file, false) ) { theErrorStatus = rspfErrorCodes::RSPF_ERROR; return false; } if(m_swapper) {delete m_swapper;m_swapper=0;} m_scalarType = m_supportData.getScalarType(); // SRTM is stored in big endian. if ( rspf::byteOrder() == RSPF_LITTLE_ENDIAN) { m_swapper = new rspfEndian(); } m_streamOpen = false; m_numberOfLines = m_supportData.getNumberOfLines(); m_numberOfSamples = m_supportData.getNumberOfSamples(); m_srtmRecordSizeInBytes = m_numberOfSamples * rspf::scalarSizeInBytes(m_scalarType); m_latSpacing = m_supportData.getLatitudeSpacing(); m_lonSpacing = m_supportData.getLongitudeSpacing(); m_nwCornerPost.lon = m_supportData.getSouthwestLongitude(); m_nwCornerPost.lat = m_supportData.getSouthwestLatitude()+1.0; m_scalarType = m_supportData.getScalarType(); theGroundRect = rspfGrect(rspfGpt(m_nwCornerPost.lat, m_nwCornerPost.lon, 0.0), rspfGpt(m_nwCornerPost.lat-1.0, m_nwCornerPost.lon+1.0, 0.0)); theMeanSpacing = (m_latSpacing*rspfGpt().metersPerDegree().y); // Set the base class null height value. theNullHeightValue = -32768.0; m_fileStr.clear(); m_fileStr.open(theFilename.c_str(), std::ios::in | std::ios::binary); if(!m_fileStr) { return false; } if(memoryMapFlag) { m_memoryMap.resize(theFilename.fileSize()); m_fileStr.read((char*)&m_memoryMap.front(), (streamsize)m_memoryMap.size()); m_fileStr.close(); } m_streamOpen = true; // Capture the stream state for non-const is_open on old compiler. return m_streamOpen; #if 0 // theMinHeightAboveMSL; // theMaxHeightAboveMSL; if(theFileStr.valid()) { if(!m_fileStr.fail()) { return true; } } theFileStr = 0; theFileStr = rspfStreamFactoryRegistry::instance()->createNewIFStream(theFilename, std::ios::in | std::ios::binary); if(theFileStr.valid()) { return (!m_fileStr.fail()); } return false; #endif }
//************************************************************************** // ossimDtedUhl::parse() //************************************************************************** void ossimDtedUhl::parse(std::istream& in) { clearErrorStatus(); theStartOffset = in.tellg(); theStopOffset = theStartOffset; // Parse theRecSen in.read(theRecSen, FIELD1_SIZE); theRecSen[FIELD1_SIZE] = '\0'; if(!(strncmp(theRecSen, "UHL", 3) == 0)) { // Not a user header label. theErrorStatus = ossimErrorCodes::OSSIM_ERROR; in.seekg(theStartOffset); return; } // Parse Field 2 in.read(theField2, FIELD2_SIZE); theField2[FIELD2_SIZE] = '\0'; // Parse theLonOrigin in.read(theLonOrigin, FIELD3_SIZE); theLonOrigin[FIELD3_SIZE] = '\0'; // Parse theLatOrigin in.read(theLatOrigin, FIELD4_SIZE); theLatOrigin[FIELD4_SIZE] = '\0'; // Parse theLonInterval in.read(theLonInterval, FIELD5_SIZE); theLonInterval[FIELD5_SIZE] = '\0'; // Parse theLatInterval in.read(theLatInterval, FIELD6_SIZE); theLatInterval[FIELD6_SIZE] = '\0'; // Parse theAbsoluteLE in.read(theAbsoluteLE, FIELD7_SIZE); theAbsoluteLE[FIELD7_SIZE] = '\0'; // Parse theSecurityCode in.read(theSecurityCode, FIELD8_SIZE); theSecurityCode[FIELD8_SIZE] = '\0'; // Parse Field 9 in.read(theField9, FIELD9_SIZE); theField9[FIELD9_SIZE] = '\0'; // Parse theNumLonLines in.read(theNumLonLines, FIELD10_SIZE); theNumLonLines[FIELD10_SIZE] = '\0'; // Parse theNumLatPoints in.read(theNumLatPoints, FIELD11_SIZE); theNumLatPoints[FIELD11_SIZE] = '\0'; // Parse theMultipleAccuracy in.read(theMultipleAccuracy, FIELD12_SIZE); theMultipleAccuracy[FIELD12_SIZE] = '\0'; // Field 13 not parsed as it's unused. in.ignore(FIELD13_SIZE); // Set the stop offset. theStopOffset = theStartOffset + UHL_LENGTH; }
//************************************************************************************************* //! Parses a NITF image file for RPC info. Returns TRUE if successful. //************************************************************************************************* bool rspfQuickbirdRpcModel::parseNitfFile(const rspfFilename& file) { setErrorStatus(); rspfFilename nitfFile = file; rspfRefPtr<rspfNitfFile> nitfFilePtr = new rspfNitfFile; if(!nitfFilePtr->parseFile(nitfFile)) { nitfFile = nitfFile.setExtension("NTF"); if(!nitfFilePtr->parseFile(nitfFile)) { nitfFile = nitfFile.setExtension("ntf"); if(!nitfFilePtr->parseFile(nitfFile)) return false; } } rspfRefPtr<rspfNitfImageHeader> ih = nitfFilePtr->getNewImageHeader(0); if (!ih) return false; theImageClipRect = ih->getImageRect(); // Give preference to external RPC data file: bool useInternalRpcTags = false; if(!parseRpcData(file)) useInternalRpcTags = true; if (!parseTileData(file)) return false; // Check for IMD (metadata) file: parseMetaData(file); // Get the gsd. theGSD.line = rspf::nan(); theGSD.samp = rspf::nan(); rspfRefPtr<rspfNitfRegisteredTag> tag; tag = ih->getTagData(PIAIMC_TAG); if (tag.valid()) { rspfNitfPiaimcTag* p = PTR_CAST(rspfNitfPiaimcTag, tag.get()); if (p) { theGSD.line = p->getMeanGsdInMeters(); theGSD.samp = theGSD.line; } } if (rspf::isnan(theGSD.line)) { tag = ih->getTagData(USE00A_TAG); if (tag.valid()) { rspfNitfUse00aTag* p = PTR_CAST(rspfNitfUse00aTag, tag.get()); if (p) { theGSD.line = p->getMeanGsdInMeters(); theGSD.samp = theGSD.line; } } } // If external RPC data file was correctly parsed, then we can bypass this code block. Otherwise // need to parse internal NITF tags for RPC data: if (useInternalRpcTags) { // Get the the RPC tag: rspfNitfRpcBase* rpcTag = NULL; // Look for the RPC00B tag first. tag = ih->getTagData(RPC00B_TAG); if (tag.valid()) rpcTag = PTR_CAST(rspfNitfRpcBase, tag.get()); if (!tag.valid()) { // Look for RPC00A tag. tag = ih->getTagData(RPC00A_TAG); if (tag.valid()) rpcTag = PTR_CAST(rspfNitfRpcBase, tag.get()); } if (!rpcTag) return false; // Set the polynomial type. if (rpcTag->getRegisterTagName() == "RPC00B") thePolyType = B; else thePolyType = A; // Parse coefficients: for (rspf_uint32 i=0; i<20; ++i) { theLineNumCoef[i] = rpcTag->getLineNumeratorCoeff(i).toFloat64(); theLineDenCoef[i] = rpcTag->getLineDenominatorCoeff(i).toFloat64(); theSampNumCoef[i] = rpcTag->getSampleNumeratorCoeff(i).toFloat64(); theSampDenCoef[i] = rpcTag->getSampleDenominatorCoeff(i).toFloat64(); } // Initialize other items in tags: theLineScale = rpcTag->getLineScale().toFloat64(); theSampScale = rpcTag->getSampleScale().toFloat64(); theLatScale = rpcTag->getGeodeticLatScale().toFloat64(); theLonScale = rpcTag->getGeodeticLonScale().toFloat64(); theHgtScale = rpcTag->getGeodeticHeightScale().toFloat64(); theLineOffset = rpcTag->getLineOffset().toFloat64(); theSampOffset = rpcTag->getSampleOffset().toFloat64(); theLatOffset = rpcTag->getGeodeticLatOffset().toFloat64(); theLonOffset = rpcTag->getGeodeticLonOffset().toFloat64(); theHgtOffset = rpcTag->getGeodeticHeightOffset().toFloat64(); theImageID = ih->getImageId(); } finishConstruction(); clearErrorStatus(); return true; }
ofxStateMachine<T>::ofxStateMachine(){ stateTime = waitTime = 0.0f; firstState = true; clearErrorStatus(); isSetup = false; }
//************************************************************************** // ossimDtedHdr::parse() //************************************************************************** void ossimDtedHdr::parse(std::istream& in) { clearErrorStatus(); theStartOffset = in.tellg(); theStopOffset = theStartOffset; // Parse theRecSen in.read(theRecSen, FIELD1_SIZE); theRecSen[FIELD1_SIZE] = '\0'; if(!(strncmp(theRecSen, "HDR", 3) == 0)) { theErrorStatus = ossimErrorCodes::OSSIM_ERROR; in.seekg(theStartOffset); return; } // Parse Field 2 in.read(theField2, FIELD2_SIZE); theField2[FIELD2_SIZE] = '\0'; // Parse theFilename in.read(theFilename, FIELD3_SIZE); theFilename[FIELD3_SIZE] = '\0'; // Parse Field 4 in.read(theField4, FIELD4_SIZE); theField4[FIELD4_SIZE] = '\0'; // Parse Field 5 in.read(theField5, FIELD5_SIZE); theField5[FIELD5_SIZE] = '\0'; // Parse Field 6 in.read(theField6, FIELD6_SIZE); theField6[FIELD6_SIZE] = '\0'; // Parse Field 7 in.read(theVersion, FIELD7_SIZE); theVersion[FIELD7_SIZE] = '\0'; // Parse theCreationDate in.read(theCreationDate, FIELD8_SIZE); theCreationDate[FIELD8_SIZE] = '\0'; // Parse Field 9 in.read(theField9, FIELD9_SIZE); theField9[FIELD9_SIZE] = '\0'; // Parse Field 10 in.read(theField10, FIELD10_SIZE); theField10[FIELD10_SIZE] = '\0'; // Parse Field 11 in.read(theField11, FIELD11_SIZE); theField11[FIELD11_SIZE] = '\0'; // Parse Field 12 in.read(theField12, FIELD12_SIZE); theField12[FIELD12_SIZE] = '\0'; // Parse Field 13 in.read(theField13, FIELD13_SIZE); theField13[FIELD13_SIZE] = '\0'; // Parse Field 14 in.read(theField14, FIELD14_SIZE); theField14[FIELD14_SIZE] = '\0'; // Set the stop offset. theStopOffset = theStartOffset + HDR_LENGTH; }
void ossimDtedDsi::parse(std::istream& in) { clearErrorStatus(); theStartOffset = in.tellg(); theStopOffset = theStartOffset; char tmp_chars[26]; // For blank field reads. // Seek to the start of the record. in.seekg(theStartOffset, std::ios::beg); // Parse theRecSen in.read(theRecSen, FIELD1_SIZE); theRecSen[FIELD1_SIZE] = '\0'; if(!(strncmp(theRecSen, "DSI", 3) == 0)) { theErrorStatus = ossimErrorCodes::OSSIM_ERROR; in.seekg(theStartOffset); return; } // Parse theSecurityCode in.read(theSecurityCode, FIELD2_SIZE); theSecurityCode[FIELD2_SIZE] = '\0'; // Parse Field 3 in.read(theField3, FIELD3_SIZE); theField3[FIELD3_SIZE] = '\0'; // Parse Field 4 in.read(theField4, FIELD4_SIZE); theField4[FIELD4_SIZE] = '\0'; // Parse Field 5 (currently blank) in.read(tmp_chars, FIELD5_SIZE); // Parse theProductLevel in.read(theProductLevel, FIELD6_SIZE); theProductLevel[FIELD6_SIZE] = '\0'; // Parse Field 7 in.read(theField7, FIELD7_SIZE); theField7[FIELD7_SIZE] = '\0'; // Parse Field 8 in.read(theField8, FIELD8_SIZE); theField8[FIELD8_SIZE] = '\0'; // Parse theEdition in.read(theEdition, FIELD9_SIZE); theEdition[FIELD9_SIZE] = '\0'; // Parse theMatchMergeVersion in.read(theMatchMergeVersion, FIELD10_SIZE); theMatchMergeVersion[FIELD10_SIZE] = '\0'; // Parse theMaintenanceDate in.read(theMaintenanceDate, FIELD11_SIZE); theMaintenanceDate[FIELD11_SIZE] = '\0'; // Parse theMatchMergeDate in.read(theMatchMergeDate, FIELD12_SIZE); theMatchMergeDate[FIELD12_SIZE] = '\0'; // Parse theMaintenanceCode in.read(theMaintenanceCode, FIELD13_SIZE); theMaintenanceCode[FIELD13_SIZE] = '\0'; // Parse theProducerCode in.read(theProducerCode, FIELD14_SIZE); theProducerCode[FIELD14_SIZE] = '\0'; // Parse Field 15 in.read(theField15, FIELD15_SIZE); theField15[FIELD15_SIZE] = '\0'; // Parse theProductStockSpecNumber in.read(theProductStockSpecNumber, FIELD16_SIZE); theProductStockSpecNumber[FIELD16_SIZE] = '\0'; // Parse theProductSpecNumber in.read(theProductSpecNumber, FIELD17_SIZE); theProductSpecNumber[FIELD17_SIZE] = '\0'; // Parse theProductSpecDate in.read(theProductSpecDate, FIELD18_SIZE); theProductSpecDate[FIELD18_SIZE] = '\0'; // Parse theVerticalDatum in.read(theVerticalDatum, FIELD19_SIZE); theVerticalDatum[FIELD19_SIZE] = '\0'; // Parse theHorizontalDatum in.read(theHorizontalDatum, FIELD20_SIZE); theHorizontalDatum[FIELD20_SIZE] = '\0'; // Parse Field 21 in.read(theField21, FIELD21_SIZE); theField21[FIELD21_SIZE] = '\0'; // Parse theCompilationDate in.read(theCompilationDate, FIELD22_SIZE); theCompilationDate[FIELD22_SIZE] = '\0'; // Parse Field 23 in.read(theField23, FIELD23_SIZE); theField23[FIELD23_SIZE] = '\0'; // Parse theLatOrigin in.read(theLatOrigin, FIELD24_SIZE); theLatOrigin[FIELD24_SIZE] = '\0'; // Parse theLonOrigin in.read(theLonOrigin, FIELD25_SIZE); theLonOrigin[FIELD25_SIZE] = '\0'; // Parse theLatSW in.read(theLatSW, FIELD26_SIZE); theLatSW[FIELD26_SIZE] = '\0'; // Parse theLonSW in.read(theLonSW, FIELD27_SIZE); theLonSW[FIELD27_SIZE] = '\0'; // Parse theLatNW in.read(theLatNW, FIELD28_SIZE); theLatNW[FIELD28_SIZE] = '\0'; // Parse theLonNW in.read(theLonNW, FIELD29_SIZE); theLonNW[FIELD29_SIZE] = '\0'; // Parse theLatNE in.read(theLatNE, FIELD30_SIZE); theLatNE[FIELD30_SIZE] = '\0'; // Parse theLonNE in.read(theLonNE, FIELD31_SIZE); theLonNE[FIELD31_SIZE] = '\0'; // Parse theLatSE in.read(theLatSE, FIELD32_SIZE); theLatSE[FIELD32_SIZE] = '\0'; // Parse theLonSE in.read(theLonSE, FIELD33_SIZE); theLonSE[FIELD33_SIZE] = '\0'; // Parse theOrientation in.read(theOrientation, FIELD34_SIZE); theOrientation[FIELD34_SIZE] = '\0'; // Parse theLatInterval in.read(theLatInterval, FIELD35_SIZE); theLatInterval[FIELD35_SIZE] = '\0'; // Parse theLonInterval in.read(theLonInterval, FIELD36_SIZE); theLonInterval[FIELD36_SIZE] = '\0'; // Parse theNumLatPoints in.read(theNumLatPoints, FIELD37_SIZE); theNumLatPoints[FIELD37_SIZE] = '\0'; // Parse theNumLonLines in.read(theNumLonLines, FIELD38_SIZE); theNumLonLines[FIELD38_SIZE] = '\0'; // Parse theCellIndicator in.read(theCellIndicator, FIELD39_SIZE); theCellIndicator[FIELD39_SIZE] = '\0'; // Parse Field 40 in.read(theField40, FIELD40_SIZE); theField40[FIELD40_SIZE] = '\0'; // Parse Field 41 in.read(theField41, FIELD41_SIZE); theField41[FIELD41_SIZE] = '\0'; // Parse Field 42 in.read(theField42, FIELD42_SIZE); theField42[FIELD42_SIZE] = '\0'; // Set the stop offset. theStopOffset = theStartOffset + DSI_LENGTH; }
//************************************************************************** // rspfDtedAcc::parse() //************************************************************************** void rspfDtedAcc::parse(std::istream& in) { clearErrorStatus(); clearFields(); theStartOffset = in.tellg(); theStopOffset = theStartOffset; // Parse theRecSen in.read(theRecSen, FIELD1_SIZE); theRecSen[FIELD1_SIZE] = '\0'; if(!(strncmp(theRecSen, "ACC", 3) == 0)) { theErrorStatus = rspfErrorCodes::RSPF_ERROR; in.seekg(theStartOffset); return; } // Parse theAbsoluteCE in.read(theAbsoluteCE, FIELD2_SIZE); theAbsoluteCE[FIELD2_SIZE] = '\0'; // Parse theAbsoluteLE in.read(theAbsoluteLE, FIELD3_SIZE); theAbsoluteLE[FIELD3_SIZE] = '\0'; // Parse theRelativeCE in.read(theRelativeCE, FIELD4_SIZE); theRelativeCE[FIELD4_SIZE] = '\0'; // Parse theRelativeLE in.read(theRelativeLE, FIELD5_SIZE); theRelativeLE[FIELD5_SIZE] = '\0'; // Parse Field 6 in.read(theField6, FIELD6_SIZE); theField6[FIELD6_SIZE] = '\0'; // Parse Field 7 in.read(theField7, FIELD7_SIZE); theField7[FIELD7_SIZE] = '\0'; // Parse Field 8 in.read(theField8, FIELD8_SIZE); theField8[FIELD8_SIZE] = '\0'; // Parse Field 9 in.read(theField9, FIELD9_SIZE); theField9[FIELD9_SIZE] = '\0'; // Parse Field 10 in.read(theField10, FIELD10_SIZE); theField10[FIELD10_SIZE] = '\0'; // Parse Field 11 in.read(theField11, FIELD11_SIZE); theField11[FIELD11_SIZE] = '\0'; // Parse Field 12 in.read(theField12, FIELD12_SIZE); theField12[FIELD12_SIZE] = '\0'; // Parse Field 13 in.read(theField13, FIELD13_SIZE); theField13[FIELD13_SIZE] = '\0'; // Parse Field 14 in.read(theField14, FIELD14_SIZE); theField14[FIELD14_SIZE] = '\0'; // Parse Field 15 in.read(theField15, FIELD15_SIZE); theField15[FIELD15_SIZE] = '\0'; // Parse Field 16 in.read(theField16, FIELD16_SIZE); theField16[FIELD16_SIZE] = '\0'; // Parse Field 17 in.read(theField17, FIELD17_SIZE); theField17[FIELD17_SIZE] = '\0'; in.ignore(FIELD18_SIZE); // Set the stop offset. theStopOffset = theStartOffset + ACC_LENGTH; }