summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Haag <[email protected]>2015-04-30 21:41:24 +0200
committerTorsten Rahn <[email protected]>2015-04-30 21:41:24 +0200
commit8bbed075fa66e9167a75bec2b9b0b014261c948e (patch)
tree25538b68b3dda420695ad9310d1b883c15a39f69
parent97f08cf12e6e02ab19f6d2cf2c5294c52f0e12d0 (diff)
Properly handle negative elevations
REVIEW: 123422
-rw-r--r--src/lib/marble/ElevationModel.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/lib/marble/ElevationModel.cpp b/src/lib/marble/ElevationModel.cpp
index b642078..b5fcb48 100644
--- a/src/lib/marble/ElevationModel.cpp
+++ b/src/lib/marble/ElevationModel.cpp
@@ -132,13 +132,12 @@ qreal ElevationModel::height( qreal lon, qreal lat ) const
Q_ASSERT( 0 <= dx && dx <= 1 );
Q_ASSERT( 0 <= dy && dy <= 1 );
- unsigned int pixel;
- pixel = image->pixel( x % width, y % height );
- pixel -= 0xFF000000; //fully opaque
+ unsigned int pixel = image->pixel( x % width, y % height ) & 0xffff; // 16 valid bits
+ short int elevation = (short int) pixel; // and signed type, so just cast it
//mDebug() << "(1-dx)" << (1-dx) << "(1-dy)" << (1-dy);
if ( pixel != invalidElevationData ) { //no data?
//mDebug() << "got at x" << x % width << "y" << y % height << "a height of" << pixel << "** RGB" << qRed(pixel) << qGreen(pixel) << qBlue(pixel);
- ret += ( qreal )pixel * ( 1 - dx ) * ( 1 - dy );
+ ret += ( qreal )elevation * ( 1 - dx ) * ( 1 - dy );
hasHeight = true;
} else {
//mDebug() << "no data at" << x % width << "y" << y % height;