bool ossimOpjJp2Writer::writeFile() { // This method is called from ossimImageFileWriter::execute(). bool result = false; if( theInputConnection.valid() && (getErrorStatus() == ossimErrorCodes::OSSIM_OK) ) { // Make sure Area of Interest is an even multiple of tiles ossimIrect areaOfInterest = theInputConnection->getAreaOfInterest(); ossimIpt imageSize(areaOfInterest.size()); ossimIpt imageLr(areaOfInterest.lr()); ossim_uint32 xBoundaryAdjustFactor = DEFAULT_TILE_SIZE.x - (imageSize.x % DEFAULT_TILE_SIZE.x); ossim_uint32 yBoundaryAdjustFactor = DEFAULT_TILE_SIZE.y - (imageSize.y % DEFAULT_TILE_SIZE.y); imageLr.x += xBoundaryAdjustFactor; imageLr.y += yBoundaryAdjustFactor; areaOfInterest.set_lr(imageLr); theInputConnection->setAreaOfInterest(areaOfInterest); // Set the tile size for all processes. theInputConnection->setTileSize( DEFAULT_TILE_SIZE ); theInputConnection->setToStartOfSequence(); //--- // Note only the master process used for writing... //--- if(theInputConnection->isMaster()) { if (!isOpen()) { open(); } if ( isOpen() ) { result = writeStream(); } } else // Slave process. { // This will return after all tiles for this node have been processed. theInputConnection->slaveProcessTiles(); result = true; } } return result; } // End: ossimOpjJp2Writer::writeFile()
bool ossimGeneralRasterWriter::writeStream() { static const char MODULE[] = "ossimGeneralRasterWriter::writeStream"; bool result = false; if( theInputConnection.valid() && theOutputStream && ( getErrorStatus() == ossimErrorCodes::OSSIM_OK ) ) { if ( theInputConnection->isMaster() ) { // Write the file with the image data. if ( (theOutputImageType == "general_raster_bip") || (theOutputImageType == "general_raster_bip_envi") ) { result = writeToBip(); } else if ( (theOutputImageType == "general_raster_bil") || (theOutputImageType == "general_raster_bil_envi") ) { result = writeToBil(); } else if ( (theOutputImageType == "general_raster_bsq") || (theOutputImageType == "general_raster_bsq_envi") ) { result = writeToBsq(); } else { ossimNotify(ossimNotifyLevel_FATAL) << MODULE << " ERROR:" << "\nUnsupported output type: " << theOutputImageType << std::endl; result = false; } if ( result ) { // Flush the stream to disk... theOutputStream->flush(); } } else // Matching else: if ( theInputConnection->isMaster() ) { // Slave process: theInputConnection->slaveProcessTiles(); result = true; } } return result; } // End: ossimGeneralRasterWriter::writeStream()
bool ossimXmlDocument::read(std::istream& in) { // char buffer[BUFFER_MAX_LEN]; // streampos file_pos; // bool readingHeader = true; bool startTagCharacterFound = false; char c = in.peek(); // Initially we will do our own skipping to make sure we ar not binary. while(!in.bad() && (c != '<') && (c >= 0x20) && (c <= 0x7e)) { in.ignore(1); c = in.peek(); } if (in.bad() || (c!='<')) { setErrorStatus(); return false; } startTagCharacterFound = true; if(readHeader(in)) { if(theXmlHeader=="") { if(startTagCharacterFound) { theXmlHeader = "<?xml version='1.0'?>"; } } } if((!theXmlHeader.contains("xml version")) && theStrictCheckFlag) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "FATAL: ossimXmlDocument::ossimXmlDocument" << "encountered parsing XML file <" << theFilename << ">. The file does not appear to be XML v1.0. \n" << "Header = \n" << theXmlHeader <<"\n" << endl; } setErrorStatus(); return false; } theRootNode = new ossimXmlNode(in, 0); setErrorStatus(theRootNode->getErrorStatus()); return (getErrorStatus()==ossimErrorCodes::OSSIM_OK); }
bool ossimGeneralRasterWriter::writeFile() { bool result = false; if( theInputConnection.valid() && ( getErrorStatus() == ossimErrorCodes::OSSIM_OK ) ) { //--- // Make sure we can open the file. Note only the master process is used for // writing... //--- if(theInputConnection->isMaster()) { if (!isOpen()) { open(); } } result = writeStream(); if ( result ) { // Do this only on the master process. Note left to right precedence! if (getSequencer() && getSequencer()->isMaster()) { //--- // Write the header out. We do this last since we must // compute min max pixel while we are writting the image. // since the header is an external text file this is Ok // to do. //--- writeHeader(); if (theOutputImageType.contains("envi")) { writeEnviHeader(); } } } close(); } return result; } // End: ossimGeneralRasterWriter::writeFile()
bool ossimOpenJpegWriter::writeFile() { if( !theInputConnection || (getErrorStatus() != ossimErrorCodes::OSSIM_OK) ) { return false; } //--- // Make sure we can open the file. Note only the master process is used for // writing... //--- if(theInputConnection->isMaster()) { if (!isOpen()) { open(); } } return writeStream(); }
bool ossimKakaduNitfWriter::writeFile() { // This method is called from ossimImageFileWriter::execute(). bool result = false; if( theInputConnection.valid() && (getErrorStatus() == ossimErrorCodes::OSSIM_OK) ) { // Set the tile size for all processes. theInputConnection->setTileSize( DEFAULT_TILE_SIZE ); theInputConnection->setToStartOfSequence(); //--- // Note only the master process used for writing... //--- if(theInputConnection->isMaster()) { if (!isOpen()) { open(); } if ( isOpen() ) { result = writeStream(); } } else // Slave process. { // This will return after all tiles for this node have been processed. theInputConnection->slaveProcessTiles(); result = true; } } return result; }
bool ossimIkonosRpcModel::parseTiffFile(const ossimFilename& filename) { bool result = false; ossimRefPtr<ossimTiffTileSource> tiff = new ossimTiffTileSource(); if ( tiff->open(filename) ) { if ( !theSupportData ) { theSupportData = new ossimIkonosMetaData(); } if ( theSupportData->open(filename) == false ) { if(traceDebug()) { // Currently not required by model so we will not error out here. ossimNotify(ossimNotifyLevel_DEBUG) << "WARNING: ossimIkonosMetaData::open returned false.\n" << std::endl; } } else { // copy ossimIkonosMetada-sensor into ossimIkonosRpcModel-sensorId theSensorID = theSupportData->getSensorID(); } //convert file to rpc filename and hdr filename so we can get some info ossimFilename rpcfile = filename.noExtension(); rpcfile += "_rpc.txt"; ossimFilename hdrfile = filename; hdrfile.setExtension(ossimString("hdr")); if( parseHdrData(hdrfile) ) { // parseRpcData sets the error status on error. parseRpcData (rpcfile); if ( !getErrorStatus() ) //check for errors in parsing rpc data { finishConstruction(); //--- // Save current state in RPC model format: //--- ossimString drivePart; ossimString pathPart; ossimString filePart; ossimString extPart; filename.split(drivePart, pathPart, filePart, extPart); ossimFilename init_rpc_geom; init_rpc_geom.merge(drivePart, pathPart, INIT_RPC_GEOM_FILENAME, ""); ossimKeywordlist kwl (init_rpc_geom); saveState(kwl); // If we get here set the return status to true. result = true; } // matches: if ( !getErrorStatus() ) } // matches: if( parseHdrData(hdrfile) ) } // matches: if ( tiff->open(filename) ) if ( traceExec() ) { ossimNotify(ossimNotifyLevel_DEBUG) << "return status: " << (result?"true\n":"false\n") << "DEBUG ossimIkonosRpcModel parseTiffFile: returning..." << std::endl; } return result; }