Commit 561cebf5 authored by Torsten Rahn's avatar Torsten Rahn
Browse files

- Backport possible division by zero and loop fixes.


svn path=/branches/KDE/4.3/kdeedu/marble/; revision=1003635
parent 8fff6353
......@@ -497,7 +497,7 @@ qreal MarbleMap::distance() const
// (about 800 pixels) equals the viewing angle of a human being.
const qreal VIEW_ANGLE = 110.0;
return ( model()->planet()->radius() * 0.4
/ (qreal)( radius() )
/ tan( 0.5 * VIEW_ANGLE * DEG2RAD ) );
......@@ -505,6 +505,13 @@ qreal MarbleMap::distance() const
void MarbleMap::setDistance( qreal distance )
{
qreal minDistance = 0.001;
if ( distance <= minDistance ) {
qDebug() << "Invalid distance: 0 m";
distance = minDistance;
}
const qreal VIEW_ANGLE = 110.0;
setRadius( (int)( model()->planet()->radius() * 0.4
......@@ -1203,6 +1210,7 @@ QString MarbleMap::distanceString() const
// reality. Therefore we assume that the average window width
// (about 800 pixels) equals the viewing angle of a human being.
//
qreal distance = ( model()->planet()->radius() * 0.4
/ (qreal)( radius() )
/ tan( 0.5 * VIEW_ANGLE * DEG2RAD ) );
......
......@@ -251,6 +251,10 @@ int MarbleWidget::radius() const
void MarbleWidget::setRadius(int radius)
{
if ( radius == d->m_map->radius() ) {
return;
}
d->m_map->setRadius( radius );
// We only have to repaint the background every time if the earth
......@@ -557,6 +561,13 @@ void MarbleWidget::centerOn( const GeoDataCoordinates &position, bool animated )
GeoDataCoordinates targetPosition = position;
targetPosition.setAltitude( distance() );
// Avoid zero distance
qreal minDistance = 0.001;
if ( targetPosition.altitude() <= minDistance ) {
targetPosition.setAltitude( minDistance );
}
d->m_physics->jumpTo( targetPosition );
} else {
qreal lon, lat;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment