geopackage-sdk/src/main/java/mil/nga/geopackage/tiles/TileGenerator.java
public int getTileCount() {
        if (tileCount == null) {
            long count = 0;

            boolean degrees = projection.isUnit(Units.DEGREES);
            ProjectionTransform transformToWebMercator = null;
            if (!degrees) {
                transformToWebMercator = projection.getTransformation(ProjectionConstants.EPSG_WEB_MERCATOR);
            }

            for (int zoom = minZoom; zoom <= maxZoom; zoom++) {

                BoundingBox expandedBoundingBox = getBoundingBox(zoom);

                // Get the tile grid that includes the entire bounding box
                TileGrid tileGrid = null;
                if (degrees) {
                    tileGrid = TileBoundingBoxUtils.getTileGridWGS84(expandedBoundingBox, zoom);
                } else {
                    tileGrid = TileBoundingBoxUtils.getTileGrid(expandedBoundingBox.transform(transformToWebMercator), zoom);
                }

                count += tileGrid.count();
                tileGrids.put(zoom, tileGrid);
                tileBounds.put(zoom, expandedBoundingBox);
            }

            tileCount = (int) Math.min(count, Integer.MAX_VALUE);
        }
        return tileCount;
    }
public int getTileCount() {
        if (tileCount == null) {
            long count = 0;

            boolean degrees = projection.isUnit(Units.DEGREES);
            ProjectionTransform transformToWebMercator = null;
            if (!degrees) {
                transformToWebMercator = projection.getTransformation(ProjectionConstants.EPSG_WEB_MERCATOR);
            }

            for (int zoom = minZoom; zoom <= maxZoom; zoom++) {

                BoundingBox expandedBoundingBox = getBoundingBox(zoom);

                // Get the tile grid that includes the entire bounding box
                TileGrid tileGrid = null;
                if (degrees) {
                    tileGrid = TileBoundingBoxUtils.getTileGridWGS84(expandedBoundingBox, zoom);
                } else {
                    tileGrid = TileBoundingBoxUtils.getTileGrid(expandedBoundingBox.transform(transformToWebMercator), zoom);
                }

                count += tileGrid.count();
                tileGrids.put(zoom, tileGrid);
                tileBounds.put(zoom, expandedBoundingBox);
            }

            tileCount = (int) Math.min(count, Integer.MAX_VALUE);
        }
        return tileCount;
    }
Get the tile count of tiles to be generated

@return tile count