Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#6932 closed defect (fixed)

gdaladdo generates invalid zoom levels for GPKG

Reported by: ariki Owned by: warmerdam
Priority: normal Milestone:
Component: default Version: 2.2.0
Severity: normal Keywords:
Cc:

Description

Steps to reproduce:

#!/usr/bin/sh

# Prepare test data
LEFT=500
BOTTOM=500
RIGHT=750
TOP=750
echo -e "${LEFT} ${BOTTOM} 50\n${RIGHT} ${BOTTOM} 100\n${LEFT} ${TOP} 150\n${RIGHT} ${TOP} 200\n" > test.xyz
gdalwarp -of GTiff -ot Byte -s_srs "EPSG:3857" -t_srs "EPSG:3857" \
    -te ${LEFT} ${BOTTOM} ${RIGHT} ${TOP} -tr 0.05 0.05 \
    -tap -r cubic test.xyz test.tif

# Create a GeoPackage
gdal_translate -of GPKG -ot Byte -co TILING_SCHEME=GoogleMapsCompatible test.tif test.gpkg

# Add overviews
gdaladdo test.gpkg 2 4 8 16 32 64 128 256

# Dump table gpkg_tile_matrix
sqlite3 -column -header test.gpkg "SELECT * FROM gpkg_tile_matrix ORDER BY zoom_level"

Output:

table_name  zoom_level  matrix_width  matrix_height  tile_width  tile_height  pixel_x_size      pixel_y_size    
----------  ----------  ------------  -------------  ----------  -----------  ----------------  ----------------
test        0           1             1              256         256          156543.033928041  156543.033928041
test        1           2             2              256         256          78271.5169640205  78271.5169640205
test        2           4             4              256         256          39135.7584820102  39135.7584820102
test        3           8             8              256         256          19567.8792410051  19567.8792410051
test        4           16            16             256         256          9783.93962050256  9783.93962050256
test        5           32            32             256         256          4891.96981025128  4891.96981025128
test        6           64            64             256         256          2445.98490512564  2445.98490512564
test        7           128           128            256         256          1222.99245256282  1222.99245256282
test        8           256           256            256         256          611.49622628141   611.49622628141 
test        9           512           512            256         256          305.748113140705  305.748113140705
test        10          1024          1024           256         256          152.874056570353  152.874056570353
test        11          2048          2048           256         256          76.4370282851763  76.4370282851763
test        12          4096          4096           256         256          38.2185141425881  38.2185141425881
test        13          8192          8192           256         256          19.1092570712941  19.1092570712941
test        14          16384         16384          256         256          9.55462853564703  9.55462853564703
test        15          32768         32768          256         256          4.77731426782352  4.77731426782352
test        16          65536         65536          256         256          2.38865713391176  2.38865713391176
test        17          1             1              256         256          9.55462853564703  9.55462853564703
test        18          1             1              256         256          4.77731426782351  4.77731426782351
test        19          1             1              256         256          2.38865713391176  2.38865713391176
test        20          131072        131072         256         256          1.19432856695588  1.19432856695588
test        21          262144        262144         256         256          0.59716428347793  0.59716428347793
test        22          524288        524288         256         256          0.29858214173897  0.29858214173897
test        23          1048576       1048576        256         256          0.14929107086948  0.14929107086948
test        24          2097152       2097152        256         256          0.07464553543474  0.07464553543474
test        25          4194304       4194304        256         256          0.03732276771737  0.03732276771737

Something strange happens starting from zoom level 17. The tiles in table "test" also have these invalid zoom level values.

Change History (3)

comment:1 by Even Rouault, 7 years ago

Resolution: fixed
Status: newclosed

In 39211:

GPKG: avoid corruption of gpkg_tile_matrix when building overviews, down to a level where they are smaller than the tile size (fixes #6932)

comment:2 by Even Rouault, 7 years ago

In 39212:

GPKG: avoid corruption of gpkg_tile_matrix when building overviews, down to a level where they are smaller than the tile size (fixes #6932)

comment:3 by Even Rouault, 7 years ago

In 39213:

GPKG: avoid corruption of gpkg_tile_matrix when building overviews, down to a level where they are smaller than the tile size (fixes #6932)

Note: See TracTickets for help on using tickets.