diff --git a/src/osgTerrain/DataSet.cpp b/src/osgTerrain/DataSet.cpp index ff595def4..a2ff1c8ed 100644 --- a/src/osgTerrain/DataSet.cpp +++ b/src/osgTerrain/DataSet.cpp @@ -64,14 +64,14 @@ CoordinateSystemType getCoordinateSystemType(const osg::CoordinateSystemNode* lh - std::cout<<"getCoordinateSystemType("<GetValue(),"GEOCCS")==0) osg::notify(osg::INFO)<<" lhsSR. is GEOCENTRIC "<GetValue(),"GEOCCS")==0) return GEOCENTRIC; @@ -94,7 +94,7 @@ double getAngularUnits(const osg::CoordinateSystemNode* lhs) char* str; double result = lhsSR.GetAngularUnits(&str); - std::cout<<"lhsSR.GetAngularUnits("<_geoTransform.set( 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, @@ -306,7 +308,7 @@ const DataSet::SpatialProperties& DataSet::SourceData::computeSpatialProperties( if (_gdalDataSet) { - //std::cout<<"Projecting bounding volume for "<<_source->getFileName()<getFileName()<getType()) { case(Source::IMAGE): - std::cout<<"B.1"<s()*(intersect_bb.xMax()-d_bb.xMin())/(d_bb.xMax()-d_bb.xMin())),(int)destination._image->s())-destX; int destHeight = osg::minimum((int)ceilf((float)destination._image->t()*(intersect_bb.yMax()-d_bb.yMin())/(d_bb.yMax()-d_bb.yMin())),(int)destination._image->t())-destY; - std::cout<<" copying from "<GetRasterCount(); @@ -468,7 +470,7 @@ void DataSet::SourceData::readImage(DestinationData& destination) int lineSpace=-(int)(destination._image->getRowSizeInBytes()); unsigned char* imageData = destination._image->data(destX,destY+destHeight-1); - std::cout << "reading RGB"<getNumColumns()*(intersect_bb.xMax()-d_bb.xMin())/(d_bb.xMax()-d_bb.xMin())),(int)destination._heightField->getNumColumns())-destX; int destHeight = osg::minimum((int)ceilf((float)destination._heightField->getNumRows()*(intersect_bb.yMax()-d_bb.yMin())/(d_bb.yMax()-d_bb.yMin())),(int)destination._heightField->getNumRows())-destY; - std::cout<<" copying from "<GetUnitType()) std::cout << "bandSelected->GetUnitType()=" << bandSelected->GetUnitType()<GetUnitType()= null" <GetUnitType()) osg::notify(osg::INFO) << "bandSelected->GetUnitType()=" << bandSelected->GetUnitType()<GetUnitType()= null" <GetNoDataValue(&success); if (success) { - std::cout<<"We have NoDataValue = "<GetOffset(&success); if (success) { - std::cout<<"We have Offset = "<GetScale(&success); if (success) { - std::cout<<"We have Scale = "<getConvertFromGeographicToGeocentric()*/) ? 1.0f/111319.0f : 1.0f; } - std::cout<<"********* getLinearUnits = "<RasterIO(GF_Read,windowX,_numValuesY-(windowY+windowHeight),windowWidth,windowHeight,floatdata,destWidth,destHeight,GDT_Float32,numBytesPerZvalue,lineSpace); bandSelected->RasterIO(GF_Read,windowX,_numValuesY-(windowY+windowHeight),windowWidth,windowHeight,heightData,destWidth,destHeight,GDT_Float32,0,0); - std::cout<<" scaling height field"<_cs = _cs; - std::cout<<"assigning CS from Source to Data."<_cs; - std::cout<<"assigning CS from Data to Source."<_geoTransform = _geoTransform; - std::cout<<"assigning GeoTransform from Source to Data."<<_geoTransform<_geoTransform = _geoTransform; - std::cout<<"assigning GeoTransform from Source to Data."<<_geoTransform<_geoTransform; - std::cout<<"assigning GeoTransform from Data to Source."<<_geoTransform<computeExtents(); @@ -786,13 +788,13 @@ bool DataSet::Source::needReproject(const osg::CoordinateSystemNode* cs, double // always need to reproject imagery with GCP's. if (_sourceData->_hasGCPs) { - std::cout<<"Need to to reproject due to presence of GCP's"<0.0f) { - std::cout<<"recomputing the target transform size"<getCoordinateSystem()<getCoordinateSystem()<padfSrcNoDataReal[i] = noDataValue; psWO->padfSrcNoDataImag[i] = 0.0; @@ -1028,7 +1030,7 @@ DataSet::Source* DataSet::Source::doReproject(const std::string& filename, osg:: double new_noDataValue = 0.0; if (success) { - std::cout<<"\tassinging no data value "<padfSrcNoDataReal[i] = noDataValue; psWO->padfSrcNoDataImag[i] = 0.0; @@ -1069,7 +1071,7 @@ DataSet::Source* DataSet::Source::doReproject(const std::string& filename, osg:: GDALGetRasterYSize( hDstDS ) ); } - std::cout<<"new projection is "<getMaxLevel()<_level) + Source* source = itr->get(); + if (!source || source->getMaxLevel()<_level) { // skip the contribution of this source since this destination tile exceeds its contribution level. continue; } - SourceData* data = (*itr)->getSourceData(); - if (data && (*itr)->getType()!=Source::MODEL) + SourceData* data = source->getSourceData(); + if (data && source->getType()!=Source::MODEL) { SpatialProperties sp = data->computeSpatialProperties(_cs.get()); @@ -1321,10 +1323,10 @@ void DataSet::DestinationTile::allocate() _terrain->_heightField->setYInterval(dem_dy); //float xMax = _terrain->_heightField->getOrigin().x()+_terrain->_heightField->getXInterval()*(float)(dem_numColumns-1); - //std::cout<<"ErrorX = "<_image.get() : 0; osg::Image* image2 = tile2->_imagery.valid()?tile2->_imagery->_image.get() : 0; - //std::cout<<"Equalizing edge "<_level<<"\t"<_tileX<<"\t"<_tileY<getDataType()==GL_UNSIGNED_BYTE) { - //std::cout<<" Equalizing image1= "<data()<<" with data2 = 0x"<<(int)image2->data()<data()<<" with data2 = 0x"<<(int)image2->data()<data(image2->s()-1,1); // RIGHT hand side delta2 = image2->getRowSizeInBytes(); num = (image1->t()==image2->t())?image2->t()-2:0; // note miss out corners. - //std::cout<<" left "<data(1,0); // BELOW hand side @@ -1646,7 +1648,7 @@ void DataSet::DestinationTile::equalizeEdge(Position position) data2 = image2->data(1,image2->t()-1); // ABOVE hand side delta2 = 3; num = (image1->s()==image2->s())?image2->s()-2:0; // note miss out corners. - //std::cout<<" below "<data(image1->s()-1,1); // LEFT hand side @@ -1654,7 +1656,7 @@ void DataSet::DestinationTile::equalizeEdge(Position position) data2 = image2->data(0,1); // RIGHT hand side delta2 = image2->getRowSizeInBytes(); num = (image1->t()==image2->t())?image2->t()-2:0; // note miss out corners. - //std::cout<<" right "<data(1,image1->t()-1); // ABOVE hand side @@ -1662,10 +1664,10 @@ void DataSet::DestinationTile::equalizeEdge(Position position) data2 = image2->data(1,0); // BELOW hand side delta2 = 3; num = (image1->s()==image2->s())?image2->s()-2:0; // note miss out corners. - //std::cout<<" above "<setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR_MIPMAP_LINEAR); texture->setFilter(osg::Texture::MAG_FILTER,osg::Texture::LINEAR); } @@ -1887,8 +1888,6 @@ osg::StateSet* DataSet::DestinationTile::createStateSet() bool compressedImageSupported = inlineImageFile; bool mipmapImageSupported = inlineImageFile; - std::cout<<"__________________image->getPixelFormat()="<getPixelFormat()<getTextureType()==COMPRESSED_TEXTURE && (image->getPixelFormat()==GL_RGB || image->getPixelFormat()==GL_RGBA)) @@ -1912,7 +1911,7 @@ osg::StateSet* DataSet::DestinationTile::createStateSet() texture->setInternalFormatMode(osg::Texture::USE_IMAGE_DATA_FORMAT); - std::cout<<">>>>>>>>>>>>>>>compress image.<<<<<<<<<<<<<<"<>>>>>>>>>>>>>>compressed image.<<<<<<<<<<<<<<"<_image,_imagery->_image->getFileName().c_str()); } @@ -1943,7 +1942,7 @@ osg::Node* DataSet::DestinationTile::createHeightField() if (_terrain.valid() && _terrain->_heightField.valid()) { - std::cout<<"--- Have terrain build tile ----"<_heightField.get(); @@ -1953,7 +1952,7 @@ osg::Node* DataSet::DestinationTile::createHeightField() } else { - std::cout<<"**** No terrain to build tile from use flat terrain fallback ****"<allocate(2,2); @@ -2012,7 +2011,7 @@ static inline osg::Vec3 computeLocalSkirtVector(const osg::EllipsoidModel* et, c osg::Node* DataSet::DestinationTile::createPolygonal() { - std::cout<<"--------- DataSet::DestinationTile::createDrawableGeometry() ------------- "<getEllipsoidModel(); bool mapLatLongsToXYZ = _dataSet->getConvertFromGeographicToGeocentric() && et; @@ -2022,7 +2021,7 @@ osg::Node* DataSet::DestinationTile::createPolygonal() if (_terrain.valid() && _terrain->_heightField.valid()) { - std::cout<<"--- Have terrain build tile ----"<_heightField.get(); } else @@ -2039,7 +2038,7 @@ osg::Node* DataSet::DestinationTile::createPolygonal() if (longitude_range>45.0) numColumns = (unsigned int)ceilf((float)numColumns*sqrtf(longitude_range/45.0)); if (latitude_range>45.0) numRows = (unsigned int)ceilf((float)numRows*sqrtf(latitude_range/45.0)); - std::cout<<"numColumns = "<get(); - - if (_level>=source->getMinLevel() && _level<=source->getMaxLevel()) + if (source && _level>=source->getMinLevel() && _level<=source->getMaxLevel()) { SourceData* data = (*itr)->getSourceData(); if (data) { - std::cout<<"DataSet::DestinationTile::readFrom -> SourceData::read() "<getMinLevel()<<"\t"<getMaxLevel()< SourceData::read() "<getMinLevel()<<"\t"<getMaxLevel()<read(*_imagery); if (_terrain.valid()) data->read(*_terrain); } @@ -2512,8 +2510,7 @@ void DataSet::DestinationTile::addRequiredResolutions(CompositeSource* sourceGra for(CompositeSource::source_iterator itr(sourceGraph);itr.valid();++itr) { Source* source = itr->get(); - - if (source->intersects(*this)) + if (source && source->intersects(*this)) { if (source->getType()==Source::IMAGE) { @@ -2579,7 +2576,7 @@ void DataSet::CompositeDestination::addRequiredResolutions(CompositeSource* sour void DataSet::CompositeDestination::readFrom(CompositeSource* sourceGraph) { - std::cout<<"CompositeDestination::readFrom() "<get(); - std::cout<<" unref tile level="<_level<<" X="<_tileX<<" Y="<_tileY<_cs.valid()) { _destinationCoordinateSystem = sd->_cs; - std::cout<<"Setting coordinate system to "<<_destinationCoordinateSystem->getCoordinateSystem()<getCoordinateSystem()<getExtents(_intermediateCoordinateSystem.get())); - std::cout<<"local_extents = xMin()"<getSortValue() > rhs->getSortValue(); + return (lhs.valid() && rhs.valid()) && (lhs->getSortValue() > rhs->getSortValue()); } }; @@ -3316,7 +3313,7 @@ void DataSet::CompositeSource::sort() // sort the composite sources internal data for(ChildList::iterator itr=_children.begin();itr!=_children.end();++itr) { - (*itr)->sort(); + if (itr->valid()) (*itr)->sort(); } } @@ -3333,33 +3330,35 @@ void DataSet::updateSourcesForDestinationGraphNeeds() for(CompositeSource::source_iterator sitr(_sourceGraph.get());sitr.valid();++sitr) { Source* source = sitr->get(); - std::cout<<"Source File "<getFileName()<getRequiredResolutions(); - std::cout<<" resolutions.size() "<getFileName()<consolodateRequiredResolutions(); - - std::cout<<" consolodated resolutions.size() "<getRequiredResolutions(); + osg::notify(osg::INFO)<<" resolutions.size() "<consolodateRequiredResolutions(); + + osg::notify(osg::INFO)<<" consolodated resolutions.size() "<get(); - if (source->needReproject(_intermediateCoordinateSystem.get())) + if (source && source->needReproject(_intermediateCoordinateSystem.get())) { // do the reprojection to a tempory file. std::string newFileName = temporyFilePrefix + osgDB::getStrippedName(source->getFileName()) + ".tif"; @@ -3381,6 +3380,11 @@ void DataSet::updateSourcesForDestinationGraphNeeds() // replace old source by new one. if (newSource) *itr = newSource; + else + { + osg::notify(osg::WARN)<<"Failed to reproject"<getFileName()<get(); - source->buildOverviews(); + if (source) source->buildOverviews(); } } @@ -3399,8 +3403,11 @@ void DataSet::updateSourcesForDestinationGraphNeeds() for(CompositeSource::source_iterator itr(_sourceGraph.get());itr.valid();++itr) { Source* source = itr->get(); - source->setSortValueFromSourceDataResolution(); - std::cout<<"sort "<getFileName()<<" value "<getSortValue()<setSortValueFromSourceDataResolution(); + osg::notify(osg::INFO)<<"sort "<getFileName()<<" value "<getSortValue()<sort(); } - std::cout<<"Using source_lod_iterator itr"<getFileName()<get(); + if (source) + { + osg::notify(osg::INFO)<<" LOD "<<(*csitr)->getFileName()<get(); - std::cout<<" reading tile level="<_level<<" X="<_tileX<<" Y="<_tileY<get(); - std::cout<<" equalizing tile level="<_level<<" X="<_tileX<<" Y="<_tileY<getSubTileName(); if (node.valid()) { - std::cout<<" writeSubTile filename="<second); @@ -3615,10 +3632,12 @@ void DataSet::writeDestination() _writeRow(prev_itr->second); } } + osg::notify(osg::NOTICE)<<"completed DataSet::writeDestination("<