Changeset 857

Show
Ignore:
Timestamp:
01/23/08 17:56:10
Author:
robert
Message:

Introduce ValidValueOperator? to help catch no data values on DEMs that don't assign the non data value.

Added commandline and BuildOption? controls for toggle on/off the interpolation of source imagery and dems.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/include/vpb/BuildOptions

    r854 r857  
    101101        void setDefaultColor(const osg::Vec4& defaultColor) { _defaultColor = defaultColor; } 
    102102        const osg::Vec4& getDefaultColor() const { return _defaultColor; } 
     103 
     104        void setUseInterpolatedImagerySampling(bool flag) { _useInterpolatedImagerySampling = flag; } 
     105        bool getUseInterpolatedImagerySampling() const { return _useInterpolatedImagerySampling; } 
     106 
     107        void setUseInterpolatedTerrainSampling(bool flag) { _useInterpolatedTerrainSampling = flag; } 
     108        bool getUseInterpolatedTerrainSampling() const { return _useInterpolatedTerrainSampling; } 
    103109 
    104110        void setBuildOverlays(bool flag) { _buildOverlays = flag; } 
     
    263269        MipMappingMode                              _mipMappingMode; 
    264270        osg::ref_ptr<osg::CoordinateSystemNode>     _destinationCoordinateSystem; 
     271 
    265272        osg::Vec4                                   _defaultColor; 
     273        bool                                        _useInterpolatedImagerySampling; 
     274        bool                                        _useInterpolatedTerrainSampling; 
     275 
    266276        std::string                                 _archiveName; 
    267277        std::string                                 _comment; 
     
    279289        unsigned int                                _maximumTileTerrainSize; 
    280290         
     291         
    281292        unsigned int                                _distributedBuildSplitLevel; 
    282293        unsigned int                                _distributedBuildSecondarySplitLevel; 
  • trunk/src/vpb/BuildOptions.cpp

    r854 r857  
    3131    _decorateWithMultiTextureControl = true; 
    3232    _defaultColor.set(0.5f,0.5f,1.0f,1.0f); 
     33    _useInterpolatedImagerySampling = false; 
     34    _useInterpolatedTerrainSampling = false; 
    3335    _destinationCoordinateSystemString = ""; 
    3436    _destinationCoordinateSystem = new osg::CoordinateSystemNode;  
     
    99101    _decorateWithMultiTextureControl = rhs._decorateWithMultiTextureControl; 
    100102    _defaultColor = rhs._defaultColor; 
     103    _useInterpolatedImagerySampling = rhs._useInterpolatedImagerySampling; 
     104    _useInterpolatedTerrainSampling = rhs._useInterpolatedTerrainSampling; 
    101105    _destinationCoordinateSystemString = rhs._destinationCoordinateSystemString; 
    102106    _destinationCoordinateSystem = rhs._destinationCoordinateSystem; 
  • trunk/src/vpb/BuildOptionsIO.cpp

    r854 r857  
    187187        ADD_VEC4_PROPERTY(DefaultColor); 
    188188         
     189        ADD_BOOL_PROPERTY(UseInterpolatedImagerySampling); 
     190        ADD_BOOL_PROPERTY(UseInterpolatedTerrainSampling); 
     191         
    189192        ADD_STRING_PROPERTY(DestinationCoordinateSystem); 
    190193 
  • trunk/src/vpb/Commandline.cpp

    r854 r857  
    484484    usage.addCommandLineOption("--write-threads-ratio <ratio>","Set the ratio number of write threads relative to number of cores to use."); 
    485485    usage.addCommandLineOption("--build-options <string>","Set build options string."); 
     486    usage.addCommandLineOption("--interpolate-terrain","Enable the use of interpolation when sampling data from source DEMs."); 
     487    usage.addCommandLineOption("--no-interpolate-terrain","Disable the use of interpolation when sampling data from source DEMs."); 
     488    usage.addCommandLineOption("--interpolate-imagery","Enable the use of interpolation when sampling data from source imagery."); 
     489    usage.addCommandLineOption("--no-interpolate-imagery","Disable the use of interpolation when sampling data from source imagery."); 
    486490} 
    487491 
     
    560564    { 
    561565        buildOptions->setDisableWrites(true); 
     566    } 
     567 
     568    while(arguments.read("--interpolate-terrain")) 
     569    { 
     570        buildOptions->setUseInterpolatedTerrainSampling(true); 
     571    } 
     572 
     573    while(arguments.read("--interpolate-imagery")) 
     574    { 
     575        buildOptions->setUseInterpolatedImagerySampling(true); 
     576    } 
     577 
     578    while(arguments.read("--no-interpolate-terrain")) 
     579    { 
     580        buildOptions->setUseInterpolatedTerrainSampling(false); 
     581    } 
     582 
     583    while(arguments.read("--no-interpolate-imagery")) 
     584    { 
     585        buildOptions->setUseInterpolatedImagerySampling(false); 
    562586    } 
    563587 
  • trunk/src/vpb/SourceData.cpp

    r803 r857  
    2727using namespace vpb; 
    2828 
     29 
     30struct ValidValueOperator 
     31{ 
     32    ValidValueOperator(GDALRasterBand *band): 
     33        defaultValue(0.0f), 
     34        noDataValue(-32767.0f), 
     35        minValue(-32000.0f), 
     36        maxValue(FLT_MAX) 
     37    { 
     38        if (band) 
     39        { 
     40            int success = 0; 
     41            float value = band->GetNoDataValue(&success); 
     42            if (success) 
     43            { 
     44                noDataValue = value; 
     45            } 
     46        } 
     47    } 
     48 
     49    inline bool isNoDataValue(float value) 
     50    { 
     51        if (noDataValue==value) return true; 
     52        if (value<minValue) return true; 
     53        return (value>maxValue); 
     54    } 
     55     
     56    inline float getValidValue(float value) 
     57    { 
     58        if (isNoDataValue(value)) return value; 
     59        else return defaultValue; 
     60    } 
     61     
     62    float defaultValue; 
     63    float noDataValue; 
     64    float minValue; 
     65    float maxValue; 
     66}; 
     67 
     68 
    2969SourceData::~SourceData() 
    3070{ 
     
    102142    band->RasterIO(GF_Read, colMax, rowMax, 1, 1, &urHeight, 1, 1, GDT_Float32, 0, 0); 
    103143 
    104     int success = 0; 
    105     float noDataValue = band->GetNoDataValue(&success); 
    106     if (success) 
    107     { 
    108       if (llHeight == noDataValue) llHeight = 0.0f; 
    109       if (ulHeight == noDataValue) ulHeight = 0.0f; 
    110       if (lrHeight == noDataValue) lrHeight = 0.0f; 
    111       if (urHeight == noDataValue) urHeight = 0.0f; 
    112     } 
     144    ValidValueOperator validValueOperator(band); 
     145 
     146    if (validValueOperator.isNoDataValue(llHeight)) llHeight = 0.0f; 
     147    if (validValueOperator.isNoDataValue(ulHeight)) ulHeight = 0.0f; 
     148    if (validValueOperator.isNoDataValue(lrHeight)) lrHeight = 0.0f; 
     149    if (validValueOperator.isNoDataValue(urHeight)) urHeight = 0.0f; 
    113150 
    114151    double x_rem = c - (int)c; 
     
    465502            const float resizeTolerance = 1.1; 
    466503 
    467             bool interpolateSourceImagery = true; 
     504            bool interpolateSourceImagery = destination._dataSet->getUseInterpolatedImagerySampling(); 
     505 
     506             
    468507            if (interpolateSourceImagery &&  
    469508                (destWindowWidthRatio>resizeTolerance || destWindowHeightRatio>resizeTolerance) && 
     
    767806} 
    768807 
     808 
     809 
    769810void SourceData::readHeightField(DestinationData& destination) 
    770811{ 
     
    872913 
    873914 
     915                ValidValueOperator validValueOperator(bandSelected); 
     916 
    874917                int success = 0; 
    875                 float noDataValue = bandSelected->GetNoDataValue(&success); 
    876                 if (success) 
    877                 { 
    878                     log(osg::INFO,"We have NoDataValue = %f",noDataValue); 
    879                 } 
    880                 else 
    881                 { 
    882                     log(osg::INFO,"We have no NoDataValue"); 
    883                     noDataValue = 0.0f; 
    884                 } 
    885  
    886918                float offset = bandSelected->GetOffset(&success); 
    887919                if (success) 
     
    915947                bool ignoreNoDataValue = true; 
    916948 
    917                 bool interpolateTerrain = true; 
     949 
     950                bool interpolateTerrain = destination._dataSet->getUseInterpolatedTerrainSampling(); 
    918951 
    919952                if (interpolateTerrain) 
     
    935968                            double geoY = orig_Y + (delta_Y * (double)r); 
    936969                            float h = getInterpolatedValue(bandSelected, geoX-xoffset, geoY); 
    937                             if (h!=noDataValue) hf->setHeight(c,r,offset + h*scale); 
     970                            if (!validValueOperator.isNoDataValue(h)) hf->setHeight(c,r,offset + h*scale); 
    938971                            else if (!ignoreNoDataValue) hf->setHeight(c,r,noDataValueFill); 
    939972                        } 
     
    964997                        { 
    965998                            float h = *heightPtr++; 
    966                             if (h!=noDataValue) hf->setHeight(c,r,offset + h*scale); 
     999                            if (!validValueOperator.isNoDataValue(h)) hf->setHeight(c,r,offset + h*scale); 
    9671000                            else if (!ignoreNoDataValue) hf->setHeight(c,r,noDataValueFill); 
    9681001