Skip to content

Commit

Permalink
[opencl] Small optimization in hillshade
Browse files Browse the repository at this point in the history
... and more tolerant epsilon for float comparison in tests
  • Loading branch information
elpaso committed Aug 8, 2018
1 parent 8f40129 commit 78a45b7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/analysis/raster/qgshillshadefilter.cpp
Expand Up @@ -30,10 +30,16 @@ QgsHillshadeFilter::QgsHillshadeFilter( const QString &inputFile, const QString
=======
, mLightAzimuth( lightAzimuth )
, mLightAngle( lightAngle )
<<<<<<< 8f40129d09776c7fe96b88604405a908595f9ede
, mCosZenithRad( std::cos( mLightAngle * M_PI / 180.0 ) )
, mSinZenithRad( std::sin( mLightAngle * M_PI / 180.0 ) )
, mAzimuthRad( mLightAzimuth * M_PI / 180.0 )
>>>>>>> [opencl] Fix small OpenCL alg issues
=======
, mCosZenithRad( std::cos( mLightAngle * M_PI / 180.0f ) )
, mSinZenithRad( std::sin( mLightAngle * M_PI / 180.0f ) )
, mAzimuthRad( mLightAzimuth * M_PI / 180.0f )
>>>>>>> [opencl] Small optimization in hillshade
{
}

Expand Down Expand Up @@ -109,17 +115,9 @@ void QgsHillshadeFilter::addExtraRasterParams( std::vector<float> &params )
void QgsHillshadeFilter::addExtraRasterParams( std::vector<float> &params )
{

// Original CPU formula
float zenith_rad = mLightAngle * M_PI / 180.0;
float azimuth_rad = mLightAzimuth * M_PI / 180.0;
params.push_back( zenith_rad ); // 5
params.push_back( azimuth_rad ); // 6

/*
params.push_back( std::cos( mLightAngle * M_PI / 180.0 ) ); // cos_zenith_rad 5
params.push_back( mLightAzimuth * M_PI / 180.0 ); // azimuth_rad 6
params.push_back( std::sin( mLightAzimuth * M_PI / 180.0 ) ); // sin_zenith_rad 7
*/
params.push_back( mCosZenithRad ); // cos_zenith_rad 5
params.push_back( mSinZenithRad ); // sin_zenith_rad 6
params.push_back( mAzimuthRad ); // azimuth_rad 7

}
<<<<<<< 573283f0dcf022e84bd615e84fd2656043a9722b
Expand Down
4 changes: 4 additions & 0 deletions tests/src/analysis/testqgsninecellfilters.cpp
Expand Up @@ -185,11 +185,15 @@ void TestNineCellFilters::_rasterCompare( QgsAlignRaster::RasterInfo &out, QgsA
QCOMPARE( out.cellSize(), refCellSize );

// If the values differ less than tolerance they are considered equal
<<<<<<< 8f40129d09776c7fe96b88604405a908595f9ede
<<<<<<< 8689c401a2a66b4b159a54d0c37e26a33aa183c3
double tolerance = 0.0001;
=======
double tolerance = 0.0000001;
>>>>>>> [opencl] Increase test coverage with no-opencl image comparison
=======
double tolerance = 0.0001;
>>>>>>> [opencl] Small optimization in hillshade

// Check three points
std::map<int, int> controlPoints;
Expand Down

0 comments on commit 78a45b7

Please sign in to comment.