07-09-2010 05:01 PM
We have implemented GPS in our BlackBerry(BB) application to get the current location coordinates that we are using to get information like - location name, location zip code, etc.
To develop this, we followed the document provided by BlackBerry official website which is available right now at this location - http://docs.blackberry.com/en/developers/deliverab
_857606_11.jsp
It works fine when the device is in an area from where it can search satellites easily (say, outside a building and in an open space) but the problem starts when we use this inside a building and in this case, it is not able to fix the GPS and due to which we don't get location coordinates.
I have checked all the BlackBerry forums for this problem but I couldn't get any solution.
I have also increased the horizontal and vertical accuracy level to 2000 meters and with different Criteria for different modes other than a "null" Criteria but then also it didn't work.
Please check the different Criteria for different modes which I have
tested:
// CELLSITE
Criteria myCriteria = new Criteria();
myCriteria.setPreferredPowerConsumption(Criteria.P
myCriteria.setHorizontalAccuracy(Criteria.NO_REQUI
myCriteria.setVerticalAccuracy(Criteria.NO_REQUIRE
myCriteria.setCostAllowed(true);
// ASSIST
Criteria myCriteria = new Criteria();
myCriteria.setPreferredPowerConsumption(Criteria.P
myCriteria.setHorizontalAccuracy(500);
myCriteria.setVerticalAccuracy(500);
myCriteria.setCostAllowed(true);
// AUTONOMOUS
Criteria myCriteria = new Criteria();
myCriteria.setPreferredPowerConsumption(Criteria.P
myCriteria.setHorizontalAccuracy(2000);
myCriteria.setVerticalAccuracy(2000);
myCriteria.setCostAllowed(false);
//any of the available location providers will be returned if myCriteria is null
Criteria myCriteria = null;
My question is, how is GoogleMaps application able to find the locations by using GPS inside a building? Is there any way in which we can also get the location coordinates by using GPS when we're inside a building?
07-09-2010 05:48 PM
Google doesn't just use GPS. Google also have GPS located all the cell towers and so can map from these to your approximate location. So if you are on wireless, Google will have a good chance of figuring out approximately where you are.
GPS on the other hand, has no chance.
There are Threads on this forum that talk about how one might use Google or another provider to find this out for yourself based on your current tower. Have a search around.
07-09-2010 10:56 PM
njnjnj,
I've been suffering from the same problem the past week and I've finally reached a solution. I use google's geolocation web service to retrieve location using cell ids. Its not very accurate but workable.
The webservice (http://www.google.com/loc/json) uses HTTP POST and takes a JSON string with the parameters required to triangulate the phone. To construct the JSON string you'll need the j2me version of the JSON library for java.
The following code constructs the json string that is required by the webservice (jsonString is of type JSONObject)
jsonString.put("version", "1.1.0");
jsonString.put("host", "maps.google.com");
int x = RadioInfo.getMCC(RadioInfo.getCurrentNetworkIndex( ));
jsonString.put("home_mobile_country_code", Integer.parseInt(Integer.toHexString(x)));
jsonString.put("home_mobile_network_code", RadioInfo.getMNC(RadioInfo.getCurrentNetworkIndex( )));
int radio = RadioInfo.getNetworkType();
jsonString.put("radio_type","gsm");
jsonString.put("carrier", RadioInfo.getCurrentNetworkName());
jsonString.put("request_address", true);
jsonString.put("address_language", "en_GB");
CellTower cellInfo = new CellTower(Integer.toHexString(x), GPRSInfo.getCellInfo().getLAC(), GPRSInfo.getCellInfo().getRSSI(), GPRSInfo.getCellInfo().getCellId(), 0,RadioInfo.getMNC(RadioInfo.getCurrentNetworkInde x()));
Hashtable map = new Hashtable();
map.put("mobile_country_code",new Integer(Integer.parseInt(cellInfo.mobileCountryCod e)));
map.put("location_area_code", new Integer(cellInfo.locationAreaCode));
map.put("signal_strength", new Integer(cellInfo.signalStrength));
map.put("cell_id", new Integer(cellInfo.cellID));
map.put("age", new Integer(0));
map.put("mobile_network_code",new Integer(cellInfo.mobileNetworkCode));
JSONArray array = new JSONArray();
array.put(0,map);
jsonString.put("cell_towers",array)
CellTower is an inner class with the following structure
private class CellTower{
public String mobileCountryCode;
public int locationAreaCode;
public int signalStrength;
public int cellID;
public int age;
public int mobileNetworkCode;
private CellTower(String mcc, int lac, int ss, int ci, int a, int mnc){
mobileCountryCode = mcc;
locationAreaCode = lac;
signalStrength = ss;
cellID = ci;
age = a;
mobileNetworkCode = mnc;
}
}
Once you construct the JSON string above you just POST it to the webservice.
To retrieve longitude and latitude from the response string simply parse it into a JSONObject using the following code:
try{
JSONObject ob = new JSONObject(response);
JSONObject ob2 = (JSONObject) ob.get("location");
Double longitude = (Double)ob2.get("longitude");
Double latitude = (Double)ob2.get("latitude");
application.geoLocatorFinished(longitude.doubleVal ue(),latitude.doubleValue());
}catch(JSONException exp){
application.log("JSON String error "+response);
}
The application.geoLocatorFinished() method is what I used as a callback method to my controller object to proceed with processing the longitude and latitude.
Well hope this helps you!
If you need anything else please let me know!
Good luck!
Nawara
07-10-2010 11:07 AM
hi nawara,
Can u post a link for the specification of this Google Maps API?
thanks.
07-10-2010 11:12 AM
07-11-2010 09:06 AM
hey,
which JSON library you are usaing?
thanks.
07-11-2010 09:52 AM
Hi
I'm using the json library available for j2me. It took me a while to find it and finally came across the source code.. I've uploaded a rar file containing the source code files to this link for you to download
You can either include these source files in your project or create another project that has them and compile it as a Library. Let me know if you need any help using it
07-11-2010 10:04 AM
hey thanks.
was looking for the same but couldn't find it.
07-11-2010 10:07 AM
Anytime man..
Let me know how things go and if you need anymore help please tell me
Good luck
07-26-2010 10:56 AM
works!
Thanks alot for this thread