Welcome to MapForums!

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

## Geodesy: MapStuff Release version 0.9

This is a discussion on Geodesy: MapStuff Release version 0.9 within the MP2K Magazine Articles forums, part of the Map Forums category; Windsway Company is releasing some Geodesy oriented software as open souce code. This is not a complete application but rather ...

1. Senior Member Black Belt
Join Date
Jul 2002
Posts
5,137

## Geodesy: MapStuff Release version 0.9

Windsway Company is releasing some Geodesy oriented software as open souce code. This is not a complete application but rather a set of routines that you can use to build your own applications.

2. Senior Member Black Belt
Join Date
Jul 2002
Posts
5,137

## vDirect rounding problems I think.

Great set of routines. VERY usefull, Thanks for posting them.

I have a rounding problem I think.

I have a recorded GPS file. For each waypoint in the file the distance between 2 points could be 0 to 50m depending how fast you are driving as the GPS samples every 2 seconds.

I need a new datafile that calculates lon/lat for every 1m interval.

Using vInverse and vDirect I am able to do this but compairing the sum of the distance to next point for each of my datasets I get conflicting data.

When I calc vDirect passing lat1/lon1, azmuth12, and a distance of 1 I get lat2/lon2 in return.

But when I use vInverse to determine distance between the 2 points I get a distance between .92 - .98 not a distance of 1.

With my 1st dataset the sum of distances is correct so vInvers is working properly.

I think the problem may be with my following routines to converting lat lon formats back and forth.

Any suggestions????? THX

'convert to oGS format

Public Function ConvertNMEA(sNMEA As String) As Double
'input N47.36981 from GPS sentence
'output N47.61635 mappoint format

Dim sTmp As String
Dim dRetVal As Double

sTmp = Left(sNMEA, 1)

sNMEA = Mid(sNMEA, 2)

If Not IsNumeric(sNMEA) Then
Exit Function
End If

dRetVal = Int(sNMEA / 100) + (sNMEA - Int(sNMEA / 100) * 100) / 60

Select Case sTmp
Case "N"
'dRetVal = dRetVal
Case "S"
dRetVal = "-" & dRetVal
Case "E"
'dRetVal = dRetVal
Case "W"
dRetVal = "-" & dRetVal
End Select

ConvertNMEA = dRetVal

End Function

'convert back to NMEA format
'Thanks Evert

Function FormatCoordinate(coordinate, LonOrLat) As String
Dim minus As Boolean, before As Integer, after As Integer
Dim Zeros As Integer, c As String

'this function needs a nddd,mm.mmmm input (integer) WGS 84 coordinate
'and returns a NMEA complaint string

'NMEA requires a special format
'latitude = ddmm.mmmm (d=degrees, m=minutes)
'longitude = dddmm.mmmm (d=degrees, m=minutes)
'note the difference; longitude needs 3 d's
'we need to give north/south and east/west too with cardinals

If LonOrLat <> "lon" And LonOrLat <> "lat" Then
FormatCoordinate = "LonOrLat must be 'lon' or 'lat'"
Exit Function
End If

c = CStr(coordinate)

'negative? remember that!
If Left(c, 1) = "-" Then
minus = True
c = Right(c, Len(c) - 1)
Else
minus = False
End If

'convert degrees.minutes to babylonian (60 degrees based)
c = Babylonian(c)

'country settings: decimal seperator can be "." or ","
c = Replace(c, ",", ".")

If LonOrLat = "lat" Then
Zeros = 4
ElseIf LonOrLat = "lon" Then
Zeros = 5
Else
FormatCoordinate = "error in FormatCoordinate"
Exit Function
End If
Do
before = Len(Left(c, InStr(c, ".") - 1))
If before < Zeros Then c = "0" & c
Loop Until before >= Zeros

Zeros = 4
Do
after = Len(Right(c, Len(c) - InStr(c, ".")))
If after < Zeros Then c = c & "0"
Loop Until after >= Zeros

'if to many digits, then reduce
after = Len(Right(c, Len(c) - InStr(c, ".")))
If after > Zeros Then c = Left(c, Len(c) - (after - Zeros))

If LonOrLat = "lat" Then
If minus = False Then
c = "N" & c
Else
c = "S" & c
End If
ElseIf LonOrLat = "lon" Then
If minus = False Then
c = "E" & c
Else
c = "W" & c
End If
Else
FormatCoordinate = "error in FormatCoordinate"
Exit Function
End If

FormatCoordinate = c
End Function

Function Babylonian(c) As String
Dim minutes As Variant
Dim degrees As Variant
'country settings: decimal seperator can be "." or ","
c = Replace(c, ",", ".")

degrees = Left(c, InStr(c, ".") - 1)
minutes = Right(c, Len(c) - InStr(c, "."))
minutes = minutes / 10 ^ Len(Right(c, Len(c) - InStr(c, ".")))
'convert minutes to babylonian (60 degrees based)
minutes = minutes * 60

If minutes < 10 Then minutes = "0" & minutes

'country settings: decimal seperator can be "." or ","
minutes = Replace(minutes, ",", ".")

If InStr(minutes, ".") = 0 Then
minutes = minutes & ".0"
End If

Babylonian = degrees & minutes
End Function

3. ## Geodesy version 0.93 release

Vic recently (9/7) sent out the latest update.. to get on his mailing list, write him at: vfraenc1@nycap.rr.com?subject=Geodesy

Geodesy version 0.93 release

This is the distribution of the latest version of the Geodesy code
set. It contains version 0.93 of the module Mapstuff.bas and version
0.91 of the class module Geodesy.cls. Also included is the new module
WICUtilities (version 0.90). Unzip the distribution (Geodesy.zip) into
the same folder where the previous version resides. The appropriate files
will be overwritten.

It is strongly suggested that you read the revision notes in the file
Revision093.txt and the general discussion in Geodesy.txt before using
this distribution.

You are receiving this distribution because you received the previous
you do not want further revisions to be sent to you, please send me
an e-mail and ask to be removed from the list. Put the word GEODESY in
the subject line of your request.

I would like to hear from any of you that are using GEODESY code. I want
to know how you are using the code, how I can make the code better and,
most importantly, have you found any bugs. Please thouroughly document
bugs so I can try and reproduce them try to fix them.

4. Senior Member Black Belt
Join Date
Jul 2002
Posts
5,137

## thanks

Thats what I needed.

5. Senior Member Black Belt
Join Date
Jul 2002
Posts
5,137

## correct format

hi, i have one Garmin Emap and returns latitude/longitude in this format

latitude 4138.1904
longitude 00444.6535

well, i put in a form the following code:

Option Explicit

Private Sub Command1_Click()

Dim utm As UTMStruct

utm.Latitude = Val(Text1.Text) (i put 4138.1904)
utm.Longitude = Val(Text2.Text)(i put 00444.6535)
utm.geoid = 22

Call LL2UTM(utm)

Label3.Caption = Label3.Caption & " " & utm.North
Label4.Caption = Label4.Caption & " " & utm.East
Label5.Caption = Label5.Caption & " " & utm.geoid
Label6.Caption = Label6.Caption & " " & utm.ZoneNumber
Label7.Caption = Label7.Caption & " " & utm.ZoneLetter
Label8.Caption = Label8.Caption & " " & utm.CentralLongitude
Label9.Caption = Label9.Caption & " " & utm.GridSF

End Sub

...and returns me negative coordinates and the zonenumber and letter are unsuitables, which is the correct format i`ve to pass to utm.Latitude and utm.longitude? and...geoid= 22 (wgs84) is correct? i'm from spain(30)

Thank you so much

Diego García Álvarez