GeoTIFF / georaster-layer-for-leaflet

Display GeoTIFFs and soon other types of raster on your Leaflet Map
https://geotiff.github.io/georaster-layer-for-leaflet-example/
Apache License 2.0
297 stars 58 forks source link

Scattered tiles in version 3.x #75

Closed vlach1989 closed 3 years ago

vlach1989 commented 3 years ago

I'm trying to reproduce following example: https://geotiff.github.io/georaster-layer-for-leaflet-example/examples/load-cog-via-script-tag.html wrapped with React-Leaflet

It works as expected in version 2.0.2. However, both in version 3.0.2 and 3.1.1 (the latest) the tiles are somehow scattered or missing:

image

I found out, that at least the calculated position for some tiles is wrong or padding is too big.

DanielJDufour commented 3 years ago

Hi, @vlach1989 . Thanks for sharing this. Would you be able to share the code you are using? Also, what browser are you using? Thank you!

vlach1989 commented 3 years ago

Hi, I have the problem both in Chrome 92 and Firefox 91.

As I said, I'm using the library together with React-Leaflet:

class CogLayer extends MapLayer {
    createLeafletElement(props) {
        const {georaster, paneName, options} = props;

        return new GeoRasterLayer({
            georaster,
            pane: paneName,
            resolution: 128,
            pixelValuesToColorFn: this.getStyle.bind(this),
        });
    }

    updateLeafletElement(fromProps, toProps) {
        super.updateLeafletElement(fromProps, toProps);
    }

    getStyle(pixelValues) {
        // TODO multiple bands
        const pixelValue = pixelValues[0]; // there's just one band in this raster

        if (pixelValue === 0) return null;

        // TODO scales, values, intervals
        return '#000000';
    }
}

export default withLeaflet(CogLayer);
geojs commented 3 years ago

@vlach1989 I had the same issue (Leaflet 1.7.1 + Chromium 93), the last version of georaster-layer-for-leaflet v3.2.0 fix the issue.

vlach1989 commented 3 years ago

I confirm, that v3.2.0 fixes the issue

DanielJDufour commented 3 years ago

Glad to hear it!