//--- // For std::sort of ElevationDatabaseListType // e.g.: std::sort( dbList.begin(), dbList.end(), dbSort ); //--- bool dbSort(ossimRefPtr<ossimElevationDatabase> a, ossimRefPtr<ossimElevationDatabase> b) { bool result = false; if ( a.valid() && b.valid() ) { result = ( a->getMeanSpacingMeters() < b->getMeanSpacingMeters() ); } return result; }
template <class T> void ossimTiledElevationDatabase::fillGrid(T /* dummyTemplate */, ossimRefPtr<ossimImageData> data) { if ( data.valid() ) { // Copy to grid reversing the lines as the ossimDblGrid's origin is the SW corner. const ossim_float64 NP = data->getNullPix(0); const T* buf = static_cast<T*>(data->getBuf(0)); if ( buf ) { const ossimIpt SIZE( data->getWidth(), data->getHeight() ); ossim_int32 bufIdx = (SIZE.y-1) * data->getWidth(); ossim_int32 grdY = 0; for (ossim_int32 y = SIZE.y-1; y >= 0; --y) { for (ossim_int32 x = 0; x < SIZE.x; ++ x) { ossim_float64 v = static_cast<ossim_float64>(buf[bufIdx+x]); m_grid->setNode(x, grdY, (v!=NP?v:ossim::nan()) ); } bufIdx -= data->getWidth(); ++grdY; } } } }
void ossimImageUtil::createHistogram(ossimRefPtr<ossimImageHandler>& ih) { static const char M[] = "ossimImageUtil::createHistogram #1"; if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << M << " entered...\n"; } if ( ih.valid() ) { // Get the entry list: std::vector<ossim_uint32> entryList; ih->getEntryList(entryList); bool useEntryIndex = false; if ( entryList.size() ) { if ( (entryList.size() > 1) || (entryList[0] != 0) ) useEntryIndex = true; } for(ossim_uint32 idx = 0; idx < entryList.size(); ++idx) { createHistogram(ih, entryList[idx], useEntryIndex); } } if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << M << " exited...\n"; } }
void ossimLasReader::setProperty(ossimRefPtr<ossimProperty> property) { if ( property.valid() ) { if ( property->getName() == SCALE_KW ) { ossimString s; property->valueToString(s); ossim_float64 d = s.toFloat64(); if ( ossim::isnan(d) == false ) { setScale( d ); } } else if ( property->getName() == SCAN_KW ) { ossimString s; property->valueToString(s); m_scan = s.toBool(); } else { ossimImageHandler::setProperty(property); } } }
bool ossimOpjCompressor::setProperty(ossimRefPtr<ossimProperty> property) { bool consumed = false; if ( property.valid() ) { ossimString key = property->getName(); if ( traceDebug() ) { ossimNotify(ossimNotifyLevel_DEBUG) << "ossimOpjCompressor::setProperty DEBUG:" << "\nkey: " << key << " values: " << property->valueToString() << std::endl; } if (key == ossimKeywordNames::COMPRESSION_QUALITY_KW) { setQualityTypeString(property->valueToString()); consumed = true; } else if ( (key == LEVELS_KW) || (key == "Clevels") ) { m_levels = property->valueToString().toInt32(); consumed = true; } else if( (key == REVERSIBLE_KW) || (key == "Creversible") ) { setReversibleFlag(property->valueToString().toBool()); consumed = true; } else if (key == ADD_ALPHA_CHANNEL_KW) { m_alpha = property->valueToString().toBool(); consumed = true; } else if ( key == THREADS_KW) { m_threads = property->valueToString().toInt32(); consumed = true; } else if ( (key == "Clayers") || (key == "Cprecincts") ) { // Generic options passed through kdu_params::parse_string. // Make in the form of "key=value" for kdu_params::parse_string. ossimString option = key; option += "="; option += property->valueToString(); // Add to list. m_options.push_back(option); consumed = true; } } return consumed; }
void ossimPlanetQtLegendItem::recursiveAdd(QTreeWidgetItem* parent, const ossimRefPtr<ossimXmlNode> node) { if(!node.valid()) { return; } const std::vector<ossimRefPtr<ossimXmlNode> >& childNodes = node->getChildNodes(); if(childNodes.size() == 0) { QTreeWidgetItem* item = new QTreeWidgetItem(parent); item->setText(0, node->getTag().c_str()); item->setText(1, node->getText().c_str()); } else { ossim_uint32 idx = 0; ossim_uint32 idxMax = 0; idxMax = childNodes.size(); QTreeWidgetItem* item = new QTreeWidgetItem(parent); item->setText(0, node->getTag().c_str()); item->setText(1, node->getText().c_str()); for(idx = 0; idx < idxMax; ++idx) { recursiveAdd(item, childNodes[idx]); } } }
void ossimTiledElevationDatabase::getBoundingRect( ossimRefPtr<ossimImageGeometry> geom, ossimGrect& boundingRect) const { if ( geom.valid() ) { std::vector<ossimGpt> corner(4); if ( geom->getCornerGpts(corner[0], corner[1], corner[2], corner[3]) ) { ossimGpt ulGpt(corner[0]); ossimGpt lrGpt(corner[0]); for ( ossim_uint32 i = 1; i < 4; ++i ) { if ( corner[i].lon < ulGpt.lon ) ulGpt.lon = corner[i].lon; if ( corner[i].lat > ulGpt.lat ) ulGpt.lat = corner[i].lat; if ( corner[i].lon > lrGpt.lon ) lrGpt.lon = corner[i].lon; if ( corner[i].lat < lrGpt.lat ) lrGpt.lat = corner[i].lat; } boundingRect = ossimGrect(ulGpt, lrGpt); } else { boundingRect.makeNan(); } } }
// Create overview for image: void ossimImageUtil::createOverview(ossimRefPtr<ossimImageHandler>& ih, bool& consumedHistogramOptions, bool& /* consumedCmmOptions */) { static const char M[] = "ossimImageUtil::createOverview #1"; if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << M << " entered...\n"; } if ( ih.valid() ) { // Get the entry list: std::vector<ossim_uint32> entryList; ih->getEntryList(entryList); bool useEntryIndex = false; if ( entryList.size() ) { if ( (entryList.size() > 1) || (entryList[0] != 0) ) useEntryIndex = true; } // Create the overview builder: ossimString overviewType; getOverviewType( overviewType.string() ); ossimRefPtr<ossimOverviewBuilderBase> ob = ossimOverviewBuilderFactoryRegistry::instance()->createBuilder(overviewType); if ( ob.valid() ) { // Set up any overview builder options that don't involve histograms. ossimPropertyInterface* pi = dynamic_cast<ossimPropertyInterface*>( ob.get() ); if ( pi ) setProps(pi); ossim_uint32 stopDimension = getOverviewStopDimension(); if ( stopDimension ) ob->setOverviewStopDimension(stopDimension); ob->setScanForMinMax( scanForMinMax() ); ob->setScanForMinMaxNull( scanForMinMaxNull() ); for(ossim_uint32 idx = 0; idx < entryList.size(); ++idx) { createOverview(ih, ob, entryList[idx], useEntryIndex, consumedHistogramOptions); } } else { ossimNotify(ossimNotifyLevel_WARN) << "ERROR:\nCould not create builder for: "<< overviewType << std::endl; outputOverviewWriterTypes(); } } if(traceDebug()) { ossimNotify(ossimNotifyLevel_DEBUG) << M << " exited...\n"; } }
ossim_uint32 ossimMultiResLevelHistogram::getNumberOfBands(ossim_uint32 resLevel) const { const ossimRefPtr<ossimMultiBandHistogram> h = getMultiBandHistogram(resLevel); if (h.valid()) { return h->getNumberOfBands(); } return 0; }
void ossimKakaduNitfWriter::setProperty(ossimRefPtr<ossimProperty> property) { if ( property.valid() ) { if ( m_compressor->setProperty(property) == false ) { // Not a compressor property. ossimNitfWriterBase::setProperty(property); } } }
const ossimRefPtr<ossimHistogram> ossimMultiResLevelHistogram::getHistogram(ossim_uint32 band, ossim_uint32 resLevel)const { const ossimRefPtr<ossimMultiBandHistogram> temp = getMultiBandHistogram(resLevel); if(temp.valid()) { return temp->getHistogram(band); } return (ossimHistogram*)0; }
void ossimRgbImage::setCurrentImageData(ossimRefPtr<ossimImageData>& imageData) { if(imageData.valid()) { if((imageData->getScalarType() == OSSIM_UCHAR)&& (imageData->getDataObjectStatus()!=OSSIM_NULL)) { theImageData = imageData; initialize(); } } }
ossimRefPtr<ossimNBandLutDataObject> ossimNitfImageHeader::createLut( ossim_uint32 bandIdx)const { ossimRefPtr<ossimNBandLutDataObject> result; if(bandIdx < (ossim_uint32)getNumberOfBands()) { const ossimRefPtr<ossimNitfImageBand> band = getBandInformation(bandIdx); if(band.valid()) { ossim_uint32 bands = band->getNumberOfLuts(); if(bands > 0) { if(band->getLut(0).valid()) { ossim_uint32 entries = band->getLut(0)->getNumberOfEntries(); result = new ossimNBandLutDataObject(); result->create(entries, band->getNumberOfLuts()); ossim_uint32 bIdx; ossim_uint32 entryIdx; for(bIdx = 0; bIdx < bands; ++bIdx) { const ossimRefPtr<ossimNitfImageLut> lut = band->getLut(bIdx); if(lut.valid()) { for(entryIdx = 0; entryIdx < entries; ++entryIdx) { (*result)[entryIdx][bIdx] = (ossimNBandLutDataObject::LUT_ENTRY_TYPE)(lut->getValue(entryIdx)); } } } } } } } return result; }
bool ossimImageUtil::hasRequiredOverview( ossimRefPtr<ossimImageHandler>& ih, ossimRefPtr<ossimOverviewBuilderBase>& ob ) { bool result = false; if ( ih.valid() && ob.valid() && ( getCopyAllFlag() == false ) ) { if ( ih->getClassName() == "ossimCcfTileSource" ) { // CCF reader does not use external overviews. result = true; } else { // Note we always have one rset ossim_uint32 required = 1; ossim_uint32 startingResLevel = ih->getNumberOfDecimationLevels(); ossim_uint32 overviewStopDimension = ob->getOverviewStopDimension(); ossim_uint32 largestImageDimension = ih->getNumberOfSamples(0) > ih->getNumberOfLines(0) ? ih->getNumberOfSamples(0) : ih->getNumberOfLines(0); while(largestImageDimension > overviewStopDimension) { largestImageDimension /= 2; ++required; } if ( startingResLevel >= required ) { result = true; } } } return result; }
virtual ~MosaicImageChain() { if(theReprojection.valid()) { theReprojection->disconnect(); theReprojection = 0; } if(theHistogramRemapper.valid()) { theHistogramRemapper->disconnect(); theHistogramRemapper = 0; } if(theBandSelector.valid()) { theBandSelector->disconnect(); theBandSelector = 0; } if(theHandler.valid()) { theHandler->disconnect(); theHandler = 0; } }
void ossimMaskFilter::setProperty(ossimRefPtr<ossimProperty> property) { if( property.valid() ) { if(property->getName() == MASK_FILTER_MASK_TYPE_KW) { setMaskType(property->valueToString()); } else { ossimImageCombiner::setProperty(property); } } }
void ossimPlanetQtLegendAnimationPathItem::loadXml(ossimRefPtr<ossimXmlNode> node, std::vector<ossimPlanetOperation*>& activityList) { if(!node.valid()) return; ossimString tempValue; if(node->getChildTextValue(tempValue, "name")) { setText(0, tempValue.c_str()); } if(node->getChildTextValue(tempValue, "path")) { setAnimationPathFromString(tempValue); } }
// Private method: bool ossimTiledElevationDatabase::isDirectoryBasedImage(ossimRefPtr<ossimImageHandler> ih) { bool result = false; if ( ih.valid() ) { // Get the image handler name. ossimString imageHandlerName = ih->getClassName(); if ( (imageHandlerName == "ossimAdrgTileSource") || (imageHandlerName == "ossimCibCadrgTileSource") ) { result = true; } } return result; }
void ossimPngReader::setProperty(ossimRefPtr<ossimProperty> property) { if ( property.valid() ) { if ( property->getName().string() == USE_ALPHA_KW ) { ossimString s; property->valueToString(s); m_useAlphaChannelFlag = s.toBool(); } else { ossimImageHandler::setProperty(property); } } }
void ossimIndexToRgbLutFilter::setProperty(ossimRefPtr<ossimProperty> property) { if(property.valid()) { ossimString value = property->valueToString(); value = value.trim(); if(property->getName() == "LUT file") { setLut(ossimFilename(property->valueToString())); } else { ossimImageSourceFilter::setProperty(property); } } }
ossimRefPtr<ossimImageData> ossimFixedTileCache::addTile(ossimRefPtr<ossimImageData> imageData, bool duplicateData) { OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex); ossimRefPtr<ossimImageData> result = NULL; if(!imageData.valid()) { return result; } if(!imageData->getBuf()) { return result; } ossim_int32 id = computeId(imageData->getOrigin()); if(id < 0) { return result; } std::map<ossim_int32, ossimFixedTileCacheInfo>::iterator tileIter = theTileMap.find(id); if(tileIter==theTileMap.end()) { if(duplicateData) { result = (ossimImageData*)imageData->dup(); } else { result = imageData; } ossimFixedTileCacheInfo cacheInfo(result, id); theCacheSize += imageData->getDataSizeInBytes(); theTileMap.insert(make_pair(id, cacheInfo)); if(theUseLruFlag) { theLruQueue.push_back(id); } } return result; }
void ossimQtScrollingImageWidget::fillImage(ossimRefPtr<ossimImageData>& data, QImage* tempImage) { if(data.valid() && data->getBuf() && !tempImage->isNull()) { ossim_uint8* buf[3]; int numberOfBands = data->getNumberOfBands(); int aWidth = tempImage->size().width(); int aHeight = tempImage->size().height(); int maxPixels = aWidth*aHeight; int offset; if(numberOfBands >= 3) { buf[0] = static_cast<ossim_uint8*>(data->getBuf(0)); buf[1] = static_cast<ossim_uint8*>(data->getBuf(1)); buf[2] = static_cast<ossim_uint8*>(data->getBuf(2)); } else { buf[0] = static_cast<ossim_uint8*>(data->getBuf(0)); buf[1] = static_cast<ossim_uint8*>(data->getBuf(0)); buf[2] = static_cast<ossim_uint8*>(data->getBuf(0)); } QRgb *bits = (QRgb*)tempImage->bits(); if(tempImage->bits()) { for(offset = 0; offset < maxPixels;++offset) { *bits = qRgb(*buf[0], *buf[1], *buf[2]); ++buf[0];++buf[1];++buf[2]; ++bits; } } else { tempImage->fill(0); } } else { tempImage->fill(0); } }
ossimRefPtr<ossimProperty> ossimNitfFileHeader::getProperty(const ossimString& name)const { ossimRefPtr<ossimProperty> result = 0; if(name == TAGS_KW) { ossim_uint32 idxMax = (ossim_uint32)theTagList.size(); if(idxMax > 0) { ossimContainerProperty* containerProperty = new ossimContainerProperty; containerProperty->setName(name); ossim_uint32 idx = 0; result = containerProperty; for(idx = 0; idx < idxMax; ++idx) { ossimNitfTagInformation tagInfo; getTagInformation(tagInfo, idx); const ossimRefPtr<ossimNitfRegisteredTag> tagData = tagInfo.getTagData(); if(tagData.valid()) { ossimContainerProperty* containerPropertyTag = new ossimContainerProperty; containerPropertyTag->setName(tagInfo.getTagName()); std::vector<ossimRefPtr<ossimProperty> > propertyList; tagData->getPropertyList(propertyList); containerPropertyTag->addChildren(propertyList); containerProperty->addChild(containerPropertyTag); } else { containerProperty->addStringProperty(tagInfo.getTagName(), "", true); } } } } return result; }
void ossimRangeDomeTileSource::setProperty(ossimRefPtr<ossimProperty> property) { if (!property.valid()) return; ossimString s; property->valueToString(s); if (s.empty()) return; // The user should select either explicit GSD or relative GSD factor, never both: if ( property->getName() == ossimKeywordNames::METERS_PER_PIXEL_KW ) { ossim_float64 gsd = s.toFloat64(); if (!ossim::isnan(gsd)) setGSD(gsd); } else { ossimImageHandler::setProperty(property); } }
bool ossim::findFirstNode(const ossimString& path, ossimRefPtr<ossimXmlNode> node, ossimString& s) { bool result = false; if ( node.valid() ) { ossimRefPtr<ossimXmlNode> n = node->findFirstNode(path); if ( n.valid() ) { s = n->getText(); if ( s.size() ) { result = true; } else { if(!traceDebug()) { ossimNotify(ossimNotifyLevel_WARN) << "ossim::findFirstNode ERROR:\n" << "Node empty: " << path << std::endl; } } } else { if(!traceDebug()) { ossimNotify(ossimNotifyLevel_WARN) << "ossim::findFirstNode ERROR:\n" << "Node not found: " << path << std::endl; } } } return result; }
void ossimOutlierRejection::setProperty(ossimRefPtr<ossimProperty> property) { if(!property.valid()) return; ossimString name = property->getName(); if(name == "inlier_output_filename") { theInlierOutputFilename = ossimFilename(property->valueToString()); } else if(name =="inlier_ratio") { setInlierRatio(property->valueToString().toDouble()); } else if(name == "inlier_image_accuracy") { setInlierImageAccuracy(property->valueToString().toDouble()); } else { ossimModelOptimizer::setProperty(property); } }
void ossimH5Reader::setProperty(ossimRefPtr<ossimProperty> property) { if ( property.valid() ) { if ( property->getName().string() == LAYER_KW ) { ossimString s; property->valueToString(s); ossim_uint32 SIZE = (ossim_uint32)m_entries.size(); for ( ossim_uint32 i = 0; i < SIZE; ++i ) { if ( m_entries[i].getName() == s.string() ) { setCurrentEntry( i ); } } } else { ossimImageHandler::setProperty(property); } } }
ossimGeoAnnotationBitmap::ossimGeoAnnotationBitmap( const ossimGpt& center, ossimRefPtr<ossimImageData> imageData, unsigned char r, unsigned char g, unsigned char b) :ossimGeoAnnotationObject(r, g, b), theCenterPoint(center), theProjectedPoint(0,0), theImageData(NULL) { if(imageData.valid() && (imageData->getScalarType()==OSSIM_UCHAR)) { theImageData = imageData; } else { ossimNotify(ossimNotifyLevel_WARN) << "ossimGeoAnnotationBitmap::ossimGeoAnnotationBitmap\n" << "Invalid image data passed to ossimGeoAnnotationBitmap " << "constructor" << endl; } }
bool ossimNitfImageHeader::hasLut() const { bool result = false; const ossim_uint32 BANDS = static_cast<ossim_uint32>(getNumberOfBands()); for (ossim_uint32 band = 0; band < BANDS; ++band) { const ossimRefPtr<ossimNitfImageBand> imgBand = getBandInformation(band); if(imgBand.valid()) { ossim_uint32 luts = imgBand->getNumberOfLuts(); if(luts > 0) { if(imgBand->getLut(0).valid()) { result = true; break; } } } } return result; }
int main( int argc, char* argv[] ) { enum { PASSED = 0, FAILED = 1 }; int status = PASSED; ossimArgumentParser ap(&argc, argv); ossimInit::instance()->addOptions(ap); ossimInit::instance()->initialize(ap); try { ossimIrect rect(0,0,255,255); ossimRefPtr<ossimImageData> srcTile = new ossimImageData(0, OSSIM_UINT16, 1, 256, 256); srcTile->initialize(); srcTile->setImageRectangle( rect ); // Set max for conversion to 8 bit. srcTile->setMaxPix( 255, 0 ); ossim_uint16* src = srcTile->getUshortBuf(); const ossim_uint32 LINES = 256; const ossim_uint32 SAMPLES = 256; ossim_uint32 s = 0; // line loop for(ossim_uint32 line = 0; line < LINES; ++line) { // sample loop for(ossim_uint32 samp = 0; samp < SAMPLES; ++samp) { src[samp] = s; } src += SAMPLES; ++s; } ossimRefPtr<ossimImageData> destTile = new ossimImageData(0, OSSIM_UINT8, 1, 256, 256); destTile->initialize(); destTile->setImageRectangle( rect ); destTile->loadTile( srcTile.get() ); destTile->validate(); ossimRefPtr<ossimMultiBandHistogram> his = new ossimMultiBandHistogram( 1, 256, 0, 255 ); destTile->populateHistogram( his ); const ossimRefPtr<ossimHistogram> h = his->getHistogram( 0 ); if ( h.valid() ) { float count; for( ossim_uint32 i = 0; i < LINES; ++i ) { count = h->GetCount( static_cast<float>(i) ); if ( count != 256.0 ) { cerr << "bin[" << i << "]: count = " << count << "\nShould be 256..." << endl; status = FAILED; break; } } } else { status = FAILED; } } catch (const ossimException& e) { ossimNotify(ossimNotifyLevel_WARN) << e.what() << std::endl; status = FAILED; } cout << "ossim-loadtile-test: " << (status == PASSED ? "PASSED" : "FAILED") << endl; return status; }