Android Question How to match a GPS back turn ?

Status
Not open for further replies.

butel

Member
Licensed User
Hello !
I m french. So my english doesnt match your profile....
My question is on the GPS précision. It seem to bee full less précision.
My aim is to install an application on each telephone gave for each group of studiants of my college.
The objectif of the application is to help wallk back each team.So for do not spend time to find the loosers !
Please, a litel help...
Just for the "going back".
 

Attachments

  • monapp.zip
    8.5 KB · Views: 204

yfleury

Active Member
Licensed User
Longtime User
If your mobile data is active, the precision is more accurate whit gps est cell phone tower.
 
Upvote 0

yfleury

Active Member
Licensed User
Longtime User
Before the student start the way, you have to record latitude and longitude. They go every where and they can clic on button "Go home" to show start point.

How much km they have to run?
They run in city, forest or...
 
Upvote 0

emexes

Expert
Licensed User
Now that I feel a little ashamed for having joked about your students, and I can see from the size of your app project zip file that you've put some work into the app, I figured I'd better make amends.

I've downloaded and compiled your app no problems, and it runs on my Android phone here. First problem I found is that clicking the Enregister button bombs out with an error. I expect that it is the Dir parameter is not set. Presumably the reload function is going to have the same problem.

So... hang on a moment while I get that fixed and tested.
 
Upvote 0

emexes

Expert
Licensed User
Hmm. Got sidetracked, now chasing down why Data seems to be empty or not initialized.

In the meantime, an unrelated observation is that you could probably replace this code:
B4X:
For i = SV.Panel.NumberOfViews -1 To 0 Step -1
    SV.Panel.RemoveViewAt(i)
Next
with
B4X:
SV.Panel.RemoveAllViews
 
Upvote 0

emexes

Expert
Licensed User
Well, that's cute: StringUtils.SaveCSV2 handling of an empty data list is a bit brutal. You'd think it would at least write the headers to the file.

I added to the start of SaveTableToCSV to "fix" the issue:
B4X:
'Saves the table to a CSV file.
Public Sub SaveTableToCSV(Dir As String, Filename As String)
    Log("Table.SaveTableToCSV(" & Dir & ", " & Filename & ")")
   
    If Data.Size = 0 Then
        ToastMessageShow("Nothing to save", False)
        Return
    End If
 
Upvote 0

emexes

Expert
Licensed User
I am indoors, GPS isn't working here. There is a way of having Android spoof location, but I don't have time at moment to go that far.

One idea is: if you want to save the start location, and the data table needs to have at least one row in order for StringUtils.SaveCSV2 to work, perhaps you could designate the first row of the table to be the starting/return location, and if the table is empty when a GPS reading comes in, to grab and store that GPS reading as the start/return location.

Then your return button would know where to guide the user back to (ie, the first location row of Data table).
 
Upvote 0

butel

Member
Licensed User
Well, that's cute: StringUtils.SaveCSV2 handling of an empty data list is a bit brutal. You'd think it would at least write the headers to the file.

I added to the start of SaveTableToCSV to "fix" the issue:
B4X:
'Saves the table to a CSV file.
Public Sub SaveTableToCSV(Dir As String, Filename As String)
    Log("Table.SaveTableToCSV(" & Dir & ", " & Filename & ")")
  
    If Data.Size = 0 Then
        ToastMessageShow("Nothing to save", False)
        Return
    End If
Thank You Emexes ! It works fine.
 
Upvote 0

butel

Member
Licensed User
I continue.
I followed your advice. I have add some line to it.
here is the new app
The next step for me is to show the position of the groupe at each time they clik on the table1. Do you now how can i put a small picture on the map to indicate where they are ?
greetings for you Emexes !
If you find "error", please tell me the line.
It's not simple for me, beginner !
 

Attachments

  • changements.zip
    9.7 KB · Views: 194
Upvote 0

butel

Member
Licensed User
I have put a "end" menu. Actualy empty. Do i can close the APP simply (does it free memory itself or is there som precautions to do ?)
Kiss !
 
Upvote 0

emexes

Expert
Licensed User
In OSMDroid there should be some option to show the current location, or to add a marker to the map at a longitude:latitude position.

You might need to clear/delete the previous marker. Or maybe you can just update the position.

I don't have the OSMDroid library, and I have to get a decent night's sleep tonight, otherwise I'd give it a go.

This posting is fairly recent, might be good enough to get you going:

https://www.b4x.com/android/forum/threads/osmdroid-mapview-and-text-overlays.104490/
 
Upvote 0

emexes

Expert
Licensed User
Do i can close the APP simply (does it free memory itself or is there som precautions to do ?
Good question. I've never ended my apps. I think that if a user wants to *really* end my app, they can just swipe it off the app list that is one button-press away.

Perhaps read this post here:
https://www.b4x.com/android/forum/t...gate-to-previous-activity.107391/#post-671433
which leads to this post here:
https://www.b4x.com/android/forum/threads/exitapplication-vs-activity-finish.79548/#content
 
Upvote 0

emexes

Expert
Licensed User
You're probably already on to this, but just in case:

If you are doing measurements or distance calculations with GPS readings, DON'T get caught up in all the precise spherical trigonometric maths and formulas. It will send you bonkers.

Over "small" areas, eg, within 100 km, the errors are small enough to ignore, eg, if you are telling your students how far they are from the starting point, and they are a kilometre away, does it really matter if that distance is off by a metre or two eg 0.1% ?

Each degree of latitude is 10000000 metres / 90 degrees = 111111 metres (as measured by you French from north pole to equator through Paris, I think ;-).

Each degree of longitude is that same 111111 metres multiplied x Cos(degrees latitude from equator) because they get smaller as you get closer to the north pole.

So to calculate straight-line distance, you can convert degrees to metres, and then use Pythagoras. Remember that the metres-per-degree conversion factors are different for latitude (constant, doesn't change) and longitude (gets smaller as latitude increases).

If you want to be slightly more accurate, you can use the average degrees-latitude-from-equator that spans the area you're calculating across, instead of using the degrees-latitude-from-equator of your current location.
 
Last edited:
Upvote 0

butel

Member
Licensed User
Good question. I've never ended my apps. I think that if a user wants to *really* end my app, they can just swipe it off the app list that is one button-press away.

Perhaps read this post here:
https://www.b4x.com/android/forum/t...gate-to-previous-activity.107391/#post-671433
which leads to this post here:
https://www.b4x.com/android/forum/threads/exitapplication-vs-activity-finish.79548/#content
I m pourly a french guy and don't understand the content of thoses link...for me, it's a wild empty world...Sorry !
Denis.
 
Upvote 0

butel

Member
Licensed User
I have tested some of this links. But my application continue to work...
What can i do for close it all ?
If you have a solution, i take !
An other kiss...for the high story here, and your efforts to understand me
Denis.
 
Upvote 0

butel

Member
Licensed User
Closing App doesnt cast ! It's seem difficult to find a "propre" way to do it.
And an other kiss...
 
Last edited:
Upvote 0

emexes

Expert
Licensed User
If your user wants to end the app, they can press the Android "task list" button (the third button, next to the "back" and "home" buttons) and swipe the app to end it.

For your app to end itself, I guess that it must explicitly close down any services that are running (eg, Starter service? GPS?). I have never done this, so I do not know the procedure without having to study the documentation.
 
Upvote 0

butel

Member
Licensed User
Hello !!! i have new questions...i hope you have deux answers....it 'll be great for me...
Here is the code :
------------------------------------------------------------
Activity.LoadLayout("carte1")
carte1.Initialize("")
Activity.AddView(carte1, 0, 0, 100%x, 100%y)
carte1.SetMultiTouchEnabled(True)
carte1.SetZoomEnabled(True)
TileSource="Mapnik"
ZoomLevel=18
Activity.Title = "Ce point est : " & lat1 & " Et "& lon1
MapCenter.Initialize(lat1, lon1)
carte1.Zoom=ZoomLevel
carte1.SetCenter3(MapCenter)
information.Initialize ("information") ' information is declare as label object
Activity.AddView (information,0,100%y-48dip,100%x,48dip)
information.TextSize=14
information.Text=GTOU ' GTOU is a string like "Vous étiez ici le 12/07/2019 à 10/30/15"
------------------------------------------------------------------------------------------------
My first question is "how can i do to center the texte in the label created ?



Second probleme : i have found some code example to put a small yellow man on the "carte1".
this little yellow man is always a little too far to the right of the position (latitude, longitude) selected. The small gap seems to be related to the width of the little guy.
the second question is: how can I get the height and width of this little yellow guy?
-------------------------------------------------------------------------------------------------

Have a nice day for all of us !
 
Upvote 0
Status
Not open for further replies.
Top