| 1 |
|
|---|
| 2 |
void doGoogleTest() { |
|---|
| 3 |
|
|---|
| 4 |
println(); |
|---|
| 5 |
println("google test"); |
|---|
| 6 |
println(); |
|---|
| 7 |
|
|---|
| 8 |
AbstractMapProvider p = new GoogleRoadProvider(); |
|---|
| 9 |
String[] urls = p.getTileUrls(new Coordinate(25322, 10507, 16)); |
|---|
| 10 |
println(urls); |
|---|
| 11 |
println( urls[0].startsWith("http://mt") && urls[0].endsWith("&x=10507&y=25322&zoom=1") ); //('....google.com/mt?n=404&v=...',) |
|---|
| 12 |
|
|---|
| 13 |
urls = p.getTileUrls(new Coordinate(25333, 10482, 16)); |
|---|
| 14 |
println( urls[0].startsWith("http://mt") && urls[0].endsWith("&x=10482&y=25333&zoom=1") ); //('....google.com/mt?n=404&v=...',) |
|---|
| 15 |
|
|---|
| 16 |
p = new GoogleAerialProvider(); |
|---|
| 17 |
urls = p.getTileUrls(new Coordinate(25322, 10507, 16)); |
|---|
| 18 |
println( urls[0].startsWith("http://kh") && urls[0].endsWith("&t=tqtsqrqtrtttqsqsr") ); //google.com/kh?n=404&v= |
|---|
| 19 |
|
|---|
| 20 |
urls = p.getTileUrls(new Coordinate(25333, 10482, 16)); |
|---|
| 21 |
println( urls[0].startsWith("http://kh") && urls[0].endsWith("&t=tqtsqrqtqssssqtrt") ); //google.com/kh?n=404&v= |
|---|
| 22 |
|
|---|
| 23 |
p = new GoogleHybridProvider(); |
|---|
| 24 |
urls = p.getTileUrls(new Coordinate(25322, 10507, 16)); |
|---|
| 25 |
println(urls); |
|---|
| 26 |
println( urls[0].startsWith("http://kh") && urls[0].endsWith("&t=tqtsqrqtrtttqsqsr") ); //google.com/kh?n=404&v= |
|---|
| 27 |
println( urls[1].startsWith("http://mt") && urls[1].endsWith("&x=10507&y=25322&zoom=1") ); //google.com/mt?n=404&v= |
|---|
| 28 |
|
|---|
| 29 |
urls = p.getTileUrls(new Coordinate(25333, 10482, 16)); |
|---|
| 30 |
println(urls); |
|---|
| 31 |
println( urls[0].startsWith("http://kh") && urls[0].endsWith("&t=tqtsqrqtqssssqtrt") ); //google.com/kh?n=404&v= |
|---|
| 32 |
println( urls[1].startsWith("http://mt") && urls[1].endsWith("&x=10482&y=25333&zoom=1") ); //google.com/mt?n=404&v= |
|---|
| 33 |
} |
|---|
| 34 |
|
|---|
| 35 |
abstract class GoogleProvider extends AbstractMapProvider{ |
|---|
| 36 |
|
|---|
| 37 |
String ROAD_VERSION = "w2.69"; |
|---|
| 38 |
String AERIAL_VERSION = "25"; |
|---|
| 39 |
String HYBRID_VERSION = "w2t.69"; |
|---|
| 40 |
String TERRAIN_VERSION = "w2p.64"; |
|---|
| 41 |
|
|---|
| 42 |
GoogleProvider() { |
|---|
| 43 |
super( new MercatorProjection(26, new Transformation(1.068070779e7, 0, 3.355443185e7, 0, -1.068070890e7, 3.355443057e7) ) ); |
|---|
| 44 |
} |
|---|
| 45 |
|
|---|
| 46 |
abstract String getZoomString(Coordinate coordinate); |
|---|
| 47 |
|
|---|
| 48 |
int tileWidth() { |
|---|
| 49 |
return 256; |
|---|
| 50 |
} |
|---|
| 51 |
|
|---|
| 52 |
int tileHeight() { |
|---|
| 53 |
return 256; |
|---|
| 54 |
} |
|---|
| 55 |
|
|---|
| 56 |
} |
|---|
| 57 |
|
|---|
| 58 |
class GoogleRoadProvider extends GoogleProvider { |
|---|
| 59 |
String[] getTileUrls(Coordinate coordinate) { |
|---|
| 60 |
String url = "http://mt" + (int)random(0, 4) + ".google.com/mt?n=404&v=" + ROAD_VERSION + "&" + getZoomString(sourceCoordinate(coordinate)); |
|---|
| 61 |
return new String[] { |
|---|
| 62 |
url }; |
|---|
| 63 |
} |
|---|
| 64 |
String getZoomString(Coordinate coordinate) { |
|---|
| 65 |
Coordinate coord = toGoogleRoad(coordinate.container()); |
|---|
| 66 |
return "x=" + (int)coord.column + "&y=" + (int)coord.row + "&zoom=" + (int)coord.zoom; |
|---|
| 67 |
} |
|---|
| 68 |
} |
|---|
| 69 |
|
|---|
| 70 |
class GoogleAerialProvider extends GoogleProvider { |
|---|
| 71 |
String[] getTileUrls(Coordinate coordinate) { |
|---|
| 72 |
String url = "http://kh" + (int)random(0, 4) + ".google.com/kh?n=404&v=" + AERIAL_VERSION + "&t=" + getZoomString(sourceCoordinate(coordinate)); |
|---|
| 73 |
return new String[] { |
|---|
| 74 |
url }; |
|---|
| 75 |
} |
|---|
| 76 |
String getZoomString(Coordinate coordinate) { |
|---|
| 77 |
return toGoogleAerial(coordinate.container()); |
|---|
| 78 |
} |
|---|
| 79 |
} |
|---|
| 80 |
|
|---|
| 81 |
class GoogleHybridProvider extends GoogleProvider { |
|---|
| 82 |
String[] getTileUrls(Coordinate coordinate) { |
|---|
| 83 |
String under = new GoogleAerialProvider().getTileUrls(coordinate)[0]; |
|---|
| 84 |
String over = "http://mt" + (int)random(0, 4) + ".google.com/mt?n=404&v=" + HYBRID_VERSION + "&" + getZoomString(sourceCoordinate(coordinate)); |
|---|
| 85 |
return new String[] { |
|---|
| 86 |
under, over }; |
|---|
| 87 |
} |
|---|
| 88 |
String getZoomString(Coordinate coordinate) { |
|---|
| 89 |
Coordinate coord = toGoogleRoad(coordinate.container()); |
|---|
| 90 |
return "x=" + (int)coord.column + "&y=" + (int)coord.row + "&zoom=" + (int)coord.zoom; |
|---|
| 91 |
} |
|---|
| 92 |
} |
|---|
| 93 |
|
|---|
| 94 |
class GoogleTerrainProvider extends GoogleRoadProvider { |
|---|
| 95 |
String[] getTileUrls(Coordinate coordinate) { |
|---|
| 96 |
String url = "http://mt" + (int)random(0, 4) + ".google.com/mt?n=404&v=" + TERRAIN_VERSION + "&" + getZoomString(sourceCoordinate(coordinate)); |
|---|
| 97 |
return new String[] { |
|---|
| 98 |
url }; |
|---|
| 99 |
} |
|---|
| 100 |
} |
|---|