void rspfPixelFlipper::initialize() { OpenThreads::ScopedLock<OpenThreads::Mutex> scopeLock(theMutex); rspfImageSourceFilter::initialize(); theValidVertices.clear(); theBoundingRects.clear(); rspf_uint32 rlevels = getNumberOfDecimationLevels(); rspf_uint32 idx = 0; if(rlevels) { if(theValidVertices.size() != rlevels) { theValidVertices.resize(rlevels); } if(theBoundingRects.size() != rlevels) { theBoundingRects.resize(rlevels); } for(idx = 0; idx < rlevels; ++idx) { std::vector<rspfIpt> validVertices; getValidImageVertices(validVertices, RSPF_CLOCKWISE_ORDER, idx); theValidVertices[idx] = rspfPolygon(validVertices); theBoundingRects[idx] = getBoundingRect(idx); } } }
void ossimKakaduJ2kReader::getDecimationFactors( vector<ossimDpt>& decimations) const { const ossim_uint32 LEVELS = getNumberOfDecimationLevels(); decimations.resize(LEVELS); for (ossim_uint32 level = 0; level < LEVELS; ++level) { getDecimationFactor(level, decimations[level]); } }
void ossimKakaduJ2kReader::getDecimationFactor(ossim_uint32 resLevel, ossimDpt& result) const { if (resLevel == 0) { //--- // Assumption r0 or first layer is full res. Might need to change to // use nitf IMAG field. //--- result.x = 1.0; result.y = 1.0; } else if ( theOverview.valid() && (resLevel > theMinDwtLevels) && (resLevel < getNumberOfDecimationLevels()) ) { //--- // External overview file. // // Use the real lines and samples in case an resLevel is skipped. // // Note we must subtract the internal overviews as the external // overview reader does not know about them. //--- ossim_float64 r0 = getNumberOfSamples(0); ossim_float64 rL = theOverview->getNumberOfSamples(resLevel-theMinDwtLevels); if (r0) // Divide by zero check { result.x = rL/r0; } else { result.x = ossim::nan(); } r0 = getNumberOfLines(0); rL = theOverview->getNumberOfLines(resLevel-theMinDwtLevels); if (r0) // Divide by zero check. { result.y = rL/r0; } else { result.y = ossim::nan(); } } else { // Internal overviews are on power of two decimation. result.x = 1.0 / pow((double)2, (double)resLevel); result.y = result.x; } }
void rspfCacheTileSource::initializeRlevelCache() { rspf_uint32 nLevels = getNumberOfDecimationLevels(); deleteRlevelCache(); if(nLevels > 0) { rspf_uint32 idx = 0; theRLevelCacheList.resize(nLevels); for(idx= 0; idx < theRLevelCacheList.size(); ++idx) { theRLevelCacheList[idx] = -1; } } }
ossim_uint32 ossimKakaduJ2kReader::getNumberOfSamples( ossim_uint32 resLevel) const { ossim_uint32 result = 0; if (resLevel < getNumberOfDecimationLevels()) { result = theSizRecord.theXsiz; if ( resLevel > 0 ) { ossimDpt dpt; getDecimationFactor(resLevel, dpt); result = static_cast<ossim_uint32>(result * dpt.x); } } return result; }
//******************************************************************* // Public method: //******************************************************************* bool ossimGeneralRasterTileSource::isValidRLevel(ossim_uint32 reduced_res_level) const { static const char MODULE[] = "ossimGeneralRasterTileSource::isValidRLevel"; if (reduced_res_level == 0) { return true; } else if (theOverview.valid()) { return theOverview->isValidRLevel(reduced_res_level); } else { ossimNotify(ossimNotifyLevel_WARN) << MODULE << " Invalid reduced_res_level: " << reduced_res_level << "\nHighest available: " << (getNumberOfDecimationLevels() - 1) << std::endl; return false; } }
bool ossimKakaduJ2kReader::getOverviewTile(ossim_uint32 resLevel, ossimImageData* result) { bool status = false; if ( (resLevel < getNumberOfDecimationLevels()) && result && (result->getNumberOfBands() == getNumberOfOutputBands()) ) { if (resLevel <= theMinDwtLevels) { // Internal overviews... try { status = ossim::copyRegionToTile(theCodestream, static_cast<int>(resLevel), theThreadEnv, theOpenTileThreadQueue, result); } catch(const ossimException& e) { ossimNotify(ossimNotifyLevel_WARN) << __FILE__ << " " << __LINE__ << " caught exception\n" << e.what(); status = false; } } // matches: if (resLevel <= theMinDwtLevels) else { // External overviews... status = theOverview->getTile(result, resLevel - theMinDwtLevels); } } return status; }
bool toprsImageReader::isValidRLevel( int resLevel ) const { bool result = false; const int LEVELS = getNumberOfDecimationLevels(); if ( !theStartingResLevel) // Not an overview. { result = (resLevel < LEVELS); } else // Used as overview. { if (resLevel >= theStartingResLevel) { //--- // Adjust the res level to be zero based for this overview before // checking. //--- result = ( (resLevel - theStartingResLevel) < LEVELS); } } return result; }
//******************************************************************* // Public method: //******************************************************************* ossimRefPtr<ossimImageGeometry> ossimAdrgTileSource::getImageGeometry() { if ( !theGeometry ) { // Check for external geom: theGeometry = getExternalImageGeometry(); if ( !theGeometry ) { // origin of latitude ossim_float64 originLatitude = (m_AdrgHeader->maxLatitude() + m_AdrgHeader->minLatitude()) / 2.0; // central meridian. ossim_float64 centralMeridian = (m_AdrgHeader->maxLongitude() + m_AdrgHeader->minLongitude()) / 2.0; //--- // Compute the pixel size in latitude and longitude direction. This will // be full image extents divided by full image lines and samples. //--- // Samples in full image (used to compute degPerPixelX). ossim_float64 samples = m_AdrgHeader->samples(); // Lines in full image (used to compute degPerPixelX). ossim_float64 lines = m_AdrgHeader->lines(); // Degrees in latitude direction of the full image. ossim_float64 degrees_in_lat_dir = m_AdrgHeader->maxLatitude() - m_AdrgHeader->minLatitude(); // Degrees in longitude direction of the full image. ossim_float64 degrees_in_lon_dir = m_AdrgHeader->maxLongitude() - m_AdrgHeader->minLongitude(); ossim_float64 degPerPixelY = degrees_in_lat_dir / lines; ossim_float64 degPerPixelX = degrees_in_lon_dir / samples; //--- // The tie is determined with the following assumptions that need to be // verified: // 1) Rows and columns start at 1. // 2) The min / max latitudes longitudes go to the edge of the pixel. // 3) Latitude decreases by degPerPixelY with each line. // 4) Longitude increases by degPerPixelX with each sample. //--- ossim_float64 ul_lat = (m_AdrgHeader->maxLatitude() - ( (m_AdrgHeader->startRow() - 1) * degPerPixelY ) - ( degPerPixelY * 0.5 ) ); ossim_float64 ul_lon = (m_AdrgHeader->minLongitude() + ( (m_AdrgHeader->startCol() -1) * degPerPixelX ) + ( degPerPixelX * 0.5 ) ); // projection type ossimKeywordlist kwl; const char* prefix = 0; kwl.add(prefix, ossimKeywordNames::TYPE_KW, "ossimEquDistCylProjection", true); // datum. kwl.add(prefix, ossimKeywordNames::DATUM_KW, "WGE", true); // origin latitude kwl.add(prefix, ossimKeywordNames::ORIGIN_LATITUDE_KW, originLatitude, true); // central meridin kwl.add(prefix, ossimKeywordNames::CENTRAL_MERIDIAN_KW, centralMeridian, true); // Save the tie point. kwl.add(prefix, ossimKeywordNames::TIE_POINT_XY_KW, ossimDpt(ul_lon, ul_lat).toString().c_str(), true); kwl.add(prefix, ossimKeywordNames::TIE_POINT_UNITS_KW, ossimUnitTypeLut::instance()->getEntryString(OSSIM_DEGREES), true); // Save the scale. kwl.add(prefix, ossimKeywordNames::TIE_POINT_LAT_KW, ul_lat, true); kwl.add(prefix, ossimKeywordNames::TIE_POINT_LON_KW, ul_lon, true); // Save the scale. kwl.add(prefix, ossimKeywordNames::PIXEL_SCALE_XY_KW, ossimDpt(degPerPixelX, degPerPixelY).toString().c_str(), true); kwl.add(prefix, ossimKeywordNames::PIXEL_SCALE_UNITS_KW, ossimUnitTypeLut::instance()->getEntryString(OSSIM_DEGREES), true); // lines kwl.add(prefix, ossimKeywordNames::NUMBER_LINES_KW, getNumberOfLines()); // samples kwl.add(prefix, ossimKeywordNames::NUMBER_SAMPLES_KW, getNumberOfSamples()); // res sets kwl.add(prefix, ossimKeywordNames::NUMBER_REDUCED_RES_SETS_KW, getNumberOfDecimationLevels()); // bands kwl.add(prefix, ossimKeywordNames::NUMBER_INPUT_BANDS_KW, getNumberOfInputBands()); // bands kwl.add(prefix, ossimKeywordNames::NUMBER_OUTPUT_BANDS_KW, getNumberOfOutputBands()); if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "\nminLon: " << m_AdrgHeader->minLon() << "\nminLond: " << m_AdrgHeader->minLongitude() << "\nminLat: " << m_AdrgHeader->minLat() << "\nminLatd: " << m_AdrgHeader->minLatitude() << "\nmaxLon: " << m_AdrgHeader->maxLon() << "\nmaxLond: " << m_AdrgHeader->maxLongitude() << "\nmaxLat: " << m_AdrgHeader->maxLat() << "\nmaxLatd: " << m_AdrgHeader->maxLatitude() << "\nstartRow: " << m_AdrgHeader->startRow() << "\nstartCol: " << m_AdrgHeader->startCol() << "\nstopRow: " << m_AdrgHeader->stopRow() << "\nstopCol: " << m_AdrgHeader->stopCol() << "\nfull image lines: " << lines << "\nfull image samples: " << samples << "\nkwl:\n" << kwl << std::endl; } ossimProjection* new_proj = ossimProjectionFactoryRegistry::instance()->createProjection(kwl); theGeometry = new ossimImageGeometry; theGeometry->setProjection(new_proj); // assumes management of projection instance } // matches (after getExternalImageGeometry()): if ( !theGeometry ) // Set image things the geometry object should know about. initImageParameters( theGeometry.get() ); } // matches: if ( !theGeometry ) return theGeometry; }
int toprsImageReader::getNumberOfReducedResSets() const { return getNumberOfDecimationLevels(); }
bool ossimMrSidReader::computeDecimationFactors( std::vector<ossimDpt>& decimations) const { bool result = true; decimations.clear(); const ossim_uint32 LEVELS = getNumberOfDecimationLevels(); for (ossim_uint32 level = 0; level < LEVELS; ++level) { ossimDpt pt; if (level == 0) { // Assuming r0 is full res for now. pt.x = 1.0; pt.y = 1.0; } else { // Get the sample decimation. ossim_float64 r0 = getNumberOfSamples(0); ossim_float64 rL = getNumberOfSamples(level); if ( (r0 > 0.0) && (rL > 0.0) ) { pt.x = rL / r0; } else { result = false; break; } // Get the line decimation. r0 = getNumberOfLines(0); rL = getNumberOfLines(level); if ( (r0 > 0.0) && (rL > 0.0) ) { pt.y = rL / r0; } else { result = false; break; } } decimations.push_back(pt); } if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimMrSidReader::computeDecimationFactors DEBUG\n"; for (ossim_uint32 i = 0; i < decimations.size(); ++i) { ossimNotify(ossimNotifyLevel_DEBUG) << "decimation[" << i << "]: " << decimations[i] << std::endl; } } return result; }