AmonRaNet / QGeoView

QGeoView is a Qt / C ++ widget for visualizing geographic data.
GNU Lesser General Public License v3.0
155 stars 60 forks source link

QGVLayerTiles opacity #46

Open de-wu opened 8 months ago

de-wu commented 8 months ago

I've problem with layer tiles opacity. When I set opacity lower than 1.0, lines between tiles become visible. I think that's caused by old tiles in the background. Is it any solution for this problem?

AmonRaNet commented 8 months ago

I think I know reason. When I have developed online layer (tiles) I found bad behavior in QGraphicsView. Neighbor tiles during zoom starts to get free space in-between (1 pixel) - right/bottom edge. And it was not because of wrong coordinates of tiles, but because of zoom itself. Most likely is because of rounding (scene to display pixels). In any case it was looking really bad.

Here is example: Screenshot_38

To fix it I have added extra code to adjust size (by 1 display pixel) of image every time when zoom is changed:

in QGVImage::projPaint

    if (!isFlag(QGV::ItemFlag::IgnoreScale)) {
        const double pixelFactor = 1.0 / getMap()->getCamera().scale();
        paintRect.setSize(paintRect.size() + QSizeF(pixelFactor, pixelFactor));
    }

As result there are no gaps, but when opacity changed most likely you will see opposite of problem (1 pixel overlap).

You can find better solution to solve both problems or at least you can remote this code for your version.

Please share results.