0

I now have coordinates for some positions as latitude and longitude like this

Lat = 16.0490143029144 Lng = 108.197069205344

I want convert it to degree like this

enter image description here

I don't know how to do it, need your help.

Thank in advance.

Võ Quang Hòa
  • 2,688
  • 3
  • 27
  • 31
  • I think they have a bit difference. Thanks – Võ Quang Hòa Jan 17 '15 at 07:17
  • 1
    Indeed, they are not identical. Since you provided no evidence of attempting to solve your _dictionary_ problem, it seemed like that might at least help you make progress to the point that you could post a _specific_ question about a problem in your code. What you posted here is just a request for a Free Coding Service. – HABO Jan 17 '15 at 14:08

1 Answers1

2
            double lat = -86.0490143029144;
            double lon = -45.197069205344;

            string latDir = (lat >= 0 ? "N" : "S");
            lat = Math.Abs(lat);
            double latMinPart = ((lat - Math.Truncate(lat) / 1) * 60);
            double latSecPart = ((latMinPart - Math.Truncate(latMinPart) / 1) * 60);

            string lonDir = (lon >= 0 ? "E" : "W");
            lon = Math.Abs(lon);
            double lonMinPart = ((lon - Math.Truncate(lon) / 1 ) * 60);
            double lonSecPart = ((lonMinPart - Math.Truncate(lonMinPart) / 1) * 60);

            Console.WriteLine(
                Math.Truncate(lat) + " " + Math.Truncate(latMinPart) + " " + Math.Truncate(latSecPart) + " " + latDir             
                );

            Console.WriteLine(
                Math.Truncate(lon) + " " + Math.Truncate(lonMinPart) + " " + Math.Truncate(lonSecPart) + " " + lonDir
                );

Add checks for nulls, zeros and data out of range.