The current way (layer.dataProvider().xSize() & layer.dataProvider().ySize()) was returning 0 / False for some combinaison of raster width and height. Using and instead of & solve the issue:
Explanation:
10 & 15 # return 10 / True
10 & 16 # return 0 / False
# In binary representation:
# 10 => 01010
# 15 => 01111
# 16 => 10000
# So a bitwise AND will return :
01010 & 01111 # return 01010 or simply 10 (once converted back to decimals) / True
01010 & 10000 # return 00000 or simply 0 / False
# But a logical AND will return:
10 and 15 # return 15 / True
10 and 16 # return 16 / True
The provider type is now checked to make sure no WMS raster layer or similar are passing through, only thoses read by GDAL. However, I'm not sure if it covers all cases. Should fix #18.
The current way (
layer.dataProvider().xSize() & layer.dataProvider().ySize()
) was returning 0 / False for some combinaison of raster width and height. Usingand
instead of&
solve the issue:Explanation: