### Question:
MapPositionUtil { public static BoundingBox getBoundingBox(MapPosition mapPosition, Dimension canvasDimension, int tileSize) { double pixelX = MercatorProjection.longitudeToPixelX(mapPosition.latLong.longitude, mapPosition.zoomLevel, tileSize); double pixelY = MercatorProjection.latitudeToPixelY(mapPosition.latLong.latitude, mapPosition.zoomLevel, tileSize); int halfCanvasWidth = canvasDimension.width / 2; int halfCanvasHeight = canvasDimension.height / 2; long mapSize = MercatorProjection.getMapSize(mapPosition.zoomLevel, tileSize); double pixelXMin = Math.max(0, pixelX - halfCanvasWidth); double pixelYMin = Math.max(0, pixelY - halfCanvasHeight); double pixelXMax = Math.min(mapSize, pixelX + halfCanvasWidth); double pixelYMax = Math.min(mapSize, pixelY + halfCanvasHeight); double minLatitude = MercatorProjection.pixelYToLatitude(pixelYMax, mapPosition.zoomLevel, tileSize); double minLongitude = MercatorProjection.pixelXToLongitude(pixelXMin, mapPosition.zoomLevel, tileSize); double maxLatitude = MercatorProjection.pixelYToLatitude(pixelYMin, mapPosition.zoomLevel, tileSize); double maxLongitude = MercatorProjection.pixelXToLongitude(pixelXMax, mapPosition.zoomLevel, tileSize); return new BoundingBox(minLatitude, minLongitude, maxLatitude, maxLongitude); } private  MapPositionUtil(); static BoundingBox getBoundingBox(MapPosition mapPosition, Dimension canvasDimension, int tileSize); static Point getTopLeftPoint(MapPosition mapPosition, Dimension canvasDimension, int tileSize);  }### Answer:
@Test public void getBoundingBoxTest() { for (int tileSize : TILE_SIZES) { MapPosition mapPosition = new MapPosition(new LatLong(0, 0), (byte) 0); Canvas canvas = GRAPHIC_FACTORY.createCanvas(); canvas.setBitmap(GRAPHIC_FACTORY.createBitmap(tileSize, tileSize)); double latitudeMin = MercatorProjection.LATITUDE_MIN; double latitudeMax = MercatorProjection.LATITUDE_MAX; BoundingBox expectedBoundingBox = new BoundingBox(latitudeMin, -180, latitudeMax, 180); Assert.assertEquals(expectedBoundingBox, MapPositionUtil.getBoundingBox(mapPosition, canvas.getDimension(), tileSize)); mapPosition = new MapPosition(new LatLong(0, 90), (byte) 0); expectedBoundingBox = new BoundingBox(latitudeMin, -90, latitudeMax, 180); Assert.assertEquals(expectedBoundingBox, MapPositionUtil.getBoundingBox(mapPosition, canvas.getDimension(), tileSize)); mapPosition = new MapPosition(new LatLong(90, -180), (byte) 0); expectedBoundingBox = new BoundingBox(0, -180, latitudeMax, 0); Assert.assertEquals(expectedBoundingBox, MapPositionUtil.getBoundingBox(mapPosition, canvas.getDimension(), tileSize)); } }