BendEg
BendEg

Reputation: 21128

Convert integer latitude and longitude to decimal (using for google maps api)

Currently I'm trying to convert integer latitude and longitude to decimal (degrees). The specification from where I get the data says:

| Latitude | Position latitude | Integer, number of 1/10th of a second |

| Longitude | Position longitude | Integer, number of 1/10th of a second |

Here is a sample number:

What I need, is something in this format:

How can I convert those formats?

I've seen a few implementations in c#, but nothing that was really usable for me, or I don't get how this might work. What I've tried:

Converting GPS coordinates (latitude and longitude) to decimal and Converting latitude and longitude to decimal values

Thanks a lot

Upvotes: 0

Views: 3265

Answers (1)

SteveTheGrk
SteveTheGrk

Reputation: 352

Here is an example for the conversions between formats.

    private void ConvertSampleFunction()
    {
        //let N 40264600 be a GPS coordinate. Then
        //Format in degrees minutes seconds: 40° 26′ 46″ N 
        double Degs=40.0;
        double Mins=26.0;
        double Secs=46.00;
        //Then in degrees - decimal minutes Format will be
        double Ddegs=Degs;
        double Dmins=Mins;
        double Dsecs=Secs/60.0;
        //This will give Ddegs and Dmins.Dsecs e.g. 40 degrees and 26.767'
        //and In Decimal format DDD.DDD... it will be
        double DecDegs=Degs+Mins/60.0+Secs/3600.0;
        //which will give the value 40.446..
    }

Hope these help.

Upvotes: 1

Related Questions