本文介绍了bearingTo(Location dest)究竟计算什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
bearingTo(Location dest)
的准确计算内容是什么?谁能解释一下吗?
What does bearingTo(Location dest)
exactly calculate? Can anyone please explain this??
谢谢.
protected void onCreate(Bundle savedInstanceState) {
DestinationLoc.setLatitude(39.543394);
DestinationLoc.setLongitude(-119.816010);
LocationManager lm =(LocationManager)getSystemService(LOCATION_SERVICE);
String provider = lm.getBestProvider(new Criteria(), true);
loc=lm.getLastKnownLocation(provider)
}
public void onSensorChanged(SensorEvent event) {
// TODO Auto-generated method stub
Startloc.setLatitude(loc.getLatitude());
Startloc.setLongitude(loc.getLongitude());
if ( Startloc == null ) return;
float azimuth = event.values[0];
float baseAzimuth = azimuth;
mInitialPosition.setText("Initial LatLong: " + Startloc.getLatitude() + " " + Startloc.getLongitude());
GeomagneticField geoField = new GeomagneticField( Double
.valueOf( Startloc.getLatitude() ).floatValue(), Double
.valueOf( Startloc.getLongitude() ).floatValue(),
Double.valueOf( Startloc.getAltitude() ).floatValue(),
System.currentTimeMillis() );
azimuth += geoField.getDeclination(); // converts magnetic north into true north
//Correct the azimuth
azimuth = azimuth % 360;
//This is where we choose to point it
float direction = azimuth + Startloc.bearingTo( DestinationLoc );
float direction2 = Startloc.bearingTo(DestinationLoc);
}
direction2
值显示为负.
推荐答案
阅读文档.它准确地描述了该方法返回的结果.
Read the documentation please. It describes exactly that that method returns.
参数
目的地目的地位置
返回
以度为单位的初始方位
这篇关于bearingTo(Location dest)究竟计算什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!