QGeoView icon indicating copy to clipboard operation
QGeoView copied to clipboard

QGVLayerTiles opacity

Open de-wu opened this issue 1 year ago • 1 comments

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?

de-wu avatar Feb 21 '24 12:02 de-wu

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.

AmonRaNet avatar Mar 12 '24 13:03 AmonRaNet