Not sure why nobody's answered this, perhaps there's some complexity that I'm not seeing.
Presumably you're talking about the same type of movement as on
www.flightradar24.com also.
In which case, for each moving marker, you'd need to keep track of the previous position update (longitude, latitude, timestamp) and its velocity (longitudinal and latitudinal), and then when a new update comes in:
NewTimestamp = DateTime.Now
Dim DeltaTime As Float = (NewTimeStamp - OldTimestamp) / 1000
If DeltaTime < say 5 seconds then
LongitudinalSpeed = (NewLongitude - OldLongitude) / DeltaTime
LatitudinalSpeed = (NewLatitude - OldLatitude) / DeltaTime
End If
OldTimestamp = NewTimestamp
OldLongitude = NewLongitude
OldLatitude = NewLatitude
and then in a separate timer tick routine (every second or so), you'd update the marker positions like:
Dim CurrentTime As Long = DateTime.Now
for each marker do
Dim DeltaTime As Float = (CurrentTime - OldTimeStamp) / 1000
If DeltaTime > SomeTimeoutPeriod Then
'if no updates for a long time, remove marker from display
Else If DeltaTime < SomeValidPeriod Then
Dim CurrentLongitude As Double = OldLongitude + LongitudinalSpeed * DeltaTime
Dim CurrentLatitude As Double = OldLatitude + LatitudinalSpeed * DeltaTime
'update marker position on map
Else
'marker should already be on map, but we're not getting updates, so leave it at our best guess of current position
End If
Note that:
- Longitude and Latitude should be stored as Double, not Float
because a Float gives 24 bits of resolution = 1-in-16M = 3 metres resolution at equator etc, which is a bit borderline for our purpose.
- The check on DeltaTime in the position update code was to prevent speed from being calculated for the first position update (when you don't have a previous position). But... now that I think about it: even if you did do the speed calculation, you'd have a humongous DeltaTime and thus the speed components would be close enough to zero to not cause a problem, and even if it did, it'd resolve itself within seconds when the next position update arrived.
- Unless you are plotting UFOs or meteors or some other super-high-speed object, then you can side-step all the spherical-to-cartesian math, because the mismatch between the two will be negligible between your position updates, and the error will be reset each update anyway ie it won't accumulate and cause trouble.
Hmm, maybe the prospect of having to do that spherical geometry is the reason for no replies.