https://bugs.kde.org/show_bug.cgi?id=461569
Torsten Rahn <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] Status|REPORTED |CONFIRMED Ever confirmed|0 |1 --- Comment #1 from Torsten Rahn <[email protected]> --- Yes, the current implementation of void MarbleAbstractPresenter::centerOn(const GeoDataLatLonBox &box, bool animated) is only a rough approximation. In order to center on a boundingbox internally Marble needs to center on the center point and adjust the zoom level (which is internally tied to the pixel-radius that a fully rendered earth would cover in terms of vertical extent). Since Marble allows for usage of different projections the actual calculation of the zoom level would hard to calculate in a generic way. So the only "better" option would be to iteratively approximate the optimal zoom level (while either working on a copy of the view parameters or turning off rendering during the iterative convergence towards the optimal zoom level). The current code looks like this: void MarbleAbstractPresenter::centerOn(const GeoDataLatLonBox &box, bool animated) { if (box.isEmpty()) { return; } int newRadius = radius(); ViewportParams* viewparams = map()->viewport(); //prevent divide by zero if(box.height() && box.width()) { //work out the needed zoom level int const horizontalRadius = ( 0.25 * M_PI ) * (viewparams->height() / box.height()); int const verticalRadius = ( 0.25 * M_PI ) * (viewparams->width() / box.width()); newRadius = qMin<int>(horizontalRadius, verticalRadius ); newRadius = qMax<int>(radius(minimumZoom()), qMin<int>(newRadius, radius(maximumZoom()))); } //move the map GeoDataLookAt target; target.setCoordinates(box.center()); target.setAltitude(box.center().altitude()); target.setRange(KM2METER * distanceFromRadius(newRadius)); flyTo(target, animated ? Automatic : Instant); } Any suggestions for improvements welcome. -- You are receiving this mail because: You are watching all bug changes.
