1. ## Long Lat Problems

Hey Guys I'm Trying to develop An Application to Retrieve Long and Lat From a Blue-tooth GPS. Its Pulling Coordinates But in a strange Format

Latitude = 5216.1327
Longitude = 00941.9632

However when I Try to display these cords On a Static Google Map I'm Out by about 30 - 40 km.

The Code I am using for Reference I found Here.
http://wiki.forum.nokia.com/index.ph..._Bluetooth_GPS

Has any one else had this Problem and have you resolved it. Or Even a Pointer in the Right Direction

Regards Kevin

2. ## Re: Long Lat Problems

Originally Posted by kev_Makaveli
Latitude = 5216.1327
Longitude = 00941.9632
At first glance, this looks like decimal minutes, which would break the JSR179 spec but for which there are good reasons. i.e.

5216.1327 = 86.935545N
941.9632 = 15.699386666666666666666666666667E

Still very far North, somewhere north of Svalbard even. Can you post the code that does this? What device are you using?

- Mike
NAVTEQ Network for Developers
The community for developing innovative location-based applications
http://NN4D.com

3. ## Re: Long Lat Problems

I'm Coding for an E-65.

The Code I Used Originally For Blue tooth GPS Is Here

http://wiki.forum.nokia.com/index.ph..._Bluetooth_GPS

Ive Made some Progress in converting it. I Wrote a Java Class That Converts It To The Proper format And Gives Me an accurate Reading.

The only problem now is that when i try to use that class to display the newly formated info i get an Exception.

Here Is the Code For The Java Class For Converting

Code:
```package Project;

/**
*
* @author Kevin
*/
public class Convert
{
String Longtitude;
String Latitude;

public Convert (String longtitude,String latitude)
{
this.Latitude = latitude;
this.Longtitude = longtitude;

}
public String ConvertLat()
{

double dLat = Double.parseDouble(Latitude);
int pt = Double.toString(dLat).toString().indexOf(".");
double degreesLat = Double.parseDouble(Double.toString(dLat).toString().substring(0, pt-2));
double minutesLat = Double.parseDouble(Double.toString(dLat).toString().substring(pt-2));
double DecDegsLat =  degreesLat + (minutesLat / 60.0);
Latitude = Double.toString(DecDegsLat);

return Latitude;
}

public String ConvertLong()
{

double dLon = Double.parseDouble(Longtitude);
int pt = Double.toString(dLat).toString().indexOf(".");
double degreesLat = Double.parseDouble(Double.toString(dLat).toString().substring(0, pt-2));
double minutesLat = Double.parseDouble(Double.toString(dLat).toString().substring(pt-2));
double DecDegsLat =  degreesLat + (minutesLat / 60.0);
Longtitude= Double.toString(DecDegsLat);

return Longtitude;
}

}

And When I Try To call this New Class in the Midlet I Get The Exception

Heres How I'm Calling It In The Midlet Screen```

4. ## Re: Long Lat Problems

Here is what you are receiving from the device:

Code:
`5216.1327`
Why are you doing the following?

Code:
`5216 + "." + (0.1327/60)`
This value is completely meaningless. There is no such thing as 5216 degrees.

You simply need to return

Code:
`5216.1327/60`
- Mike
NAVTEQ Network for Developers
The community for developing innovative location-based applications
http://NN4D.com

5. ## Re: Long Lat Problems

It Returns Correct cords Mike. The cords u calculate Place Me Miles away from My Location.

Here Is a Sample Of My code Mike. with a Value Hard coded.

Code:
```package javaapplication12;

import javax.swing.JOptionPane;

/**
*
* @author Kevin
*/
public class Test
{
public static void main(String[] args) {

double dLat = 5216.1312;
int pt = Double.toString(dLat).toString().indexOf(".");
double degreesLat = Double.parseDouble(Double.toString(dLat).toString().substring(0, pt-2));
double minutesLat = Double.parseDouble(Double.toString(dLat).toString().substring(pt-2));
double DecDegsLat =  degreesLat + (minutesLat / 60.0);
double test =  DecDegsLat;
JOptionPane.showMessageDialog(null, test);

}

}```
Run it as standard and u will See it gives a valid Location and you Might understand More what I'm trying to do.

Regards Kevin

6. ## Re: Long Lat Problems

OK, let's break it up:

Code:
```double dLat = 5216.1312;
int pt = Double.toString(dLat).toString().indexOf(".");```
Double.toString(dLat) returns "5216.1312"

"5216.1312".toString() returns "5216.1312"

"5216.1312".indexOf(".") returns 4

Code:
`double degreesLat = Double.parseDouble(Double.toString(dLat).toString().substring(0, pt-2));`
Double.toString(dLat) returns "5216.1312"

"5216.1312".toString() returns "5216.1312"

"5216.1312".substring(0,pt-2) returns "52"

(what happens when pt <= 2?)

Double.parseDouble("52") returns 52.0

Code:
`double minutesLat = Double.parseDouble(Double.toString(dLat).toString().substring(pt-2));`
Double.toString(dLat) returns "5216.1312"

"5216.1312".toString() returns "5216.1312"

"5216.1312".substring(pt-2) returns "16.1312"

(what happens when pt<=2?)

Double.parseDouble("16.1312") returns 16.1312

Code:
`double DecDegsLat =  degreesLat + (minutesLat / 60.0);`
minutesLat / 60.0 returns 0.26885333333333333333333333333333

DecDegsLat = 52.26885333333333333333333333333333

As far as I can see, this number is completely meaningless, it just happens, purely by accident, to be somewhere close to where you want it to be.

You could just as easily divide by 100 and get 52.161312, which is also close to the value you want to see.

So the question really is, what does your device documentation say it actually returns?

- Mike
NAVTEQ Network for Developers
The community for developing innovative location-based applications
http://NN4D.com

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•