Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [solved] Getting the last known position from GPS
Forum Updated to NodeBB v4.3 + New Features

[solved] Getting the last known position from GPS

Scheduled Pinned Locked Moved QML and Qt Quick
10 Posts 2 Posters 3.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pascal95abc
    wrote on last edited by
    #1

    Hello,

    I need the last known position from my GPS even if it is not turned on.

    Viewranger is a program in which I can see my last known position even if the GPS receiver is turned off.

    How to do so in QML, maybe with the PositionSource element ?

    Thank you

    Qt 4.7.3
    Symbian OS v9.4 / Symbian^1, S60 5th Edition
    on N97

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mlong
      wrote on last edited by
      #2

      You'll have to write some code to store your GPS fixes (either as they come in, or when your program exits) to a file, which you can then read in as your program starts next time. I'm not sure of a QML-native way to do this, but would be easy enough to do through a simple C++ class.

      Software Engineer
      My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

      1 Reply Last reply
      0
      • P Offline
        P Offline
        pascal95abc
        wrote on last edited by
        #3

        Your idea is, I think, the easiest and the one which is the least complicated.

        I am not sure but I really think that these positions are already stored on my device.
        In the example, I used Viewranger to see where I was when I turned off GPS but I don't remeber having run Viewranger when I turned GPS off.

        Qt 4.7.3
        Symbian OS v9.4 / Symbian^1, S60 5th Edition
        on N97

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mlong
          wrote on last edited by
          #4

          bq. I am not sure but I really think that these positions are already stored on my device.

          They may be. But as far as I know, that's not a documented feature that can (or should) be relied upon.

          Software Engineer
          My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

          1 Reply Last reply
          0
          • P Offline
            P Offline
            pascal95abc
            wrote on last edited by
            #5

            Ok, but then, with your solution, I always have to keep my program running in the background with a timer to cyclically write the GPS coordinates in the file if they are !==NaN.

            Then I think of adding my program to the system startup, but how to do so ?
            Maybe a new topic would be appropiate to ask this.

            Qt 4.7.3
            Symbian OS v9.4 / Symbian^1, S60 5th Edition
            on N97

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mlong
              wrote on last edited by
              #6

              I don't think having your app running in the background is a good idea (especially considering battery drain, etc.)

              You had said the "last known" value. That's different than "The current value of the GPS whether or not my app is running."

              Software Engineer
              My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

              1 Reply Last reply
              0
              • P Offline
                P Offline
                pascal95abc
                wrote on last edited by
                #7

                My idea was running my app always in the background and saving the GPS's coordinates in a text file if they are valid (that's what I meant with "!== NaN").
                This app should work as a "helper" app.

                Then when my actual program is run and not GPS is turned on, it checks the file and gets the position.

                But I think you are right that running the program in the background might harm the battery.

                Qt 4.7.3
                Symbian OS v9.4 / Symbian^1, S60 5th Edition
                on N97

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mlong
                  wrote on last edited by
                  #8

                  As I had stated previously, if it's a "good enough" solution, you could always save the last known coordinate that your app knew about as your app shuts down. You shouldn't need to save every position that comes in. Only the final one.

                  Software Engineer
                  My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

                  1 Reply Last reply
                  0
                  • P Offline
                    P Offline
                    pascal95abc
                    wrote on last edited by
                    #9

                    Ok, then I know what to do. Thank you.

                    Qt 4.7.3
                    Symbian OS v9.4 / Symbian^1, S60 5th Edition
                    on N97

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      mlong
                      wrote on last edited by
                      #10

                      You're welcome! Good luck!

                      Software Engineer
                      My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved