Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

GPS Distance Problem

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-19-2008, 02:08 PM
Knows the basics
 
Join Date: Jan 2008
Posts: 78
Default GPS Distance Problem

Hello,

i'd like to check the distance with GPS Modul. I use some functions from GPS4PPC.sbp and modified it. P.E.

Sub Timer1_Tick
stat = GPS1.Status
If Serial1.InBufferCount > 0 Then
Label2.Text = "GPS is connected."
GPS1.GPSStream(Serial1.InputString)
north = GPS1.LatitudeHemisphere
If checkdis < 1 Then
If north = "n" Then
n = true
Else
n = false
End If
n = true
n = true
vlat = GPS1.Latitude
vlot = GPS1.Longitude
End If
checkdis = checkdis +1
If checkdis = 5 Then
distanz
checkdis = 0
End If
counter = 0
Else
counter = counter + 1
If counter >= 5 Then 'After 5 seconds without any data we will try to make a new connection.
counter = 0
Timer1.Enabled = false
Serial1.PortOpen = false
Label2.Text = "No connection."
GPS1.GPSBuffer = ""
If Msgbox("GPS was disconnected." & crlf & "Do you want to reconnect?","",cMsgboxYesNo) = cYes Then
mnuConnect_Click 'Try to reconnect.
End If
End If
End If
End Sub

Sub distanz
If Gps1.SpeedOverGround * umrech >5 Then
n = true
LL() = Converter.UTMToLatLon(6378137,1/298.257223563,33,vlat,n,vlot)
lat1 = LL.Lat
lon1 = LL.Lon

LL() = Converter.UTMToLatLon(6378137,1/298.257223563,33,GPS1.Latitude,n,GPS1.Longitude)
Distance_Course(lat1,lon1,LL.Lat,LL.Lon)

dis() = res()
di = (dis.Distance * 1.852 + da)
dia= Round(di ,2)
label5.Text = dia
da = dia
End If

End Sub

But i get creazy results. If i multiplicate di with 1000 then the distance is around the true distance but only around. What' wrong?

Georg
Reply With Quote
  #2 (permalink)  
Old 04-19-2008, 03:06 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 13,162
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

What is the purpose of this line:
Code:
LL() = Converter.UTMToLatLon(6378137,1/298.257223563,33,GPS1.Latitude,n,GPS1.Longitude)
Reply With Quote
  #3 (permalink)  
Old 04-19-2008, 03:14 PM
Knows the basics
 
Join Date: Jan 2008
Posts: 78
Default

That is the new position after 5 seconds
Reply With Quote
  #4 (permalink)  
Old 04-19-2008, 03:20 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 13,162
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

UTMToLatLon expects UTM coordinates and returns Lat/Lon coordinates.

Course_Distance expects Lat/Lon coordinates so no conversion is required anyway.
Reply With Quote
  #5 (permalink)  
Old 04-23-2008, 09:39 AM
Knows the basics
 
Join Date: Jan 2008
Posts: 78
Default

It does not work to calculate the distanc with Lat/Lon during the drive, to much diverence. I made it on this way and it works fine

Sub distanz
If Gps1.SpeedOverGround * umrech >= 4 Then
sek = sek +1
da =da + (Gps1.SpeedOverGround * umrech/3600)
di = Round(da,2)
If di > 0 Then
label8.Text = Round(da*3600/sek,2) & " Km/h"
End If
label9.Text = di & " Km"
If sek/3600 > 1 Then
h = Round(sek/3600,0)
m = (sek -(h*3600))/60
Else
h = 0
m = Round(sek/60,0)
End If
label14.Text = h & " h " & m & " min"
End If

End Sub

called by Timer

umrech value of miles or Km

perhaps it helps some other one

Georg
Reply With Quote
  #6 (permalink)  
Old 04-23-2008, 10:59 PM
Junior Member
 
Join Date: May 2007
Posts: 35
Default

Hi Georg,
do I really understand you, that you want to measure the distance while moving? I did this using UTM-data. Here http://www.basic4ppc.com/forum/showt...light=distance is the thread to the code sample.

John
Reply With Quote
  #7 (permalink)  
Old 04-25-2008, 05:10 AM
Knows the basics
 
Join Date: Jan 2008
Posts: 78
Default

Hi John,

thank you. That is exactly what i searching for. It works very well. You are right with GPS.SpeedOverGround > 2. But sometimes the Speed on my Devise runs up to 6 and 7 Km/h without moving. Perhaps the problem is, that in germany all the things are more nervous.

Georg
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculating distance abastien Code Samples & Tips 8 01-10-2009 09:49 AM
Distance-test on UTM and LAT-LON Put Claude Questions (Windows Mobile) 1 10-16-2007 02:06 PM
Distance between UTM zones jerryjukem Questions (Windows Mobile) 3 10-10-2007 11:19 AM
Measuring distance on move Agrartec Code Samples & Tips 15 08-28-2007 02:43 AM
Distance Calculator PatrikL Share Your Creations 7 04-30-2007 06:15 PM


All times are GMT. The time now is 02:13 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0