Changeset 857
- Timestamp:
- 01/23/08 17:56:10
- Files:
-
- trunk/include/vpb/BuildOptions (modified) (3 diffs)
- trunk/src/vpb/BuildOptions.cpp (modified) (2 diffs)
- trunk/src/vpb/BuildOptionsIO.cpp (modified) (1 diff)
- trunk/src/vpb/Commandline.cpp (modified) (2 diffs)
- trunk/src/vpb/SourceData.cpp (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/include/vpb/BuildOptions
r854 r857 101 101 void setDefaultColor(const osg::Vec4& defaultColor) { _defaultColor = defaultColor; } 102 102 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; } 103 109 104 110 void setBuildOverlays(bool flag) { _buildOverlays = flag; } … … 263 269 MipMappingMode _mipMappingMode; 264 270 osg::ref_ptr<osg::CoordinateSystemNode> _destinationCoordinateSystem; 271 265 272 osg::Vec4 _defaultColor; 273 bool _useInterpolatedImagerySampling; 274 bool _useInterpolatedTerrainSampling; 275 266 276 std::string _archiveName; 267 277 std::string _comment; … … 279 289 unsigned int _maximumTileTerrainSize; 280 290 291 281 292 unsigned int _distributedBuildSplitLevel; 282 293 unsigned int _distributedBuildSecondarySplitLevel; trunk/src/vpb/BuildOptions.cpp
r854 r857 31 31 _decorateWithMultiTextureControl = true; 32 32 _defaultColor.set(0.5f,0.5f,1.0f,1.0f); 33 _useInterpolatedImagerySampling = false; 34 _useInterpolatedTerrainSampling = false; 33 35 _destinationCoordinateSystemString = ""; 34 36 _destinationCoordinateSystem = new osg::CoordinateSystemNode; … … 99 101 _decorateWithMultiTextureControl = rhs._decorateWithMultiTextureControl; 100 102 _defaultColor = rhs._defaultColor; 103 _useInterpolatedImagerySampling = rhs._useInterpolatedImagerySampling; 104 _useInterpolatedTerrainSampling = rhs._useInterpolatedTerrainSampling; 101 105 _destinationCoordinateSystemString = rhs._destinationCoordinateSystemString; 102 106 _destinationCoordinateSystem = rhs._destinationCoordinateSystem; trunk/src/vpb/BuildOptionsIO.cpp
r854 r857 187 187 ADD_VEC4_PROPERTY(DefaultColor); 188 188 189 ADD_BOOL_PROPERTY(UseInterpolatedImagerySampling); 190 ADD_BOOL_PROPERTY(UseInterpolatedTerrainSampling); 191 189 192 ADD_STRING_PROPERTY(DestinationCoordinateSystem); 190 193 trunk/src/vpb/Commandline.cpp
r854 r857 484 484 usage.addCommandLineOption("--write-threads-ratio <ratio>","Set the ratio number of write threads relative to number of cores to use."); 485 485 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."); 486 490 } 487 491 … … 560 564 { 561 565 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); 562 586 } 563 587 trunk/src/vpb/SourceData.cpp
r803 r857 27 27 using namespace vpb; 28 28 29 30 struct 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 29 69 SourceData::~SourceData() 30 70 { … … 102 142 band->RasterIO(GF_Read, colMax, rowMax, 1, 1, &urHeight, 1, 1, GDT_Float32, 0, 0); 103 143 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; 113 150 114 151 double x_rem = c - (int)c; … … 465 502 const float resizeTolerance = 1.1; 466 503 467 bool interpolateSourceImagery = true; 504 bool interpolateSourceImagery = destination._dataSet->getUseInterpolatedImagerySampling(); 505 506 468 507 if (interpolateSourceImagery && 469 508 (destWindowWidthRatio>resizeTolerance || destWindowHeightRatio>resizeTolerance) && … … 767 806 } 768 807 808 809 769 810 void SourceData::readHeightField(DestinationData& destination) 770 811 { … … 872 913 873 914 915 ValidValueOperator validValueOperator(bandSelected); 916 874 917 int success = 0; 875 float noDataValue = bandSelected->GetNoDataValue(&success);876 if (success)877 {878 log(osg::INFO,"We have NoDataValue = %f",noDataValue);879 }880 else881 {882 log(osg::INFO,"We have no NoDataValue");883 noDataValue = 0.0f;884 }885 886 918 float offset = bandSelected->GetOffset(&success); 887 919 if (success) … … 915 947 bool ignoreNoDataValue = true; 916 948 917 bool interpolateTerrain = true; 949 950 bool interpolateTerrain = destination._dataSet->getUseInterpolatedTerrainSampling(); 918 951 919 952 if (interpolateTerrain) … … 935 968 double geoY = orig_Y + (delta_Y * (double)r); 936 969 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); 938 971 else if (!ignoreNoDataValue) hf->setHeight(c,r,noDataValueFill); 939 972 } … … 964 997 { 965 998 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); 967 1000 else if (!ignoreNoDataValue) hf->setHeight(c,r,noDataValueFill); 968 1001
