class WMSLayer extends AbstractModel implements ImageProvider<TileImageKey> {

    public Collection<GeographicBoundingBox> generateGrid(int level)
    {
        Vector2d cellDimensions = myLayerCellDimensions.get(level);

        double height;
        double width;
        final double minLat;
        final double minLon;
        final double maxLat;
        final double maxLon;
        GeographicBoundingBox bbox = myDataTypeInfo.getWmsConfig().getLayerConfig().getBoundingBoxConfig()
                .getGeographicBoundingBox();
        if (bbox == null || bbox.getDeltaLonD() > WORLD_WIDTH || bbox.getDeltaLatD() > WORLD_HEIGHT)
        {
            height = WORLD_HEIGHT;
            width = WORLD_WIDTH;
            minLat = -height * 0.5;
            minLon = -width * 0.5;
            maxLat = height * 0.5;
            maxLon = width * 0.5;
        }
        else
        {
            height = bbox.getDeltaLatD();
            width = bbox.getDeltaLonD();
            minLat = bbox.getLowerLeft().getLatLonAlt().getLatD();
            minLon = bbox.getLowerLeft().getLatLonAlt().getLonD();
            maxLat = bbox.getUpperRight().getLatLonAlt().getLatD();
            maxLon = bbox.getUpperRight().getLatLonAlt().getLonD();
        }

        int rows = (int)Math.ceil(height / cellDimensions.getY());
        int cols = (int)Math.ceil(width / cellDimensions.getX());
        List<GeographicBoundingBox> results = new ArrayList<>(rows * cols);
        double lat1 = minLat;
        for (int row = 0; row < rows;)
        {
            double lat2 = minLat + cellDimensions.getY() * ++row;
            if (lat2 > maxLat)
            {
                lat2 = maxLat;
            }
            double lon1 = minLon;
            for (int col = 0; col < cols;)
            {
                double lon2 = minLon + cellDimensions.getX() * ++col;
                if (lon2 > maxLon)
                {
                    lon2 = maxLon;
                }
                LatLonAlt lowerLeft = LatLonAlt.createFromDegrees(lat1, lon1);
                LatLonAlt upperRight = LatLonAlt.createFromDegrees(lat2, lon2);
                results.add(new GeographicBoundingBox(lowerLeft, upperRight));
                lon1 = lon2;
            }
            lat1 = lat2;
        }

        return results;
    }

    public  WMSLayer(Builder builder);

}