谷歌IO 2013应用价值之谜 [英] Google IO 2013 App Mystery Values
问题描述
我想使用的<一个href=\"https://$c$c.google.com/p/iosched/source/browse/android/src/main/java/com/google/android/apps/iosched/ui/SVGTileProvider.java#61\"相对=nofollow> SVGTileProvider
是在的谷歌IO 2013应用。我无法弄清楚到底如何在谷歌地图中的位置的图像,但。我已经收窄到类的这个部分。这些都不是经/纬度坐标,但不知何故,他们必须从纬度/经度坐标的到来。有谁知道这些是什么,或他们来自哪里?
mBaseMatrix.setPolyToPoly(
新的浮动[] {
0,0,
limits.width(),0,
limits.width(),limits.height()
},0,
新的浮动[] {
40.95635986328125f,98.94217824936158f,
40.95730018615723f,98.94123077396628f,
40.95791244506836f,98.94186019897214f
},0,3);
更新
第一组神秘的数字大致翻译纬度/经度37.783887,-122.405107。
更新2
这些方法帮助我转换纬度为y值,反之亦然。我怎么能X和经度做到这一点?
公共静态双y2lat(双AY){
返回Math.toDegrees(2 * Math.atan(Math.exp(Math.toRadians(AY))) - Math.PI / 2);
}
公共静态双lat2y(双阿拉特){
返回Math.toDegrees(将Math.log(Math.tan(Math.PI / 4 + Math.toRadians(ALAT)/ 2)));
}
原来,这些都是世界坐标。
下面是一些Java code,从经纬度转换/长x / y的。
公共静态浮动lat2y(双阿拉特){
回报(浮)(((1 - 将Math.log(Math.tan(阿拉特* Math.PI / 180)+ 1 / Math.cos(阿拉特* Math.PI / 180))/ Math.PI)/ 2 *数学.pow(2,0))* 256);
}
公共静态浮动lon2x(双LON){
回报(浮)((LON + 180°F)/ 360F * 256f);
}
I'm trying to make use of the SVGTileProvider
that is found in the Google IO 2013 app. I can't figure out exactly how to position an image on the Google Map though. I've narrowed it down to this section of the class. These aren't lat/long coordinates however somehow they must be coming from lat/long coordinates. Does anyone know what these are or where they come from?
mBaseMatrix.setPolyToPoly(
new float[]{
0, 0,
limits.width(), 0,
limits.width(), limits.height()
}, 0,
new float[]{
40.95635986328125f, 98.94217824936158f,
40.95730018615723f, 98.94123077396628f,
40.95791244506836f, 98.94186019897214f
}, 0, 3);
Update
The first set of mystery numbers roughly translates to lat/long 37.783887,-122.405107.
Update 2
These methods help me convert latitude to a y value and vice versa. How can I do this for X and Longitude?
public static double y2lat(double aY) {
return Math.toDegrees(2 * Math.atan(Math.exp(Math.toRadians(aY))) - Math.PI / 2);
}
public static double lat2y(double aLat) {
return Math.toDegrees(Math.log(Math.tan(Math.PI / 4 + Math.toRadians(aLat) / 2)));
}
Turns out these are World Coordinates.
Here is some java code to translate from lat/long to x/y.
public static float lat2y(double aLat) {
return (float) (((1 - Math.log(Math.tan(aLat * Math.PI / 180) + 1 / Math.cos(aLat * Math.PI / 180)) / Math.PI) / 2 * Math.pow(2, 0)) * 256);
}
public static float lon2x(double lon) {
return (float) ((lon + 180f) / 360f * 256f);
}
这篇关于谷歌IO 2013应用价值之谜的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!