@Test public void getTopLeftPointTest() { 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)); Point expectedPoint = new Point(0, 0); Assert.assertEquals(expectedPoint, MapPositionUtil.getTopLeftPoint(mapPosition, canvas.getDimension(), tileSize)); mapPosition = new MapPosition(new LatLong(0, 90), (byte) 1); expectedPoint = new Point(tileSize, (float) tileSize / 2); Assert.assertEquals(expectedPoint, MapPositionUtil.getTopLeftPoint(mapPosition, canvas.getDimension(), tileSize)); } }
public static Point getTopLeftPoint(MapPosition mapPosition, Dimension canvasDimension, int tileSize) { LatLong centerPoint = mapPosition.latLong; byte zoomLevel = mapPosition.zoomLevel; int halfCanvasWidth = canvasDimension.width / 2; int halfCanvasHeight = canvasDimension.height / 2; double pixelX = Math.round(MercatorProjection.longitudeToPixelX(centerPoint.longitude, zoomLevel, tileSize)); double pixelY = Math.round(MercatorProjection.latitudeToPixelY(centerPoint.latitude, zoomLevel, tileSize)); return new Point((int) pixelX - halfCanvasWidth, (int) pixelY - halfCanvasHeight); }
MapPositionUtil { public static Point getTopLeftPoint(MapPosition mapPosition, Dimension canvasDimension, int tileSize) { LatLong centerPoint = mapPosition.latLong; byte zoomLevel = mapPosition.zoomLevel; int halfCanvasWidth = canvasDimension.width / 2; int halfCanvasHeight = canvasDimension.height / 2; double pixelX = Math.round(MercatorProjection.longitudeToPixelX(centerPoint.longitude, zoomLevel, tileSize)); double pixelY = Math.round(MercatorProjection.latitudeToPixelY(centerPoint.latitude, zoomLevel, tileSize)); return new Point((int) pixelX - halfCanvasWidth, (int) pixelY - halfCanvasHeight); } }
MapPositionUtil { public static Point getTopLeftPoint(MapPosition mapPosition, Dimension canvasDimension, int tileSize) { LatLong centerPoint = mapPosition.latLong; byte zoomLevel = mapPosition.zoomLevel; int halfCanvasWidth = canvasDimension.width / 2; int halfCanvasHeight = canvasDimension.height / 2; double pixelX = Math.round(MercatorProjection.longitudeToPixelX(centerPoint.longitude, zoomLevel, tileSize)); double pixelY = Math.round(MercatorProjection.latitudeToPixelY(centerPoint.latitude, zoomLevel, tileSize)); return new Point((int) pixelX - halfCanvasWidth, (int) pixelY - halfCanvasHeight); } private  MapPositionUtil(); }
MapPositionUtil { public static Point getTopLeftPoint(MapPosition mapPosition, Dimension canvasDimension, int tileSize) { LatLong centerPoint = mapPosition.latLong; byte zoomLevel = mapPosition.zoomLevel; int halfCanvasWidth = canvasDimension.width / 2; int halfCanvasHeight = canvasDimension.height / 2; double pixelX = Math.round(MercatorProjection.longitudeToPixelX(centerPoint.longitude, zoomLevel, tileSize)); double pixelY = Math.round(MercatorProjection.latitudeToPixelY(centerPoint.latitude, zoomLevel, tileSize)); return new Point((int) pixelX - halfCanvasWidth, (int) pixelY - halfCanvasHeight); } private  MapPositionUtil(); static BoundingBox getBoundingBox(MapPosition mapPosition, Dimension canvasDimension, int tileSize); static Point getTopLeftPoint(MapPosition mapPosition, Dimension canvasDimension, int tileSize); }
MapPositionUtil { public static Point getTopLeftPoint(MapPosition mapPosition, Dimension canvasDimension, int tileSize) { LatLong centerPoint = mapPosition.latLong; byte zoomLevel = mapPosition.zoomLevel; int halfCanvasWidth = canvasDimension.width / 2; int halfCanvasHeight = canvasDimension.height / 2; double pixelX = Math.round(MercatorProjection.longitudeToPixelX(centerPoint.longitude, zoomLevel, tileSize)); double pixelY = Math.round(MercatorProjection.latitudeToPixelY(centerPoint.latitude, zoomLevel, tileSize)); return new Point((int) pixelX - halfCanvasWidth, (int) pixelY - halfCanvasHeight); } private  MapPositionUtil(); static BoundingBox getBoundingBox(MapPosition mapPosition, Dimension canvasDimension, int tileSize); static Point getTopLeftPoint(MapPosition mapPosition, Dimension canvasDimension, int tileSize);  }