Am 14.09.12 16:22, schrieb Stefan Mettenbrink:
Hat jemand eine Routine, die Maidenhead-Koordinaten in Längen- und
Breitengrade umrechnet?
Auf die Schnelle habe ich bei Google nichts gefunden.

Basierend auf dem Artikel und dem entsprechenden Perl-Code:
http://en.wikipedia.org/wiki/Maidenhead_Locator_System

-------------------------------

Function LocatorToLatLong(locator as String) As String()
  dim grid() as String
  dim formatter as String
  dim lon, lat as Double

  grid = locator.Uppercase.Split("")

  lon = ((grid(0).Asc - Asc("A")) * 20) - 180
  lat = ((grid(1).Asc - Asc("A")) * 10) - 90
  lon = lon + ((grid(2).Asc - Asc("0")) * 2)
  lat = lat + ((grid(3).Asc - Asc("0")) * 1)

  if grid.Ubound >= 5 then
    'have subsquares
    lon = lon + ((grid(4).Asc) - Asc("A")) * (5/60)
    lat = lat + ((grid(5).Asc) - Asc("A")) * (2.5/60)
    'move to center of subsquare
    lon = lon + (2.5/60)
    lat = lat + (1.25/60)
    'not too precise
    formatter = "%.5f"
  else
    'move to center of square
    lon = lon + 1
    lat = lat + 0.5
    'even less precise
    formatter = "%.1f"
  end if

  'Latitude: + = North, - = South
  'Longitude: + = East, - = West

  return Array(Sprintf(formatter, lat), Sprintf(formatter, lon))

End Function

-------------------------------

Die sprintf() Funktion erhält man über das "StringUtils Module" von "Joe's REALbasic Page":

http://www.strout.net/info/coding/rb/intro.html
http://www.strout.net/files/rb/stringutils.zip

(man benötigt lediglich die sprintf() und die repeat() Funktion daraus)

Aufruf testen mit:
-------------------------------

dim geo() as String
geo = LocatorToLatLong("BL11BH16")
MsgBox  "Longitude: " + geo(0) + EndOfLine + "Latitude: " + geo(1)
'Ausgabe:
'Longitude: 21,31250
'Latitude : -157,87500

-------------------------------

Bei Longitude sind negative Werte "South", bei Latitude sind negative Werte "West". Zum Abgleich der Funktionalität kannst du folgenden Online-Converter nutzen:

http://www.amsat.org/cgi-bin/gridconv


--
Michael Kagerbauer
http://rbcoder.de

Antwort per Email an