views:

929

answers:

3

I've installed the Google Maps Java 2 ME app on my Nokia N73 which supports the Location API (JSR 179), but does not have an in-built GPS sensor. The "My Location" features works correctly, and is able to pinpoint my position within the city.

When I tried to access the CellID, LAC and other related data, I got nulls. So how is Maps able to calculate my position? Is it because their app is signed with a certificate? (mine isn't)

+2  A: 

What it does is measure the signal strength of WiFi, 3G and GSM Base Stations/Access Points in the area. Since all WiFi access points have a unique MAC address, and 3G and GSM Base Stations also have unique identifications, it now knows which base stations you are close to and approximately how close to them you are, based on the strength.

There are now a few ways to find the distance. If it knows where the Access Point/Base Station is, then it can triangulate your position, based on the signal strength. For this to work it needs to have access to at least 3 AP/BS. With GSM it can also use the Timer Advance, which is an estimation of how far away you are from the base station, with an accuracy of approximately 1km. With 3G it's even better.

Another approach (used by Google and others) is that all your signal strength data is sent to a server. If you have a GPS then your GPS info is also sent along. The server can then build a map of signal strengths to different AP/BS at different coordinates. Since you don't have a GPS it now compares the signal strengths you have passed along and tries to find the closest match in its database, and then finds the location at that closest point.

Marius
Everything that You are describing can't be done in J2ME, so this should prove my point - the version of Google Maps used is not written in J2ME
JaanusSiim
Is Google Maps for Mobile written in C++, and does C++ on the Symbian OS expose cellid, lac and other info to the application.
Kevin Boyd
+1  A: 

This is easy to do in J2ME using the APIs defined by JSR 179. There's a simple example here: JavaME Location API Example application with Source Code (that page is broken at the time of writing; here's the Google Cache version).

That sample works perfectly on my Nokia E63, which like your N97 N73 doesn't have a GPS but does support cell-based positioning. Here's the core of it:

public void checkLocation() throws Exception
{
    String string;
    Location l;
    LocationProvider lp;
    Coordinates c;

    // Set criteria for selecting a location provider:
    // accurate to 500 meters horizontally
    Criteria cr = new Criteria();
    cr.setHorizontalAccuracy(500);

    // Get an instance of the provider
    lp = LocationProvider.getInstance(cr);

    // Request the location, setting a one-minute timeout
    l = lp.getLocation(60);
    c = l.getQualifiedCoordinates();

    if(c != null ) {
      // Use coordinate information
      double lat = c.getLatitude();
      double lon = c.getLongitude();
      string = "\nLatitude : " + lat + "\nLongitude : " + lon;

    } else {
        string ="Location API failed";
    }
    midlet.displayString(string);
}

@Marius is right about how the technology works, but the JSR 179 APIs hide all that detail from you. @JaanusSiim is wrong that you can't do this from J2ME.

Note that the sample application doesn't require signing to work - the phone will pop up a prompt asking whether to allow the unsigned application to access your location information.

RichieHindle
you quoted "like your N97" however my phone is N73...I have tried the sample program on the N73 but it doesn't work, I deduced that without the cellid and/or lac the phone cant compute the location. I think The way Google does it is that they have a Symbian C++ app which I can see from the GUI, then either Symbian may be able to retrieve the values which Java ME can't or else Google may have signed their app at the operator level and got specific access to these values...
Kevin Boyd
Sorry, I meant N73, which does support JSR 197 - see http://www.forum.nokia.com/devices/N73 As for the sample not working, in my case I've disabled "Bluetooth GPS" and enabled "Network based" in Settings / General / Positioning, and I have an Access Point and a Server (supl.nokia.com) configured under "Positioning server".
RichieHindle
I guess you mean "JSR 179 Location API for J2ME™". If a device Supports location API if might be able to compute your location using a. External gps(via bluetooth) b. Internal gps c. cell id ... now since the N73 doesn't have an internal gps that leaves the other two options. Cell ID is also out if you consider reading this link...http://library.forum.nokia.com/index.jsp?topic=/Java_Developers_Library/GUID-1F6DF24F-40E4-4450-80F6-783C996A25D7.html...
Kevin Boyd
your E63 is a S60 3rd Edition, Feature Pack 1 device while the N73 is a 3rd Edition Initial Release.. but as per that link the cell-id should not even be retrieved on a FP1 device so I wonder how its working on your E63
Kevin Boyd
Cell IDs aren't very relevant as far as I can see. JSR 179 defines an API for retrieving the latitude and longitude of your current location, and that's what that code sample uses. There's more to it than just cell ID - my phone accurately tracks my position to within about 50 yards without a GPS, by using the techniques that @Marius talks about. I don't know whether there are significant differences between S60v3 original and S60v3 FP 1 when it comes to JSR 179, but there are no obvious published differences on Nokia's site. Do you have an equivalent of Tools/Settings/General/Positioning?
RichieHindle
Well I couldn't find the relevant settings on the N73...BTW I also tried my version of the Location api test on my friends E63 but it didn't work there either might be some bug in my code(it wasn't mine any way I had taken it off the net).. will try your version and see it works...
Kevin Boyd
I don't understand what other techniques will the JSR179 use if the cell id information isn't available... any ideas?
Kevin Boyd
If you're trying to read `com.nokia.mid.cellid`, that requires S60 3rd Edition FP 2. But just because the Cell ID isn't directly available to you, that doesn't mean the positioning system can't use it behind the scenes.
RichieHindle
A: 

I have an N73.

I have tried everything - google maps works but none of my code or anyone else's code.

I don't have a Settings / General menu!!!! You have a different N73 to me!

barry
I think you are in the same boat as everyone else and same as me or many other J2ME developers so you should be happy about that... as of for a specific reply refer to my comments to Richie Hindle...
Kevin Boyd
Thanks Kevin - I've have accepted the fact there's no gps without gps :)
barry
Don't give up so early, there is definitely a possibility of GPS without GPS so hang in there.. let me do some tests on the N73 that I have and see what works and what doesn't
Kevin Boyd
found this link which says need S60 3rd ed FP2: http://wiki.forum.nokia.com/index.php/CS000947_-_Getting_Cell_ID_in_Java_ME
barry