为什么getBaseStationLatitude()不断返回Integer.MAX_VALUE(未知)? [英] Why getBaseStationLatitude() keeps returning the Integer.MAX_VALUE (unknown)?

查看:229
本文介绍了为什么getBaseStationLatitude()不断返回Integer.MAX_VALUE(未知)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

课程项目&论文工作-尝试从CDMA Cell中提取信息,特别是通过使用getBaseStationLatitude()& getBaseStationLongitude().返回的值是MAX_VALUE(2147483647)-我没有收到实际的经/纬度. getBaseStationID(),getNetworkID()& getSystemID()返回有效的ID.我已经在2个单独的单元中对此进行了测试,但没有好运.我的代码发布在下面.两者均为ACCESS_FINE_LOCATION& ACCESS_COURSE_LOCATION添加到清单.在Android 2.2.2.Droid上进行的测试

问题-有人遇到过同样的问题吗?我在代码中缺少什么吗?这些值在哪里存储和发布(例如,这些坐标是在基站分配的,并不断发送给移动设备)?

代码:

package xXx.edu.com;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.telephony.cdma.CdmaCellLocation;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class CDMAData extends Activity implements OnClickListener{

    CdmaCellLocation location;
    int cellID, lat, lon, netID, sysID;
    private Context context;
    Button getDataBtn;

   /** Called when the activity is first created. */
   @Override
   public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);

      context = (Context) this;
      setContentView(R.layout.cid);

      setConnections();
   }

   private void setConnections() {

       getDataBtn = (Button) this.findViewById(R.id.getID);
       getDataBtn.setOnClickListener(this);

   }

   public void onClick(View v) {

       TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
       location = (CdmaCellLocation) tm.getCellLocation();
       cellID = location.getBaseStationId();
       lat = location.getBaseStationLatitude();
       lon = location.getBaseStationLongitude();
       netID = location.getNetworkId();
       sysID = location.getSystemId();

       TextView myView1 = (TextView) findViewById(R.id.bsID);
       myView1.setText("" + cellID);

       TextView myView2 = (TextView) findViewById(R.id.bsLat);
       myView2.setText("" + lat);

       TextView myView3 = (TextView) findViewById(R.id.bsLon);
       myView3.setText("" + lon);

       TextView myView4 = (TextView) findViewById(R.id.netID);
       myView4.setText("" + netID);

       TextView myView5 = (TextView) findViewById(R.id.sysID);
       myView5.setText("" + sysID);

   }
}

解决方案

原因如下:

纬度是3GPP2 C.S0005-A v6.0中指定的十进制数. 以0.25秒为单位表示,范围从-1296000到 1296000(包括两个值)(对应于-90到+90的范围 度). Integer.MAX_VALUE被视为无效值.

经度是3GPP2 C.S0005-A v6.0中指定的十进制数.它 以0.25秒为单位表示,范围从-2592000到 2592000(包括两个值)(对应于-180至 +180度). Integer.MAX_VALUE被视为无效值.

说:

Latitude = L(Android cdma API返回的整数)

纬度=((L * 90)/1296000))

现在,您可以轻松地将其转换为分钟和秒的度数: 以下是执行此操作的URL(以下任何链接均应起作用): http://zonalandeducation.com/mmts/trigonometryRealms/degMinSec/degMinSec.htm

http://www.fcc.gov/mb/audio/bickel/DDDMMSS-decimal.html

Class project & thesis work - trying to pull information from CDMA Cell, specifically by using the getBaseStationLatitude() & getBaseStationLongitude(). The value being returned is the MAX_VALUE (2147483647) - I'm not receiving actual lat/longs. getBaseStationID(), getNetworkID() & getSystemID() are returning valid id's. I've tested this in 2 separate cells with no luck. My code is posted below. Both ACCESS_FINE_LOCATION & ACCESS_COURSE_LOCATION are added to manifest. Testing done on Droid, Android 2.2.2.

Questions - Has anyone run into same problems? Am I missing something in the code? Where are these values stored and issued at (e.g. are these coordinates assigned at the base station, and constantly being transmitted to mobile device)?

Code:

package xXx.edu.com;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.telephony.cdma.CdmaCellLocation;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class CDMAData extends Activity implements OnClickListener{

    CdmaCellLocation location;
    int cellID, lat, lon, netID, sysID;
    private Context context;
    Button getDataBtn;

   /** Called when the activity is first created. */
   @Override
   public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);

      context = (Context) this;
      setContentView(R.layout.cid);

      setConnections();
   }

   private void setConnections() {

       getDataBtn = (Button) this.findViewById(R.id.getID);
       getDataBtn.setOnClickListener(this);

   }

   public void onClick(View v) {

       TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
       location = (CdmaCellLocation) tm.getCellLocation();
       cellID = location.getBaseStationId();
       lat = location.getBaseStationLatitude();
       lon = location.getBaseStationLongitude();
       netID = location.getNetworkId();
       sysID = location.getSystemId();

       TextView myView1 = (TextView) findViewById(R.id.bsID);
       myView1.setText("" + cellID);

       TextView myView2 = (TextView) findViewById(R.id.bsLat);
       myView2.setText("" + lat);

       TextView myView3 = (TextView) findViewById(R.id.bsLon);
       myView3.setText("" + lon);

       TextView myView4 = (TextView) findViewById(R.id.netID);
       myView4.setText("" + netID);

       TextView myView5 = (TextView) findViewById(R.id.sysID);
       myView5.setText("" + sysID);

   }
}

解决方案

Here is why:

Latitude is a decimal number as specified in 3GPP2 C.S0005-A v6.0.It is represented in units of 0.25 seconds and ranges from -1296000 to 1296000, both values inclusive (corresponding to a range of -90 to +90 degrees). Integer.MAX_VALUE is considered invalid value.

Longitude is a decimal number as specified in 3GPP2 C.S0005-A v6.0. It is represented in units of 0.25 seconds and ranges from -2592000 to 2592000, both values inclusive (corresponding to a range of -180 to +180 degrees). Integer.MAX_VALUE is considered invalid value.

Say:

Latitude = L (integer as returned by Android cdma API)

Latitude in degree = (( L * 90)/1296000))

Now you can easily convert it to degree min and seconds: Following is the URL to do that(any of the following links should work): http://zonalandeducation.com/mmts/trigonometryRealms/degMinSec/degMinSec.htm

http://www.fcc.gov/mb/audio/bickel/DDDMMSS-decimal.html

这篇关于为什么getBaseStationLatitude()不断返回Integer.MAX_VALUE(未知)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆