diff --git a/pkg/bing/bing_test.go b/pkg/bing/bing_test.go index 002284fb..4f01790e 100644 --- a/pkg/bing/bing_test.go +++ b/pkg/bing/bing_test.go @@ -92,3 +92,11 @@ func TestLatLonClippingFuzz(t *testing.T) { } } } + +func TestIssue302(t *testing.T) { + // Requesting tile with zoom level > 63 crashes the server #302 + for z := uint64(0); z < 256; z++ { + tileX, tileY := PixelXYToTileXY(LatLongToPixelXY(33, -115, z)) + TileXYToBounds(tileX, tileY, z) + } +} diff --git a/pkg/bing/ext.go b/pkg/bing/ext.go index b9e73555..1ee06357 100644 --- a/pkg/bing/ext.go +++ b/pkg/bing/ext.go @@ -33,10 +33,10 @@ func TileXYToBounds(tileX, tileY int64, levelOfDetail uint64) (minLat, minLon, m maxLat, minLon = PixelXYToLatLong(pixelX, pixelY, levelOfDetail) pixelX, pixelY = TileXYToPixelXY(tileX+1, tileY+1) minLat, maxLon = PixelXYToLatLong(pixelX, pixelY, levelOfDetail) - if tileX%size == 0 { + if size == 0 || tileX%size == 0 { minLon = MinLongitude } - if tileX%size == size-1 { + if size == 0 || tileX%size == size-1 { maxLon = MaxLongitude } if tileY <= 0 {