ossim_uint32 ossimLasReader::getNumberOfDecimationLevels() const { // Can support any number of rlevels. ossim_uint32 result = 1; const ossim_uint32 STOP_DIMENSION = 16; ossim_uint32 largestImageDimension = getNumberOfSamples(0) > getNumberOfLines(0) ? getNumberOfSamples(0) : getNumberOfLines(0); while(largestImageDimension > STOP_DIMENSION) { largestImageDimension /= 2; ++result; } return result; }
//******************************************************************* // Public Method: //******************************************************************* ossimIrect ossimAdrgTileSource::getImageRectangle(ossim_uint32 reduced_res_level) const { return ossimIrect(0, // upper left x 0, // upper left y getNumberOfSamples(reduced_res_level) - 1, // lower right x getNumberOfLines(reduced_res_level) - 1); // lower right y }
ossimIrect ossimH5Reader::getImageRectangle(ossim_uint32 reduced_res_level) const { return ossimIrect(0, 0, getNumberOfSamples(reduced_res_level) - 1, getNumberOfLines(reduced_res_level) - 1); }
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 rspfRpfTocEntry::getDecimalDegreesPerPixel(rspfDpt& scale) const { #if 1 scale.x = theBoundaryInformation.getCoverage().getHorizontalInterval(); scale.y = theBoundaryInformation.getCoverage().getVerticalInterval(); #else rspf_float64 ulLat = theBoundaryInformation.getCoverage().getUlLat(); rspf_float64 ulLon = theBoundaryInformation.getCoverage().getUlLon(); rspf_float64 urLon = theBoundaryInformation.getCoverage().getUrLon(); rspf_float64 llLat = theBoundaryInformation.getCoverage().getLrLat(); rspf_float64 lines = getNumberOfLines(); rspf_float64 samps = getNumberOfSamples(); scale.x = (urLon - ulLon) / samps; scale.y = (ulLat - llLat) / lines; #endif }
toprsIRect toprsImageReader::getImageRectangle( int resLevel /*= 0*/ ) const { toprsIRect result; if( isOpen() && isValidRLevel(resLevel) ) { int lines = getNumberOfLines(resLevel); int samples = getNumberOfSamples(resLevel); if( !lines || !samples ) { result.makeNAN(); } else { result = toprsIRect(0, 0, samples-1, lines-1); } } else { result.makeNAN(); } return result; }
bool FWSingleOMP::run() { hdf_WGT_data.setFileName(xmlrootName); hdf_OBS_data.setFileName(xmlrootName); if (doWeights==1) { fillIDMatrix(); hdf_WGT_data.makeFile(); hdf_WGT_data.openFile(); hdf_WGT_data.addFW(0); for (int i=0;i<Weights.size();i++) hdf_WGT_data.addStep(i,Weights[i]); hdf_WGT_data.closeFW(); hdf_WGT_data.closeFile(); for(int ill=1;ill<weightLength;ill++) { transferParentsOneGeneration(); FWOneStep(); // WeightHistory.push_back(Weights); hdf_WGT_data.openFile(); hdf_WGT_data.addFW(ill); for (int i=0;i<Weights.size();i++) hdf_WGT_data.addStep(i,Weights[i]); hdf_WGT_data.closeFW(); hdf_WGT_data.closeFile(); } } else { fillIDMatrix(); // find weight length from the weight file hid_t f_file = H5Fopen(hdf_WGT_data.getFileName().c_str(),H5F_ACC_RDONLY,H5P_DEFAULT); hsize_t numGrps = 0; H5Gget_num_objs(f_file, &numGrps); weightLength = static_cast<int> (numGrps)-1; if (H5Fclose(f_file)>-1) f_file=-1; if (verbose>0) app_log()<<" weightLength "<<weightLength<<endl; } if (verbose>0) app_log()<<" Done Computing Weights"<<endl; if (doObservables==1) { int nprops = H.sizeOfObservables();//local energy, local potnetial and all hamiltonian elements int FirstHamiltonian = H.startIndex(); // vector<vector<vector<RealType> > > savedValues; int nelectrons = W[0]->R.size(); int nfloats=OHMMS_DIM*nelectrons; // W.clearEnsemble(); makeClones(W,Psi,H); vector<ForwardWalkingData* > FWvector; for(int ip=0; ip<NumThreads; ip++) FWvector.push_back(new ForwardWalkingData(nelectrons)); if (myComm->rank()==0) hdf_OBS_data.makeFile(); hdf_float_data.openFile(fname.str()); for(int step=0;step<numSteps;step++) { hdf_float_data.setStep(step); vector<RealType> stepObservables(walkersPerBlock[step]*(nprops+2), 0); for(int wstep=0; wstep<walkersPerBlock[step];) { vector<float> ThreadsCoordinate(NumThreads*nfloats); int nwalkthread = hdf_float_data.getFloat(wstep*nfloats, (wstep+NumThreads)*nfloats, ThreadsCoordinate) / nfloats; // for(int j=0;j<ThreadsCoordinate.size();j++)cout<<ThreadsCoordinate[j]<<" "; // cout<<endl; #pragma omp parallel for for(int ip=0; ip<nwalkthread; ip++) { vector<float> SINGLEcoordinate(0); vector<float>::iterator TCB1(ThreadsCoordinate.begin()+ip*nfloats), TCB2(ThreadsCoordinate.begin()+(1+ip)*nfloats); SINGLEcoordinate.insert(SINGLEcoordinate.begin(),TCB1,TCB2); FWvector[ip]->fromFloat(SINGLEcoordinate); wClones[ip]->R=FWvector[ip]->Pos; wClones[ip]->update(); RealType logpsi(psiClones[ip]->evaluateLog(*wClones[ip])); RealType eloc=hClones[ip]->evaluate( *wClones[ip] ); hClones[ip]->auxHevaluate(*wClones[ip]); int indx=(wstep+ip)*(nprops+2); stepObservables[indx]= eloc; stepObservables[indx+1]= hClones[ip]->getLocalPotential(); for(int i=0;i<nprops;i++) stepObservables[indx+i+2] = hClones[ip]->getObservable(i) ; } wstep+=nwalkthread; for(int ip=0; ip<NumThreads; ip++) wClones[ip]->resetCollectables(); } hdf_OBS_data.openFile(); hdf_OBS_data.addStep(step, stepObservables); hdf_OBS_data.closeFile(); // savedValues.push_back(stepObservables); hdf_float_data.endStep(); if (verbose >1) cout<<"Done with step: "<<step<<endl; } } if(doDat>=1) { vector<int> Dimensions(4); hdf_WGT_data.openFile(); hdf_OBS_data.openFile(); Estimators->start(weightLength,1); int nprops; if (doObservables==1) nprops = H.sizeOfObservables()+2; else { int Noo = hdf_OBS_data.numObsStep(0); int Nwl = hdf_WGT_data.numWgtStep(0); nprops = Noo/Nwl; } for(int ill=0;ill<weightLength;ill++) { Dimensions[0]=ill; Dimensions[1]= nprops ; Dimensions[2]=numSteps; Dimensions[3]=startStep; Estimators->startBlock(1); Estimators->accumulate(hdf_OBS_data,hdf_WGT_data,Dimensions); Estimators->stopBlock(getNumberOfSamples(ill)); } hdf_OBS_data.closeFile(); hdf_WGT_data.closeFile(); Estimators->stop(); } return true; }
bool ossimKakaduJ2kReader::open() { static const char MODULE[] = "ossimKakaduJ2kReader::open"; if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entered...\n"; } bool result = false; if(isOpen()) { closeEntry(); } // Open up a stream to the file. theFileStr.open(theImageFile.c_str(), ios::in | ios::binary); if ( theFileStr.good() ) { //--- // Check for the Start Of Codestream (SOC) and Size (SIZ) markers which // are required as first and second fields in the main header. //--- ossim_uint16 soc; ossim_uint16 siz; theFileStr.read((char*)&soc, 2); theFileStr.read((char*)&siz, 2); if (ossim::byteOrder() == OSSIM_LITTLE_ENDIAN) // Alway big endian. { ossimEndian().swap(soc); ossimEndian().swap(siz); } if ( (soc == SOC_MARKER) && (siz == SIZ_MARKER) ) { // Read in and store the size record. theSizRecord.parseStream(theFileStr); // Position to start of code stream prior to create call. theFileStr.seekg(0); //--- // Initialize the codestream. The class ossimKakaduNitfReader is a // kdu_compressed source so we feed ourself to the codestream. // // TODO: Currently no kdu_thread_env. This should be implemented for // speed... //--- //--- // Construct multi-threaded processing environment if required. // Temp hard coded to a single thread. //--- if (theThreadEnv) { theThreadEnv->terminate(NULL, true); theThreadEnv->destroy(); } else { theThreadEnv = new kdu_thread_env(); } theThreadEnv->create(); // Creates the single "owner" thread // Check for threads in prefs file. ossim_uint32 threads = 1; const char* lookup = ossimPreferences::instance()->findPreference("kakadu_threads"); if ( lookup ) { threads = ossimString::toUInt32(lookup); if ( threads > 1 ) { for (ossim_uint32 nt=1; nt < threads; ++nt) { if ( !theThreadEnv->add_thread() ) { if (traceDebug()) { ossimNotify(ossimNotifyLevel_WARN) << "Unable to create thread!\n"; } } } } } theOpenTileThreadQueue = theThreadEnv->add_queue(NULL,NULL,"open_tile_q"); theCodestream.create(this, theThreadEnv); if ( theCodestream.exists() ) { //--- // We have to store things here in this non-const method because // NONE of the kakadu methods are const. //--- theMinDwtLevels = theCodestream.get_min_dwt_levels(); theCodestream.set_persistent(); // ???? theCodestream.enable_restart(); // ???? kdu_dims region_of_interest; region_of_interest.pos.x = 0; region_of_interest.pos.y = 0; region_of_interest.size.x = getNumberOfSamples(0); region_of_interest.size.y = getNumberOfLines(0); theCodestream.apply_input_restrictions( 0, // first_component 0, // max_components (0 = all remaining will appear) 0, // highest resolution level 0, // max_layers (0 = all layers retained) ®ion_of_interest, // expanded out to block boundary. //KDU_WANT_CODESTREAM_COMPONENTS); KDU_WANT_OUTPUT_COMPONENTS); // Set the scalar: theScalarType = theSizRecord.getScalarType(); if (theScalarType != OSSIM_SCALAR_UNKNOWN) { //--- // NOTE: Please leave commented out code for now. //--- // Capture the sub image offset. // theSubImageOffset.x = theSizRecord.theXOsiz; // theSubImageOffset.y = theSizRecord.theYOsiz; // Initialize the image rect. theImageRect = ossimIrect(0, 0, theSizRecord.theXsiz-1, theSizRecord.theYsiz-1); // Initialize the cache. if (theCacheId != -1) { ossimAppFixedTileCache::instance()->deleteCache(theCacheId); theCacheId = -1; } ossimIpt tileSize(theSizRecord.theXTsiz, theSizRecord.theYTsiz); // Stretch to tile boundary for the cache. ossimIrect fullImgRect = theImageRect; fullImgRect.stretchToTileBoundary(tileSize); // Set up the tile cache. theCacheId = ossimAppFixedTileCache::instance()-> newTileCache(fullImgRect, tileSize); // Add the sub image rect after the // Initialize the tile we will return. initializeTile(); // Call the base complete open to pick up overviews. completeOpen(); // We should be good now so set the return result to true. result = true; if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << "\nSIZ marker segment" << theSizRecord << "theCodestream.get_num_components(false): " << theCodestream.get_num_components(false) << "\ntheCodestream.get_num_components(true): " << theCodestream.get_num_components(true) << "\ntheCodestream.get_bit_depth(0, true): " << theCodestream.get_bit_depth(0, true) << "\ntheCodestream.get_signed(0, true): " << theCodestream.get_signed(0, true) << "\ntheCodestream.get_min_dwt_levels(): " << theCodestream.get_min_dwt_levels() << "\ntheImageRect: " << theImageRect << "\nFull image rect: " << fullImgRect << "\nthreads: " << threads << "\n"; vector<ossimDpt> decimations; getDecimationFactors(decimations); for (ossim_uint32 i = 0; i < decimations.size(); ++i) { ossimNotify(ossimNotifyLevel_DEBUG) << theCodestream.get_min_dwt_levels() << "Decimation factor[" << i << "]: " << decimations[i] << "\nsamples[" << i << "]: " << getNumberOfSamples(i) << "\nlines[" << i << "]: " << getNumberOfLines(i) << std::endl; } } } } // matches: if ( theCodestream.exists() ) } // matches: if ( (soc == SOC_MARKER) && (siz == SIZ_MARKER) ) } // matches: if ( theFileStr.good() ) else { if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " ERROR:" << "\nCannot open: " << theImageFile.c_str() << endl; } } if (traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " exit status = " << (result?"true":"false\n") << std::endl; } 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; }
bool FWSingle::run() { Estimators->start(weightLength,1); fillIDMatrix(); //we do this once because we only want to link parents to parents if we need to // if (verbose>1) app_log()<<" getting weights for generation "<<gensTransferred<<endl; vector<vector<vector<int> > > WeightHistory; WeightHistory.push_back(Weights); for(int ill=1; ill<weightLength; ill++) { transferParentsOneGeneration(); FWOneStep(); WeightHistory.push_back(Weights); } if (verbose>0) app_log()<<" Done Computing Weights"<<endl; int nprops = H.sizeOfObservables();//local energy, local potnetial and all hamiltonian elements int FirstHamiltonian = H.startIndex(); vector<vector<vector<RealType> > > savedValues; int nelectrons = W[0]->R.size(); int nfloats=OHMMS_DIM*nelectrons; ForwardWalkingData fwer; fwer.resize(nelectrons); // MCWalkerConfiguration* savedW = new MCWalkerConfiguration(W); for(int step=0; step<numSteps; step++) { vector<float> ALLcoordinates; readInFloat(step,ALLcoordinates); vector<float> SINGLEcoordinate(nfloats); vector<float>::iterator fgg(ALLcoordinates.begin()), fgg2(ALLcoordinates.begin()+nfloats); W.resetCollectables(); vector<vector<RealType> > stepObservables; for(int wstep=0; wstep<walkersPerBlock[step]; wstep++) { std::copy( fgg,fgg2,SINGLEcoordinate.begin()); fwer.fromFloat(SINGLEcoordinate); W.R=fwer.Pos; fgg+=nfloats; fgg2+=nfloats; W.update(); RealType logpsi(Psi.evaluateLog(W)); RealType eloc=H.evaluate( W ); // (*W[0]).resetProperty(logpsi,1,eloc); H.auxHevaluate(W); H.saveProperty(W.getPropertyBase()); vector<RealType> walkerObservables(nprops+2,0); walkerObservables[0]= eloc; walkerObservables[1]= H.getLocalPotential(); const RealType* restrict ePtr = W.getPropertyBase(); for(int i=0; i<nprops; i++) walkerObservables[i+2] = ePtr[FirstHamiltonian+i] ; stepObservables.push_back(walkerObservables); } savedValues.push_back(stepObservables); } for(int ill=0; ill<weightLength; ill++) { Estimators->startBlock(1); Estimators->accumulate(savedValues,WeightHistory[ill],getNumberOfSamples(ill)); Estimators->stopBlock(getNumberOfSamples(ill)); } Estimators->stop(); return true; }
void rspfRpfTocEntry::getBoundingRect(rspfIrect& rect) const { rect = rspfIrect(0, 0, getNumberOfSamples()-1, getNumberOfLines()-1); }
ossimProjection* ossimMrSidReader::getGeoProjection() { if (theReader == 0) return 0; // A local KWL will be filled as items are read from the support data. At the end, // the projection factory will be provided with the populated KWL to instantiate proper // map projection. No prefix needed. ossimKeywordlist kwl; // Add the lines and samples. kwl.add(ossimKeywordNames::NUMBER_LINES_KW, getNumberOfLines(0)); kwl.add(ossimKeywordNames::NUMBER_SAMPLES_KW, getNumberOfSamples(0)); ossimString proj_type; ossimString datum_type; ossimString scale_units; ossimString tie_pt_units = "meters"; ossim_uint32 code = 0; ossim_uint32 gcsCode = 0; ossim_uint32 pcsCode = 0; const LTIGeoCoord& geo = theReader->getGeoCoord(); LTIMetadataDatabase metaDb = theReader->getMetadata(); const char* projStr = geo.getWKT(); // Can only handle non-rotated images since only projection object returned (no 2d transform): if( (geo.getXRot() != 0.0) || (geo.getYRot() != 0.0)) return 0; bool gcsFound = getMetadataElement(metaDb, "GEOTIFF_NUM::2048::GeographicTypeGeoKey", &gcsCode); bool pcsFound = getMetadataElement(metaDb, "GEOTIFF_NUM::3072::ProjectedCSTypeGeoKey", &pcsCode); if (gcsFound && pcsCode == false) { code = gcsCode; kwl.add(ossimKeywordNames::TYPE_KW, "ossimEquDistCylProjection"); proj_type = "ossimEquDistCylProjection"; kwl.add(ossimKeywordNames::GCS_CODE_KW, code); tie_pt_units = "degrees"; // Assign units if set in Metadata char unitStr[200]; if (getMetadataElement(metaDb, "GEOTIFF_CHAR::GeogAngularUnitsGeoKey", &unitStr, sizeof(unitStr)) == true) { ossimString unitTag(unitStr); if ( unitTag.contains("Angular_Degree") ) // decimal degrees scale_units = "degrees"; else if ( unitTag.contains("Angular_Minute") ) // decimal minutes scale_units = "minutes"; else if ( unitTag.contains("Angular_Second") ) // decimal seconds scale_units = "seconds"; } } else { if (!pcsFound) { pcsFound = getMetadataElement(metaDb, "GEOTIFF_NUM::3074::ProjectionGeoKey", &code); } else { code = pcsCode; } if (pcsFound) { kwl.add(ossimKeywordNames::PCS_CODE_KW, code); tie_pt_units = "meters"; char unitStr[200]; if (getMetadataElement(metaDb, "GEOTIFF_CHAR::ProjLinearUnitsGeoKey", &unitStr, sizeof(unitStr))) { ossimString unitTag(unitStr); if ( unitTag.contains("Linear_Meter") ) scale_units = "meters"; else if ( unitTag.contains("Linear_Foot") ) scale_units = "feet"; else if ( unitTag.contains("Linear_Foot_US_Survey") ) scale_units = "us_survey_feet"; } } } char rasterTypeStr[200]; strcpy( rasterTypeStr, "unnamed" ); double topLeftX = geo.getX(); // AMBIGUOUS! OLK 5/10 double topLeftY = geo.getY(); // AMBIGUOUS! OLK 5/10 if (getMetadataElement(metaDb, "GEOTIFF_CHAR::GTRasterTypeGeoKey", &rasterTypeStr, sizeof(rasterTypeStr)) == true) { ossimString rasterTypeTag(rasterTypeStr); // If the raster type is pixel_is_area, shift the tie point by // half a pixel to locate it at the pixel center. if ( rasterTypeTag.contains("RasterPixelIsPoint") ) { topLeftX -= geo.getXRes() / 2.0; // AMBIGUOUS -- DOESN'T MATCH COMMENT! OLK 5/10 topLeftY += geo.getYRes() / 2.0; // AMBIGUOUS! OLK 5/10 } } ossimDpt gsd(fabs(geo.getXRes()), fabs(geo.getYRes())); ossimDpt tie(topLeftX, topLeftY); // CANNOT HANDLE 2D TRANSFORMS -- ONLY REAL PROJECTIONS. (OLK 5/10) //std::stringstream mString; //// store as a 4x4 matrix //mString << ossimString::toString(geo.getXRes(), 20) // << " " << ossimString::toString(geo.getXRot(), 20) // << " " << 0 << " " // << ossimString::toString(geo.getX(), 20) // << " " << ossimString::toString(geo.getYRot(), 20) // << " " << ossimString::toString(geo.getYRes(), 20) // << " " << 0 << " " // << ossimString::toString(geo.getY(), 20) // << " " << 0 << " " << 0 << " " << 1 << " " << 0 // << " " << 0 << " " << 0 << " " << 0 << " " << 1; //kwl.add(ossimKeywordNames::IMAGE_MODEL_TRANSFORM_MATRIX_KW, mString.str().c_str()); // if meta data does not have the code info, try to read from .aux file if (code == 0) { ossimFilename auxFile = theImageFile; auxFile.setExtension("aux"); ossimAuxFileHandler auxHandler; if (auxFile.exists() && auxHandler.open(auxFile)) { ossimString proj_name = auxHandler.getProjectionName(); ossimString datum_name = auxHandler.getDatumName(); ossimString unitType = auxHandler.getUnitType(); // HACK: Geographic projection is specified in non-WKT format. Intercepting here. OLK 5/10 // TODO: Need projection factory that can handle miscellaneous non-WKT specs as they are // encountered. if (proj_name.contains("Geographic")) { kwl.add(ossimKeywordNames::TYPE_KW, "ossimEquDistCylProjection", false); scale_units = "degrees"; tie_pt_units = "degrees"; } else { // pass along MrSid's projection name and pray it can be resolved: kwl.add(ossimKeywordNames::PROJECTION_KW, proj_name, false); if (unitType.empty()) { if (proj_name.downcase().contains("feet")) { scale_units = "feet"; tie_pt_units = "feet"; } } else { scale_units = unitType; tie_pt_units = unitType; } } // HACK: WGS-84 is specified in non-WKT format. Intercepting here. OLK 5/10 // TODO: Need datum factory that can handle miscellaneous non-WKT specs as they are // encountered. if (datum_name.contains("WGS") && datum_name.contains("84")) kwl.add(ossimKeywordNames::GCS_CODE_KW, "EPSG:4326"); else kwl.add(ossimKeywordNames::DATUM_KW, datum_name, false); } } kwl.add(ossimKeywordNames::PIXEL_SCALE_XY_KW, gsd.toString()); kwl.add(ossimKeywordNames::PIXEL_SCALE_UNITS_KW, scale_units); kwl.add(ossimKeywordNames::TIE_POINT_XY_KW, tie.toString()); kwl.add(ossimKeywordNames::TIE_POINT_UNITS_KW, tie_pt_units); ossimProjection* proj = ossimProjectionFactoryRegistry::instance()->createProjection(kwl); return proj; }
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; }