@Test public void testGetTileFromCoordinate() { Tile tile = factory.findTileAtCoordinate(51, 7, new WebMercatorZoomLevel(5), createService()); TileService service = createService(); OSMTile expectedTile = new OSMTile(20, 15, new WebMercatorZoomLevel(5), service); Assert.assertEquals(expectedTile, tile); }
public Tile findTileAtCoordinate( double lon, double lat, ZoomLevel zoomLevel, TileService service) { lat = TileFactory.normalizeDegreeValue(lat, 90); lon = TileFactory.normalizeDegreeValue(lon, 180); lat = OSMTileFactory.moveInRange( lat, WebMercatorTileService.MIN_LATITUDE, WebMercatorTileService.MAX_LATITUDE); int xTile = (int) Math.floor((lon + 180) / 360 * (1 << zoomLevel.getZoomLevel())); int yTile = (int) Math.floor( (1 - Math.log( Math.tan(lat * Math.PI / 180) + 1 / Math.cos( lat * Math .PI / 180)) / Math.PI) / 2 * (1 << zoomLevel.getZoomLevel())); if (yTile < 0) yTile = 0; return new OSMTile(xTile, yTile, zoomLevel, service); }
OSMTileFactory extends WebMercatorTileFactory { public Tile findTileAtCoordinate( double lon, double lat, ZoomLevel zoomLevel, TileService service) { lat = TileFactory.normalizeDegreeValue(lat, 90); lon = TileFactory.normalizeDegreeValue(lon, 180); lat = OSMTileFactory.moveInRange( lat, WebMercatorTileService.MIN_LATITUDE, WebMercatorTileService.MAX_LATITUDE); int xTile = (int) Math.floor((lon + 180) / 360 * (1 << zoomLevel.getZoomLevel())); int yTile = (int) Math.floor( (1 - Math.log( Math.tan(lat * Math.PI / 180) + 1 / Math.cos( lat * Math .PI / 180)) / Math.PI) / 2 * (1 << zoomLevel.getZoomLevel())); if (yTile < 0) yTile = 0; return new OSMTile(xTile, yTile, zoomLevel, service); } }
OSMTileFactory extends WebMercatorTileFactory { public Tile findTileAtCoordinate( double lon, double lat, ZoomLevel zoomLevel, TileService service) { lat = TileFactory.normalizeDegreeValue(lat, 90); lon = TileFactory.normalizeDegreeValue(lon, 180); lat = OSMTileFactory.moveInRange( lat, WebMercatorTileService.MIN_LATITUDE, WebMercatorTileService.MAX_LATITUDE); int xTile = (int) Math.floor((lon + 180) / 360 * (1 << zoomLevel.getZoomLevel())); int yTile = (int) Math.floor( (1 - Math.log( Math.tan(lat * Math.PI / 180) + 1 / Math.cos( lat * Math .PI / 180)) / Math.PI) / 2 * (1 << zoomLevel.getZoomLevel())); if (yTile < 0) yTile = 0; return new OSMTile(xTile, yTile, zoomLevel, service); }  }
OSMTileFactory extends WebMercatorTileFactory { public Tile findTileAtCoordinate( double lon, double lat, ZoomLevel zoomLevel, TileService service) { lat = TileFactory.normalizeDegreeValue(lat, 90); lon = TileFactory.normalizeDegreeValue(lon, 180); lat = OSMTileFactory.moveInRange( lat, WebMercatorTileService.MIN_LATITUDE, WebMercatorTileService.MAX_LATITUDE); int xTile = (int) Math.floor((lon + 180) / 360 * (1 << zoomLevel.getZoomLevel())); int yTile = (int) Math.floor( (1 - Math.log( Math.tan(lat * Math.PI / 180) + 1 / Math.cos( lat * Math .PI / 180)) / Math.PI) / 2 * (1 << zoomLevel.getZoomLevel())); if (yTile < 0) yTile = 0; return new OSMTile(xTile, yTile, zoomLevel, service); }  Tile findTileAtCoordinate(
            double lon, double lat, ZoomLevel zoomLevel, TileService service); static double moveInRange(double value, double min, double max); Tile findRightNeighbour(Tile tile, TileService service); @Override Tile findLowerNeighbour(Tile tile, TileService service); }
OSMTileFactory extends WebMercatorTileFactory { public Tile findTileAtCoordinate( double lon, double lat, ZoomLevel zoomLevel, TileService service) { lat = TileFactory.normalizeDegreeValue(lat, 90); lon = TileFactory.normalizeDegreeValue(lon, 180); lat = OSMTileFactory.moveInRange( lat, WebMercatorTileService.MIN_LATITUDE, WebMercatorTileService.MAX_LATITUDE); int xTile = (int) Math.floor((lon + 180) / 360 * (1 << zoomLevel.getZoomLevel())); int yTile = (int) Math.floor( (1 - Math.log( Math.tan(lat * Math.PI / 180) + 1 / Math.cos( lat * Math .PI / 180)) / Math.PI) / 2 * (1 << zoomLevel.getZoomLevel())); if (yTile < 0) yTile = 0; return new OSMTile(xTile, yTile, zoomLevel, service); }  Tile findTileAtCoordinate(
            double lon, double lat, ZoomLevel zoomLevel, TileService service); static double moveInRange(double value, double min, double max); Tile findRightNeighbour(Tile tile, TileService service); @Override Tile findLowerNeighbour(Tile tile, TileService service);  }