Android Question GPS Time not changing

stu14t

Active Member
Licensed User
Longtime User
I'm messing about with an app that takes a picture every few meters and uses the UTC time stamp as the picture name. However, the time is not changing when the GPS fix changes.

Here is the section of code that looks after the fix / time change:

B4X:
Sub GPS_LocationChanged (Location1 As Location)
     
    Lat1 = Location1.Latitude 'Get Lat
    Long1 = Location1.Longitude 'Get GPS Long
    Altitude = Location1.Altitude ' Get GPS Alt
    GPSTime = Location1.Time ' Get GPS Time
 
    'This next code just converts Lat Long to OSGB coordinates
    Dim str As String
    Dim digits As Int
    Dim sep As String
    OSGB.WGS84toOSGB36(Lat1, Long1, Altitude)
    str = OSGB.OSGB36toNGR(OSGB.NewLatitude, OSGB.NewLongitude)
    digits = 5 
    sep = " "
    ngr = "GridRef: " & str.SubString2(0, 2) & sep & str.SubString2(2, digits + 2)
    ngr = ngr & sep & str.SubString2(7, digits + 7) & CRLF
    'Removes OSGB if outside UK
    If Local = "English (United Kingdom)" Then
        East = NumberFormat2(OSGB.Easting, 1, 0, 0, False)
        North = NumberFormat2(OSGB.Northing, 1, 0, 0, False)
        ngr = ngr & "National Grid: " & East & " " & North & CRLF
    Else
        East = 0
        North = 0
    End If
 
    PicTime = dt.Format(GPSTime) ' Give the picture the UTC Date / time as picture name.
 
    Log(PicTime)
    camEx.TakePicture ' takes the picture
    CSVWriter ' Writes a corresponding CSV file that links GPS to picture
 
End Sub

And here is the corresponding GPS file which shows Lat, Long, Altitude, Eastings, Northings and PicTime in UTC. This GPS location changes but time (within the picture file name on the far right column) does not change every time. (I've replaced some of the GPS data with XX) There are 19 location changes but only two time changes.

B4X:
Lat    Long    Alt    East    North    Pic
XX.98134665    XX.2359372    114    XX2979    XX7177    2015-12-17T15:19:10.592+0000
XX.98120744    XX.23652013    78    XX2942    XX7163    2015-12-17T15:19:10.592+0000
XX.98110049    XX.23642104    78    XX2948    XX7151    2015-12-17T15:19:10.592+0000
XX.98106336    XX.23611363    66    XX29XX    XX7146    2015-12-17T15:19:10.592+0000
XX.98101XX8    XX.235951XX    85    XX2977    XX7141    2015-12-17T15:19:10.592+0000
XX.98114161    XX.23659628    68    XX2937    XX71XX    2015-12-17T15:19:10.592+0000
XX.98105197    XX.2363XX43    69    XX2952    XX7145    2015-12-17T15:19:10.592+0000
XX.98115443    XX.23XX1069    72    XX2930    XX7157    2015-12-17T15:19:10.592+0000
XX.98112162    XX.236860XX    63    XX2921    XX7153    2015-12-17T15:19:10.592+0000
XX.98108XX4    XX.23702562    68    XX2910    XX7150    2015-12-17T15:19:10.592+0000
XX.98108413    XX.23722216    72    XX2898    XX7150    2015-12-17T15:19:10.592+0000
XX.98111207    XX.23738210    73    XX2888    XX7153    2015-12-17T15:19:10.592+0000
XX.98113348    XX.23754269    69    XX2878    XX7167    2015-12-17T15:19:10.592+0000
XX.98111934    XX.23771388    69    XX28XX    XX7154    2015-12-17T15:19:10.592+0000
XX.98110227    XX.23787885    69    XX2857    XX7152    2015-12-17T15:21:21.664+0000
XX.98105112    XX.23805107    69    XX2846    XX7147    2015-12-17T15:21:21.664+0000
XX.98099344    XX.23818972    69    XX2837    XX7141    2015-12-17T15:21:21.664+0000
XX.98091026    XX.23827197    66    XX2867    XX7131    2015-12-17T15:21:21.664+0000
XX.98082791    XX.23834703    68    XX2827    XX7122    2015-12-17T15:21:21.664+0000

There are 19 location changes but only two time changes.

Is this a GPS issue or my code?
 

stu14t

Active Member
Licensed User
Longtime User
Put a Log(GPSTime) just after
GPSTime = Location1.Time ' Get GPS Time
to see if the time returned by the GPS changes.

Klaus,

The raw ticks from GPSTime are remaining the same. First number is the time ticks and then lat long (Changed a bit) then UTC timestamp:

B4X:
1.450372759552E12 57.98144087 -7.23707366
2015-12-17T17:19:19.552+0000
1.450372759552E12 57.98145754 -7.2370783
2015-12-17T17:19:19.552+0000
1.450372759552E12 57.98146998 -7.23700201
2015-12-17T17:19:19.552+0000
1.450372759552E12 57.98143715 -7.23706442
2015-12-17T17:19:19.552+0000
1.450372759552E12 57.98145378 -7.23699483
2015-12-17T17:19:19.552+0000
1.450372759552E12 57.98149552 -7.23693704

** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **

So, Lat / long changing but GPStime not
 
Upvote 0

stu14t

Active Member
Licensed User
Longtime User
Ah. I don't get the milliseconds if I use Long. I changed it to Float.

I need a millisecond time to accurately locate the picture taken. This is to be used in a car, for example, traveling at 60mph (110kph) there is approximately 20m gap in each second and I'm taking a picture every 5m.
 
Last edited:
Upvote 0

stu14t

Active Member
Licensed User
Longtime User
Klaus,

This is how I format the time:

B4X:
DateTime.DateFormat = "dd-MM-yyyy"
DateTime.TimeFormat = "HH:mm:ss.SSSZ"

And then create the name for the picture:

B4X:
PicTime = DateTime.Date(GPSTime) & "T" & DateTime.Time(GPSTime)

This, after changing back to Long, only rolls over every whole second. However, I haven't tried it in the car (for speed) to see if I get the milliseconds
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Set GPSTime as Long and look at the Logs if the Tick value changes.
I suspected the wrong type declaration because of this: 1.450372759552E12
This is not a display of a Long variable.
First test if the Long typed variable changes in your test.
Your Time format is wrong you should use DateTime.TimeFormat = "HH:mm:ss.sssZ".
 
Upvote 0
Top