你好,游客 登录 注册 搜索
背景:
阅读新闻

Android GSM+CDMA基站定位

[日期:2012-06-15] 来源:Linux社区  作者:geniuseoe [字体:大 中 小]

值得一提的是C网获取基站再定位那偏差不是一般的大,是恨大,将近1千米了,大概是C网基站较少的缘故吧

最后通过经纬度获取地理位置信息,代码如下:

  1. public static  String getAddress(Location itude) throws Exception {  
  2.         String resultString = "";  
  3.    
  4.         /** 这里采用get方法,直接将参数加到URL上 */  
  5.         String urlString = String.format("http://maps.google.cn/maps/geo?key=abcdefg&q=%s,%s", itude.getLatitude(), itude.getLongitude());  
  6.         Log.i("URL", urlString);  
  7.    
  8.         /** 新建HttpClient */  
  9.         HttpClient client = new DefaultHttpClient();  
  10.         /** 采用GET方法 */  
  11.         HttpGet get = new HttpGet(urlString);  
  12.         try {  
  13.             /** 发起GET请求并获得返回数据 */  
  14.             HttpResponse response = client.execute(get);  
  15.             HttpEntity entity = response.getEntity();  
  16.             BufferedReader buffReader = new BufferedReader(new InputStreamReader(entity.getContent()));  
  17.             StringBuffer strBuff = new StringBuffer();  
  18.             String result = null;  
  19.             while ((result = buffReader.readLine()) != null) {  
  20.                 strBuff.append(result);  
  21.             }  
  22.             resultString = strBuff.toString();  
  23.    
  24.             Log.e("resultAdress--->", resultString);  
  25.               
  26.             /** 解析JSON数据,获得物理地址 */  
  27.             if (resultString != null && resultString.length() > 0) {  
  28.                 JSONObject jsonobject = new JSONObject(resultString);  
  29.                 JSONArray jsonArray = new JSONArray(jsonobject.get("Placemark").toString());  
  30.                 resultString = "";  
  31.                 for (int i = 0; i < jsonArray.length(); i++) {  
  32.                     resultString = jsonArray.getJSONObject(i).getString("address");  
  33.                 }  
  34.             }  
  35.         } catch (Exception e) {  
  36.             throw new Exception("获取物理位置出现错误:" + e.getMessage());  
  37.         } finally {  
  38.             get.abort();  
  39.             client = null;  
  40.         }  
  41.    
  42.         return resultString;  
  43.     }  

在获取地理位置的这个location事实上应该传入纠偏后的location,本文暂不做此处理,所以得到的地理信息位置是偶偏差的,大家注意

最后附上截图:

Android GSM+CDMA基站定位

工程下载链接:

免费下载地址在 http://linux.linuxidc.com/

用户名与密码都是www.linuxidc.com

具体下载目录在 /2012年资料/6月/15日/Android GSM+CDMA基站定位/

linux
相关资讯       Android编程开发 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款