Qibla指南针不正确或不准确

时间:2013-05-17 06:01:37

标签: android

首先到达当前位置的北面, 然后计算轴承,

这是代码:

  @Override
        public void onSensorChanged(SensorEvent event) {
float azimuth = (int)event.values[0];
            azimuth =  azimuth * 180 / (float) Math.PI;
GeomagneticField geoField = new GeomagneticField(Double.valueOf(
                    location.getLatitude()).floatValue(), Double.valueOf(
                    location.getLongitude()).floatValue(), Double.valueOf(
                    location.getAltitude()).floatValue(),
                    System.currentTimeMillis());

            azimuth += geoField.getDeclination(); // converts magnetic north
                                                    // into true north
            float bearing = location.bearingTo(MeccaLocation); // (it's already
                                                                // in degrees)

float Meccadirection = (float) (azimuth - bearing);
} 

但结果方向不准确。

0 个答案:

没有答案