2010-05-02 33 views

回答

2

如果您可以对仲裁网站执行HTTP Post,则可以使用Google的geolocation api

只需以下面的JSON格式POST数据到https://www.google.com/loc/json

请参阅上述链接,了解如何从wifi等向json添加更多信息,从而大大提高结果的准确性。并特别注意移动国家代码,得到它是not obvious

{ 
    "version": "1.1.0", 
    "cell_towers": [ 
    { 
     "cell_id": "42", 
     "location_area_code": 415, 
     "mobile_country_code": 310, 
     "mobile_network_code.": 410, 
     "age": 0, 
     "signal_strength": -60, 
     "timing_advance": 5555 
    }, 
    { 
     "cell_id": "88", 
     "location_area_code": 415, 
     "mobile_country_code": 310, 
     "mobile_network_code": 580, 
     "age": 0, 
     "signal_strength": -70, 
     "timing_advance": 7777 
    } 
    ] 
} 

这将返回Google对您所在位置的纬度/经度的估计值,以及准确性和可选的地理编码地址。您可以快速测试使用名为REST控制台的Chrome扩展程序。

但是,似乎Blackberry API只提供有关当前连接的单元的信息,而不是其他可见但未注册的单元。在这种情况下不能进行三角测量,因为你(不自然地)需要三点来进行三角测量!然而,位置的不准确的径向估计仍然是可能的。

您仍然可以通过提供一个塔来使用Google API,或者如果您选择使用Ericsson API。您可能想要同时测试并比较准确性。 Ericcson API与Google相似,但只希望单个单元格作为输入。 A tutorial is available,但它归结为这样的JSON请求:

StringBuffer url = new StringBuffer(); 
url.append("http://cellid.labs.ericsson.net/json/lookup"); 
url.append("?cellid=").append(cell.getCellId()); 
url.append("&mnc=").append(cell.getMnc()); 
url.append("&mcc=").append(cell.getMcc()); 
url.append("&lac=").append(cell.getLac()); 
url.append("&key=").append(API_KEY); 
try { 
    byte[] data = getHttp(url.toString()); 
    if(data!=null) { 
    JSONObject o = new JSONObject(new String(data)); 
    JSONObject pos = o.getJSONObject("position"); 
    this.longitude = pos.getDouble("longitude"); 
    this.latitude = pos.getDouble("latitude"); 
    this.accuracy = pos.getDouble("accuracy"); 
    this.cellName = pos.optString("name"); 
    } 
} catch (IOException e) { 
    e.printStackTrace(); 
} 
+0

嗨!分钟是多少?这个功能的单元数量? – 2010-05-04 05:48:24

+0

只需要一个手机塔。但是,随着更多的蜂窝塔的添加,精确度将会增加。 JSON结果应包含准确性估计。 – fmark 2010-05-04 07:19:41

+0

感谢您的信息,但我不知道如何获得3黑莓手机的数据,我只能得到一个单元格的数据: Integer.toString(GPRSInfo.getCellInfo()。getCellId()); //获取当前的小区ID。 Integer.toString(GPRSInfo.getCellInfo()。getLAC()); //检索位置区域代码。 Integer.toString(GPRSInfo.getCellInfo()。getBSIC()); //基站识别码。 – 2010-05-04 13:44:33