Bug 314542 - PlacemarkLayout does not handle IDL correctly
Summary: PlacemarkLayout does not handle IDL correctly
Status: RESOLVED FIXED
Alias: None
Product: marble
Classification: Applications
Component: general (show other bugs)
Version: 1.6 (KDE 4.11)
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: marble-bugs
URL: https://forum.kde.org/viewtopic.php?f...
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-06 18:19 UTC by Dennis Nienhüser
Modified: 2013-04-17 21:28 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dennis Nienhüser 2013-02-06 18:19:22 UTC
Quoting the forum thread:
"3) Again, next issue occurs when displaying two boxes handling crossing the IDL - some placemarks may suddnely disappear from screen while the IDL is in view. However, though special case for IDL is provided, there are still disappearing placemarks, even with provided cities.txt / cityplacemarks.kml ! This is why another fix must be applied. Problem occurs in function PlacemarkLayout::visibleTiles (file PlacemarkLayout.cpp)."

Proposed fix:
QSet<TileId> PlacemarkLayout::visibleTiles( const ViewportParams *viewport ) const
{
    int zoomLevel = qLn( viewport->radius() *4 / 256 ) / qLn( 2.0 );

    /**
     * rely on m_placemarkCache to find the placemarks for the tiles which
     * matter. The top level tiles have the more popular placemarks,
     * the bottom level tiles have the smaller ones, and we only get the ones
     * matching our latLonAltBox.
     */

    QRect rect;
    qreal north, south, east, west;
    viewport->viewLatLonAltBox().boundaries(north, south, east, west);
    QSet<TileId> tileIdSet;                                                 ///+
    QVector<QRectF> frects;                                                 ///+
    if( west <= east )                                                      ///+
        frects << QRectF(west, north, east - west, south - north);          ///+
    else {                                                                  ///+
        frects << QRectF(west, north, M_PI - west, south - north);          ///+
        frects << QRectF(-M_PI, north, east + M_PI, south - north);         ///+
    }                                                                       ///+

    foreach( QRectF frect, frects ) {                                       ///+

        TileId key;
///-        key = TileId::fromCoordinates( GeoDataCoordinates(west, north, 0), zoomLevel);
        key = TileId::fromCoordinates( GeoDataCoordinates(frect.left(),     ///+
            north, 0), zoomLevel);                                          ///+
        rect.setLeft( key.x() );
        rect.setTop( key.y() );

///-        key = TileId::fromCoordinates( GeoDataCoordinates(east, south, 0), zoomLevel);
        key = TileId::fromCoordinates( GeoDataCoordinates(frect.right(),    ///+
            south, 0), zoomLevel);                                          ///+
        rect.setRight( key.x() );
        rect.setBottom( key.y() );

        TileCoordsPyramid pyramid( 0, zoomLevel );
        pyramid.setBottomLevelCoords( rect );

///-        QSet<TileId> tileIdSet;
        bool crossesDateLine = viewport->viewLatLonAltBox().crossesDateLine();
        for ( int level = pyramid.topLevel(); level <= pyramid.bottomLevel(); ++level ) {
            QRect const coords = pyramid.coords( level );
            int x1, y1, x2, y2;
            coords.getCoords( &x1, &y1, &x2, &y2 );
///-            if ( !crossesDateLine ) { // normal case, rect does not cross dateline
            for ( int x = x1; x <= x2; ++x ) {
                for ( int y = y1; y <= y2; ++y ) {
                    TileId const tileId( 0, level, x, y );
                    tileIdSet.insert(tileId);
                }
            }
///-            } else { // as we cross dateline, we first get west part, then east part
///-                // go till max tile
///-                for ( int x = x1; x <= ((2 << (level-1))-1); ++x ) {
///-                    for ( int y = y1; y <= y2; ++y ) {
///-                        TileId const tileId( 0, level, x, y );
///-                        tileIdSet.insert(tileId);
///-                    }
///-                }
///-                // start from min tile
///-                for ( int x = 0; x <= x2; ++x ) {
///-                    for ( int y = y1; y <= y2; ++y ) {
///-                        TileId const tileId( 0, level, x, y );
///-                        tileIdSet.insert(tileId);
///-                    }
///-                }
///-            }
        }
    }

    return tileIdSet;
}
Comment 1 Thibaut Gridel 2013-04-17 21:28:14 UTC
Git commit a7b9bcb1244fe147692624d6a70f8a24311cce4f by Thibaut Gridel.
Committed on 15/04/2013 at 19:09.
Pushed by tgridel into branch 'master'.

PlacemarkLayout: fix for IDL bug

M  +20   -29   src/lib/PlacemarkLayout.cpp

http://commits.kde.org/marble/a7b9bcb1244fe147692624d6a70f8a24311cce4f