ossimRefPtr<ossimImageGeometry> ossimPngReader::getImageGeometry() { if ( !theGeometry ) { //--- // Check factory for external geom: //--- theGeometry = getExternalImageGeometry(); if ( !theGeometry ) { // Fist time through: theGeometry = new ossimImageGeometry(); //--- // This code does not call ossimImageGeometryRegistry::extendGeometry // by design to avoid wasted factory calls. //--- } // Set image things the geometry object should know about. initImageParameters( theGeometry.get() ); } return theGeometry; }
ossimRefPtr<ossimImageGeometry> ossimLasReader::getImageGeometry() { if ( !theGeometry ) { // Check for external geom: theGeometry = getExternalImageGeometry(); if ( !theGeometry ) { theGeometry = new ossimImageGeometry(); if ( m_proj.valid() ) { theGeometry->setProjection( m_proj.get() ); } else { //--- // WARNING: // Must create/set theGeometry at this point or the next call to // ossimImageGeometryRegistry::extendGeometry will put us in an infinite loop // as it does a recursive call back to ossimImageHandler::getImageGeometry(). //--- // Try factories for projection. ossimImageGeometryRegistry::instance()->extendGeometry(this); } } // Set image things the geometry object should know about. initImageParameters( theGeometry.get() ); } return theGeometry; }
//************************************************************************************************ //! Returns the image geometry object associated with this tile source or NULL if non defined. //! The geometry contains full-to-local image transform as well as projection (image-to-world) //************************************************************************************************ rspfRefPtr<rspfImageGeometry> rspfEnviTileSource::getImageGeometry() { if ( !theGeometry ) { // Check for external geom: theGeometry = getExternalImageGeometry(); if ( !theGeometry ) { // Check the internal geometry first to avoid a factory call. theGeometry = getInternalImageGeometry(); // At this point it is assured theGeometry is set. //--- // WARNING: // Must create/set theGeometry at this point or the next call to // rspfImageGeometryRegistry::extendGeometry will put us in an infinite loop // as it does a recursive call back to rspfImageHandler::getImageGeometry(). //--- // Check for set projection. if ( theGeometry.valid()&&!theGeometry->getProjection() ) { // Try factories for projection. rspfImageGeometryRegistry::instance()->extendGeometry(this); } } // Set image things the geometry object should know about. initImageParameters( theGeometry.get() ); } return theGeometry; }
ossimRefPtr<ossimImageGeometry> ossimMrSidReader::getImageGeometry() { if ( !theGeometry ) { //--- // Check for external geom: //--- theGeometry = getExternalImageGeometry(); if ( !theGeometry ) { //--- // Check the internal geometry first to avoid a factory call. //--- theGeometry = getInternalImageGeometry(); // At this point it is assured theGeometry is set. // Check for set projection. if ( !theGeometry->getProjection() ) { // Try factories for projection. ossimImageGeometryRegistry::instance()->extendGeometry(this); } } // Set image things the geometry object should know about. initImageParameters( theGeometry.get() ); } return theGeometry; }
ossimRefPtr<ossimImageGeometry> ossimNdfTileSource::getImageGeometry() { if ( !theGeometry ) { // Check for external geom: theGeometry = getExternalImageGeometry(); if ( !theGeometry ) { theGeometry = new ossimImageGeometry(); // Validate Header to ensure we support this data type ossimNdfHeader lnh(theHeaderFile); if(lnh.getErrorStatus() == ossimErrorCodes::OSSIM_OK) { // Get the projection info. ossimKeywordlist kwl; kwl.add(lnh.getGeom()); // Create the projection. ossimRefPtr<ossimProjection> proj = ossimProjectionFactoryRegistry::instance()-> createProjection(kwl); if ( proj.valid() ) { // Assign projection to our ossimImageGeometry object. theGeometry->setProjection( proj.get() ); } } // At this point it is assured theGeometry is set. //--- // WARNING: // Must create/set theGeometry at this point or the next call to // ossimImageGeometryRegistry::extendGeometry will put us in an infinite loop // as it does a recursive call back to ossimImageHandler::getImageGeometry(). //--- // Check for set projection. if ( !theGeometry->getProjection() ) { // Try factories for projection. ossimImageGeometryRegistry::instance()->extendGeometry(this); } } // Set image things the geometry object should know about. initImageParameters( theGeometry.get() ); } return theGeometry; }
//************************************************************************************************ //! Returns the image geometry object associated with this tile source or NULL if non defined. //! The geometry contains full-to-local image transform as well as projection (image-to-world) //************************************************************************************************ ossimRefPtr<ossimImageGeometry> ossimSrtmTileSource::getImageGeometry() { if(!theGeometry.valid()) { // First time through set the projection. theGeometry = new ossimImageGeometry(); theGeometry->setProjection( m_SrtmSupportData.getProjection().get() ); // Set image things the geometry object should know about. initImageParameters( theGeometry.get() ); } return theGeometry; }
//************************************************************************************************** // Returns the image geometry object associated with this tile source or NULL if non defined. //************************************************************************************************** rspfRefPtr<rspfImageGeometry> rspfVpfTileSource::getImageGeometry() { if (theGeometry.valid()) return theGeometry; rspfRefPtr<rspfImageGeometry> annotGeom = m_AnnotationSource->getImageGeometry(); if ( annotGeom.valid() ) { // Copy the annotation source's geometry as our own: theGeometry = new rspfImageGeometry(*annotGeom); // Set image things the geometry object should know about. initImageParameters( theGeometry.get() ); return theGeometry; } return rspfRefPtr<rspfImageGeometry>(); }
ossimRefPtr<ossimImageGeometry> ossimLandsatTileSource::getImageGeometry() { if ( !theGeometry ) { // Check for external geom: theGeometry = getExternalImageGeometry(); if ( !theGeometry ) { theGeometry = new ossimImageGeometry(); if ( theFfHdr.valid() ) { // Make a model ossimLandSatModel* model = new ossimLandSatModel (*theFfHdr); if (model->getErrorStatus() == ossimErrorCodes::OSSIM_OK) { //initialize the image geometry object with the model theGeometry->setProjection(model); } } //--- // WARNING: // Must create/set the geometry at this point or the next call to // ossimImageGeometryRegistry::extendGeometry will put us in an infinite loop // as it does a recursive call back to ossimImageHandler::getImageGeometry(). //--- // Check for set projection. if ( !theGeometry->getProjection() ) { // Try factories for projection. ossimImageGeometryRegistry::instance()->extendGeometry(this); } } // Set image things the geometry object should know about. initImageParameters( theGeometry.get() ); } return theGeometry; }
ossimRefPtr<ossimImageGeometry> ossimH5Reader::getImageGeometry() { if ( !theGeometry ) { //--- // Check for external geom: //--- theGeometry = getExternalImageGeometry(); if ( !theGeometry ) { //--- // WARNING: // Must create/set the geometry at this point or the next call to // ossimImageGeometryRegistry::extendGeometry will put us in an infinite loop // as it does a recursive call back to ossimImageHandler::getImageGeometry(). //--- // Check the internal geometry first to avoid a factory call. m_mutex.lock(); theGeometry = getInternalImageGeometry(); m_mutex.unlock(); // At this point it is assured theGeometry is set. // Check for set projection. if ( !theGeometry->getProjection() ) { // Try factories for projection. ossimImageGeometryRegistry::instance()->extendGeometry(this); } } // Set image things the geometry object should know about. initImageParameters( theGeometry.get() ); } return theGeometry; }
//************************************************************************************************** //! Returns the image geometry object associated with this tile source or NULL if non defined. //! The geometry contains full-to-local image transform as well as projection (image-to-world) //************************************************************************************************** rspfRefPtr<rspfImageGeometry> rspfDoqqTileSource::getImageGeometry() { if (theGeometry.valid()) return theGeometry; if(theHeaderInformation.valid()) { rspfKeywordlist kwl; const char* prefix = 0; // legacy rspfString proj = theHeaderInformation->theProjection.trim().upcase(); rspfString datum = theHeaderInformation->theDatum.trim().upcase(); if(proj == rspfString("UTM") || proj == rspfString("1")) { kwl.add(prefix, rspfKeywordNames::TYPE_KW, "rspfUtmProjection", true); kwl.add(prefix, rspfKeywordNames::ZONE_KW, theHeaderInformation->theUtmZone, true); } else { return rspfRefPtr<rspfImageGeometry>(); } if(datum == rspfString("NAR") || datum == rspfString("4")) { kwl.add(prefix, rspfKeywordNames::DATUM_KW, "NAR-C", // North American Conus 1983 true); } else if(datum == rspfString("NAS") || datum == rspfString("1")) { kwl.add(prefix, rspfKeywordNames::DATUM_KW, "NAS-C", // North American Conus 1927 true); } else if(datum == rspfString("2")) { kwl.add(prefix, rspfKeywordNames::DATUM_KW, "WGD", // WGS 72 true); } else if(datum == rspfString("3")) { kwl.add(prefix, rspfKeywordNames::DATUM_KW, "WGE", // WGS 84 true); } else { return rspfRefPtr<rspfImageGeometry>(); } kwl.add(prefix, rspfKeywordNames::METERS_PER_PIXEL_X_KW, theHeaderInformation->theGsd.x, true); kwl.add(prefix, rspfKeywordNames::METERS_PER_PIXEL_Y_KW, theHeaderInformation->theGsd.y, true); kwl.add(prefix, rspfKeywordNames::TIE_POINT_EASTING_KW, // theHeaderInformation->theUE + (theHeaderInformation->theGsd/2.0), theHeaderInformation->theEasting, true); kwl.add(prefix, rspfKeywordNames::TIE_POINT_NORTHING_KW, // theHeaderInformation->theUN - (theHeaderInformation->theGsd/2.0), theHeaderInformation->theNorthing, true); // Capture this for next time. theGeometry = new rspfImageGeometry; theGeometry->loadState(kwl, prefix); // Set image things the geometry object should know about. initImageParameters( theGeometry.get() ); return theGeometry; } return rspfRefPtr<rspfImageGeometry>(); }
//******************************************************************* // 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; }
//************************************************************************************************* // I know what I am. I am a Quickbird TIFF image. I may be standalone or tiled with row-column // designation in the file name. My projection information is available (possibly) in an // accompanying RPC file and/or internal TIF tag, and my transform info (sub-image offset) is // available in a TILE info file (*.til) or internal TIF tag. Therefore, I (and not some outside // factory) am best qualified for establishing my image geometry. //************************************************************************************************* ossimRefPtr<ossimImageGeometry> ossimQuickbirdTiffTileSource::getImageGeometry() { if ( !theGeometry ) { //--- // Check factory for external geom: //--- theGeometry = getExternalImageGeometry(); if ( !theGeometry ) { theGeometry = new ossimImageGeometry(); // Fetch the tile info for this particular image: if ( m_tileInfoFilename.size() ) { ossimQuickbirdTile tileFile; if ( tileFile.open(m_tileInfoFilename) ) { ossimQuickbirdTileInfo info; bool infoStatus = tileFile.getInfo(info, theImageFile.file().upcase()); if ( !infoStatus ) { infoStatus = tileFile.getInfo(info, theImageFile.file().downcase()); } if ( infoStatus ) { // Establish sub-image offset (shift) for this tile: ossimDpt shift(0,0); if ((info.theUlXOffset != OSSIM_INT_NAN) && (info.theUlYOffset != OSSIM_INT_NAN)) shift = ossimIpt(info.theUlXOffset, info.theUlYOffset); if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimQuickbirdTiffTileSource::open() DEBUG:" << "\nSub image offset = " << shift << std::endl; } // Create the transform and set it in the geometry object: ossimRefPtr<ossim2dTo2dTransform> transform = new ossim2dTo2dShiftTransform(shift); theGeometry->setTransform(transform.get()); // Next is the projection part of the image geometry. This should be available // as an external RPC file or internal RPC's in the tiff file. Otherwise use // the map projection specified in the // tiff file: theGeometry->setProjection(0); ossimRefPtr<ossimQuickbirdRpcModel> model = new ossimQuickbirdRpcModel; if (model->parseFile(theImageFile)) { theGeometry->setProjection(model.get()); } else { // Last resort to a projection factory: ossimRefPtr<ossimProjection> proj = ossimProjectionFactoryRegistry::instance()->createProjection(this); if (proj.valid()) theGeometry->setProjection(proj.get()); } } // Set image things the geometry object should know about. initImageParameters( theGeometry.get() ); } } } } return theGeometry; }
ossimRefPtr<ossimImageGeometry> ossimGeneralRasterTileSource::getImageGeometry() { if ( !theGeometry.valid() ) { // Check for external geom: theGeometry = getExternalImageGeometry(); if ( !theGeometry.valid() ) { theGeometry = new ossimImageGeometry(); ossimString ext = theImageFile.ext(); ossimFilename hdrFile = theImageFile; ossimFilename xmlFile = theImageFile; hdrFile = hdrFile.setExtension("hdr"); xmlFile = xmlFile.setExtension("xml"); if (hdrFile.exists()) { ossimKeywordlist geoKwl; ossimKeywordlist kwl(hdrFile, ' '); kwl.downcaseKeywords(); ossim_uint32 lines = 0; ossim_uint32 samples = 0; ossim_float32 ll_lon = 0.0; ossim_float32 ll_lat = 0.0; ossim_float32 xCellSize = 1.0; ossim_float32 yCellSize = 1.0; const char* lookup = kwl.find("ncols"); if (lookup) { samples = ossimString(lookup).toUInt32(); geoKwl.add(ossimKeywordNames::NUMBER_SAMPLES_KW, samples); } lookup = kwl.find("nrows"); if (lookup) { lines = ossimString(lookup).toUInt32(); geoKwl.add(ossimKeywordNames::NUMBER_LINES_KW, lines); } lookup = kwl.find("cellsize"); if (lookup) { xCellSize = ossimString(lookup).toFloat32(); yCellSize = xCellSize; geoKwl.add(ossimKeywordNames::DECIMAL_DEGREES_PER_PIXEL_LAT, yCellSize); geoKwl.add(ossimKeywordNames::DECIMAL_DEGREES_PER_PIXEL_LON, xCellSize); } lookup = kwl.find("xdim"); if (lookup) { xCellSize = ossimString(lookup).toFloat32(); geoKwl.add(ossimKeywordNames::DECIMAL_DEGREES_PER_PIXEL_LON, xCellSize); } lookup = kwl.find("ydim"); if (lookup) { yCellSize = ossimString(lookup).toFloat32(); geoKwl.add(ossimKeywordNames::DECIMAL_DEGREES_PER_PIXEL_LAT, yCellSize); } lookup = kwl.find("xllcenter"); if (lookup) { ossim_float32 centerX = ossimString(lookup).toFloat32(); ll_lon = centerX + xCellSize * 0.5; geoKwl.add(ossimKeywordNames::TIE_POINT_LON_KW, ll_lon); } lookup = kwl.find("yllcenter"); if (lookup) { ossim_float32 centerY = ossimString(lookup).toFloat32(); ll_lat = (centerY + (lines - 1) * yCellSize) + yCellSize * 0.5; geoKwl.add(ossimKeywordNames::TIE_POINT_LAT_KW, ll_lat); } lookup = kwl.find("xllcorner"); if (lookup) { ll_lon = ossimString(lookup).toFloat32(); geoKwl.add(ossimKeywordNames::TIE_POINT_LON_KW, ll_lon); } lookup = kwl.find("yllcorner"); if (lookup) { ossim_uint32 centerY = ossimString(lookup).toFloat32(); ll_lat = centerY + lines * yCellSize; geoKwl.add(ossimKeywordNames::TIE_POINT_LAT_KW, ll_lat); } lookup = kwl.find("ulxmap"); if (lookup) { ll_lon = ossimString(lookup).toFloat32(); geoKwl.add(ossimKeywordNames::TIE_POINT_LON_KW, ll_lon); } lookup = kwl.find("ulymap"); if (lookup) { ossim_uint32 centerY = ossimString(lookup).toFloat32(); ll_lat = centerY + lines * yCellSize; geoKwl.add(ossimKeywordNames::TIE_POINT_LAT_KW, ll_lat); } kwl.add(ossimKeywordNames::ORIGIN_LATITUDE_KW, ll_lat); geoKwl.add(ossimKeywordNames::TYPE_KW, "ossimEquDistCylProjection"); geoKwl.add(ossimKeywordNames::DATUM_KW, ossimDatumFactory::instance()->wgs84()-> code()); ossimRefPtr<ossimProjection> proj = ossimMapProjectionFactory::instance()-> createProjection(geoKwl); if ( proj.valid() ) { theGeometry->setProjection(proj.get()); } } else if (xmlFile.exists()) { ossimFgdcXmlDoc file; if ( file.open(xmlFile) ) { ossimRefPtr<ossimProjection> proj = file.getProjection(); if ( !proj.valid() ) { proj = file.getGridCoordSysProjection(); } if ( proj.valid() ) { theGeometry->setProjection(proj.get()); } } } // xml file exist... } // Matches second if ( !theGeometry.valid() ) //--- // WARNING: // Must have theGeometry at this point or the next call to // ossimImageGeometryRegistry::extendGeometry will put us in an infinite loop // as it does a recursive call back to ossimImageHandler::getImageGeometry(). //--- // Check for set projection. if ( !theGeometry->getProjection() ) { // Try factories for projection. ossimImageGeometryRegistry::instance()->extendGeometry(this); } // Set image things the geometry object should know about. initImageParameters( theGeometry.get() ); } // Matches first if ( !theGeometry.valid() ) return theGeometry; }