Android Question How to match a GPS back turn ?

Discussion in 'Android Questions' started by butel, Jul 8, 2019.

Thread Status:
Not open for further replies.
  1. butel

    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".
     

    Attached Files:

  2. klaus

    klaus Expert Licensed User

    Googeling a bit, I found that the accuracy is about 10 to 15m.
    I have no experience on how to collect positions of other phones.
     
  3. yfleury

    yfleury Active Member Licensed User

    If your mobile data is active, the precision is more accurate whit gps est cell phone tower.
     
  4. yfleury

    yfleury Active Member Licensed 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...
     
  5. emexes

    emexes Well-Known Member Licensed User

    [JOKE]This could be a useful app for biology subjects too: a practical demonstration of natural selection trimming the class to those likely to succeed.[/JOKE]
     
    priusfan, Shelby, butel and 2 others like this.
  6. emexes

    emexes Well-Known Member 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.
     
    Shelby likes this.
  7. emexes

    emexes Well-Known Member 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:
    Code:
    For i = SV.Panel.NumberOfViews -1 To 0 Step -1
        SV.Panel.RemoveViewAt(i)
    Next
    with
    Code:
    SV.Panel.RemoveAllViews
     
    Shelby likes this.
  8. emexes

    emexes Well-Known 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:
    Code:
    '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
     
    Shelby likes this.
  9. emexes

    emexes Well-Known Member 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).
     
  10. butel

    butel Member Licensed User

    Thank You Emexes ! It works fine.
     
  11. butel

    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 !
     

    Attached Files:

  12. butel

    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 !
     
    Shelby likes this.
  13. emexes

    emexes Well-Known Member 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/
     
    Shelby likes this.
  14. emexes

    emexes Well-Known 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
     
    Shelby likes this.
  15. emexes

    emexes Well-Known Member 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: Jul 9, 2019
    butel and Shelby like this.
  16. butel

    butel Member Licensed User

    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.
     
  17. butel

    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.
     
  18. butel

    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: Jul 9, 2019
  19. emexes

    emexes Well-Known Member 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.
     
  20. butel

    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 !
     
Thread Status:
Not open for further replies.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice