Changeset 6171 in josm for trunk/src/org/openstreetmap/josm/data/coor
- Timestamp:
- 2013-08-21T13:38:23+02:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/coor/QuadTiling.java
r4319 r6171 9 9 public static final int TILES_PER_LEVEL_SHIFT = 2; // Has to be 2. Other parts of QuadBuckets code rely on it 10 10 public static final int TILES_PER_LEVEL = 1<<TILES_PER_LEVEL_SHIFT; 11 static public final int X_PARTS = 360;12 static public final int X_BIAS = -180;11 public static final int X_PARTS = 360; 12 public static final int X_BIAS = -180; 13 13 14 static public final int Y_PARTS = 180;15 static public final int Y_BIAS = -90;14 public static final int Y_PARTS = 180; 15 public static final int Y_BIAS = -90; 16 16 17 public static LatLon tile2LatLon(long quad) 18 { 17 public static LatLon tile2LatLon(long quad) { 19 18 // The world is divided up into X_PARTS,Y_PARTS. 20 19 // The question is how far we move for each bit … … 44 43 return new LatLon(y, x); 45 44 } 46 static long xy2tile(long x, long y)47 {45 46 static long xy2tile(long x, long y) { 48 47 long tile = 0; 49 48 int i; … … 58 57 return tile; 59 58 } 60 static long coorToTile(LatLon coor)61 {59 60 static long coorToTile(LatLon coor) { 62 61 return quadTile(coor); 63 62 } 64 static long lon2x(double lon)65 {63 64 static long lon2x(double lon) { 66 65 //return Math.round((lon + 180.0) * QuadBuckets.WORLD_PARTS / 360.0)-1; 67 66 long ret = (long)((lon + 180.0) * WORLD_PARTS / 360.0); … … 71 70 return ret; 72 71 } 73 static long lat2y(double lat)74 {72 73 static long lat2y(double lat) { 75 74 //return Math.round((lat + 90.0) * QuadBuckets.WORLD_PARTS / 180.0)-1; 76 75 long ret = (long)((lat + 90.0) * WORLD_PARTS / 180.0); … … 80 79 return ret; 81 80 } 82 static public long quadTile(LatLon coor) 83 { 84 return xy2tile(lon2x(coor.lon()), 85 lat2y(coor.lat())); 81 82 public static long quadTile(LatLon coor) { 83 return xy2tile(lon2x(coor.lon()), lat2y(coor.lat())); 86 84 } 87 static public int index(int level, long quad)88 {85 86 public static int index(int level, long quad) { 89 87 long mask = 0x00000003; 90 88 int total_shift = TILES_PER_LEVEL_SHIFT*(NR_LEVELS-level-1); 91 89 return (int)(mask & (quad >> total_shift)); 92 90 } 93 static public int index(LatLon coor, int level) { 94 // The nodes that don't return coordinates will all get 95 // stuck in a single tile. Hopefully there are not too 96 // many of them 91 92 /** 93 * Returns quad tiling index for given coordinates and level. 94 * 95 * @param coor coordinates 96 * @param level level 97 * 98 * @return quad tiling index for given coordinates and level. 99 * @since 2263 100 */ 101 public static int index(LatLon coor, int level) { 102 // The nodes that don't return coordinates will all get stuck in a single tile. 103 // Hopefully there are not too many of them 97 104 if (coor == null) 98 105 return 0; 99 106 100 long x = lon2x(coor.lon()); 101 long y = lat2y(coor.lat()); 107 return index(coor.lat(), coor.lon(), level); 108 } 109 110 /** 111 * Returns quad tiling index for given coordinates and level. 112 * 113 * @param lat latitude 114 * @param lon longitude 115 * @param level level 116 * 117 * @return quad tiling index for given coordinates and level. 118 * @since 6171 119 */ 120 public static int index(final double lat, final double lon, final int level) { 121 long x = lon2x(lon); 122 long y = lat2y(lat); 102 123 int shift = NR_LEVELS-level-1; 103 124 return (int)((x >> shift & 1) * 2 + (y >> shift & 1));
Note:
See TracChangeset
for help on using the changeset viewer.