Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
451 views
in Technique[技术] by (71.8m points)

geolocation - Cell triangulation on BlackBerry

Any ideas about how to do cell triangulation for Blackberry and J2ME phones? I know how to get the cell id but I couldn't do triangulation.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If you can do an HTTP Post to an arbitray website, you can use Google's geolocation api.

Simply POST data in the following JSON format to https://www.google.com/loc/json.

See the above link on how to add more information to your json from wifi etc. to greatly increase the accuracy of the result. And pay special attention to the mobile country code, getting it is 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
    }
  ]
}

This will return you Google's estimate of the latitude/longitude on your location, along with accuracy and optionally a geocoded address. You can test it quickly e.g. with the Chrome extension called REST Console.

However, it seems that the Blackberry API only provides info on the currently connected cell, not other visible but unregistered cells. In this situation cannot do triangulation, as you (unsuprisingly) need three points to triangulate! However, a less accurate radial estimate of location is still possible.

You can still use the Google API for this, by providing only one tower, or you can use the Ericsson API if you choose. You might want to test with both and compare the accuracy. The Ericcson API is a similar JSON api to Google's, but only expects a single cell as input. A tutorial is available, but it boils down to a JSON request like this:

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();
} 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...