if (tileWidth == 0 || tileHeight == 0) {
return codes;
}
// Calculate bounds relative to extents:
Bbox clippedBounds = bounds.intersection(layerBounds);
if (clippedBounds == null) {
// TODO throw error? If this is null, then the server configuration is incorrect.
GWT.log("Map bounds outside of layer extents, check the server configuration");
return codes;
}
double relativeBoundX = Math.abs(clippedBounds.getX() - layerBounds.getX());
double relativeBoundY = Math.abs(clippedBounds.getY() - layerBounds.getY());
currentMinX = (int) Math.floor(relativeBoundX / tileWidth);
currentMinY = (int) Math.floor(relativeBoundY / tileHeight);
currentMaxX = (int) Math.ceil((relativeBoundX + clippedBounds.getWidth()) / tileWidth) - 1;
currentMaxY = (int) Math.ceil((relativeBoundY + clippedBounds.getHeight()) / tileHeight) - 1;
// Now fill the list with the correct codes:
for (int x = currentMinX; x <= currentMaxX; x++) {
for (int y = currentMinY; y <= currentMaxY; y++) {
codes.add(new TileCode(currentTileLevel, x, y));