gvsig-osm / org.gvsig.raster.osm / trunk / org.gvsig.raster.osm / org.gvsig.raster.osm.app.osmclient / src / test / java / TestProjection.java @ 85
History | View | Annotate | Download (584 Bytes)
1 | 85 | nbrodin | |
---|---|---|---|
2 | public class TestProjection { |
||
3 | public static void main(String[] args) { |
||
4 | int zoom = 1; |
||
5 | double lat = -85d; |
||
6 | double lon = -180d; |
||
7 | System.out.println("http://tile.openstreetmap.org/" + getTileNumber(lat, lon, zoom) + ".png"); |
||
8 | } |
||
9 | public static String getTileNumber(final double lat, final double lon, final int zoom) { |
||
10 | int xtile = (int)Math.floor( (lon + 180) / 360 * (1<<zoom) ) ; |
||
11 | int ytile = (int)Math.floor( (1 - Math.log(Math.tan(Math.toRadians(lat)) + 1 / Math.cos(Math.toRadians(lat))) / Math.PI) / 2 * (1<<zoom) ) ; |
||
12 | return("" + zoom + "/" + xtile + "/" + ytile); |
||
13 | } |
||
14 | } |