Domanda

I have lat/long coordinates for a list of ports. The coordinates are in a 2856N 05211E format (totally made those numbers up, btw). I'm trying to figure out how I can convert them to the degree format the Google Earth pluginuses in order to plot them on a map. Is there a parameter in the API that I could use to convert this? Any ideas would be appreciated.

È stato utile?

Soluzione

I'm assuming you can parse the values yourself. If not, then provide the language you wish to use.

The conversion is simple, Degrees/Min/Sec(DMS) to Decimal Degrees is

result = D + M/60 + S/3600;

If S or W,

result *= -1;

As always, do your own error checking.

-90 <= lat <= 90

-180 <= lon <= 180

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top