Fix tile with zoom level over 63 panics

fixes #302
This commit is contained in:
Josh Baker 2018-04-19 17:24:47 -07:00
parent d2da9ca6ee
commit 08afe004ae
2 changed files with 10 additions and 2 deletions

View File

@ -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)
}
}

View File

@ -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 {