Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. coordinates are nan for latitude and logitude

coordinates are nan for latitude and logitude

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
5 Posts 2 Posters 836 Views 2 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.
  • J Offline
    J Offline
    Jasur
    wrote on last edited by
    #1

    Hi all
    Below code worked fine before.I am getting nan for latitude and longitude now.
    In .pro file i have: QT += quick quickcontrols2 sql qml positioning network core
    location
    import QtPositioning 5.12 also i have
    GPS on Android device is ON
    SDK platform 30
    NDK 21.3.65

    My main idea is to get GPS coordinates from Android device and send to database

    Page {
        property string lat
        property string lon
        property date currentTime: new Date()
        property string timeString
        property string textString
        property string photoString
    
        Rectangle {
            id: rect1
            anchors.fill: parent
    
    
    
            POST_REQ_CAMERA {
                id: demo
            }
    
    
            PositionSource {
                id: src
                updateInterval: 5000
                active: true
    
                onPositionChanged: {
                    var coord = src.position.coordinate;
                    console.log("Coordinate:", coord.latitude,coord.longitude );
                    lat=coord.latitude;
                    //lat=src.position.coordinate.latitude
                    lon=coord.longitude;
    
                }
    
            }
    
            Image {
                id: photoPreview
    
                anchors.fill: parent
                fillMode: Image.PreserveAspectFit
            }
    
    
            Camera {
                id: camera
                imageProcessing.whiteBalanceMode: CameraImageProcessing.WhiteBalanceFlash
                captureMode: Camera.CaptureStillImage
    
                exposure {
                    exposureCompensation: -1.0
                    exposureMode: Camera.ExposurePortrait
                }
    
                flash.mode: Camera.FlashRedEyeReduction
    
                imageCapture {
                    id: imageSaved
                    onImageSaved:  {
    
                        //photoPreview.source = preview
                        photoString=path
                        //demo.processImage(preview);
                    }
                }
            }
    
    
            VideoOutput {
                source: camera
                //anchors.fill: parent
                //focus : visible // to receive focus and capture key events when visible
            }
    
            Button {
                id: cpatureButton
    
                opacity: 0.5
    
                Text {
                    id: textId
                    text: qsTr("Take Photo")
                    color: "white"
                }
                onClicked: {
                    camera.imageCapture.capture();
                    cpatureButton.enabled=false
                    textId.visible=false
                    sendButton.visible = true
                    sendButton.enabled = true
                    complainText.visible = true
    
    
                }
            }
    
            Button {
                id: sendButton
    
                text: "Send"
                visible : false
                enabled: false
    
    
    
                onClicked:
                {
                    timeString = currentTime.toLocaleString(locale,"yyyy-MM-dd hh:mm:ss");//  Locale.ShortFormat);
                    textString = complainText.text
                    demo.upload(lat,lon, timeString,textString, photoString)
                    console.log(lat,lon,timeString, textString, photoString);
                }
            }
    
            TextField {
                id: complainText
    
                x: parent.width/2
                y: parent.bottom
                visible : false
                width: 160
                placeholderText: "Enter Text Here"
                focus: true
                color: "#aaa"
                text: lat + lon
            }
    
    
        }
    }
    
    raven-worxR 1 Reply Last reply
    0
    • J Jasur

      Hi all
      Below code worked fine before.I am getting nan for latitude and longitude now.
      In .pro file i have: QT += quick quickcontrols2 sql qml positioning network core
      location
      import QtPositioning 5.12 also i have
      GPS on Android device is ON
      SDK platform 30
      NDK 21.3.65

      My main idea is to get GPS coordinates from Android device and send to database

      Page {
          property string lat
          property string lon
          property date currentTime: new Date()
          property string timeString
          property string textString
          property string photoString
      
          Rectangle {
              id: rect1
              anchors.fill: parent
      
      
      
              POST_REQ_CAMERA {
                  id: demo
              }
      
      
              PositionSource {
                  id: src
                  updateInterval: 5000
                  active: true
      
                  onPositionChanged: {
                      var coord = src.position.coordinate;
                      console.log("Coordinate:", coord.latitude,coord.longitude );
                      lat=coord.latitude;
                      //lat=src.position.coordinate.latitude
                      lon=coord.longitude;
      
                  }
      
              }
      
              Image {
                  id: photoPreview
      
                  anchors.fill: parent
                  fillMode: Image.PreserveAspectFit
              }
      
      
              Camera {
                  id: camera
                  imageProcessing.whiteBalanceMode: CameraImageProcessing.WhiteBalanceFlash
                  captureMode: Camera.CaptureStillImage
      
                  exposure {
                      exposureCompensation: -1.0
                      exposureMode: Camera.ExposurePortrait
                  }
      
                  flash.mode: Camera.FlashRedEyeReduction
      
                  imageCapture {
                      id: imageSaved
                      onImageSaved:  {
      
                          //photoPreview.source = preview
                          photoString=path
                          //demo.processImage(preview);
                      }
                  }
              }
      
      
              VideoOutput {
                  source: camera
                  //anchors.fill: parent
                  //focus : visible // to receive focus and capture key events when visible
              }
      
              Button {
                  id: cpatureButton
      
                  opacity: 0.5
      
                  Text {
                      id: textId
                      text: qsTr("Take Photo")
                      color: "white"
                  }
                  onClicked: {
                      camera.imageCapture.capture();
                      cpatureButton.enabled=false
                      textId.visible=false
                      sendButton.visible = true
                      sendButton.enabled = true
                      complainText.visible = true
      
      
                  }
              }
      
              Button {
                  id: sendButton
      
                  text: "Send"
                  visible : false
                  enabled: false
      
      
      
                  onClicked:
                  {
                      timeString = currentTime.toLocaleString(locale,"yyyy-MM-dd hh:mm:ss");//  Locale.ShortFormat);
                      textString = complainText.text
                      demo.upload(lat,lon, timeString,textString, photoString)
                      console.log(lat,lon,timeString, textString, photoString);
                  }
              }
      
              TextField {
                  id: complainText
      
                  x: parent.width/2
                  y: parent.bottom
                  visible : false
                  width: 160
                  placeholderText: "Enter Text Here"
                  focus: true
                  color: "#aaa"
                  text: lat + lon
              }
      
      
          }
      }
      
      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @Jasur
      at what position in your code do you get NaN?

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      J 1 Reply Last reply
      0
      • raven-worxR raven-worx

        @Jasur
        at what position in your code do you get NaN?

        J Offline
        J Offline
        Jasur
        wrote on last edited by
        #3

        @raven-worx On a huawei mobile device, after clicking on the send button, I display the lat and lon on the text field where I get the result of the nan. In below code i get nan

        text: lat + lon
        
        raven-worxR 1 Reply Last reply
        0
        • J Jasur

          @raven-worx On a huawei mobile device, after clicking on the send button, I display the lat and lon on the text field where I get the result of the nan. In below code i get nan

          text: lat + lon
          
          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @Jasur
          and this output is still ok?

          console.log("Coordinate:", coord.latitude,coord.longitude );

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          J 1 Reply Last reply
          0
          • raven-worxR raven-worx

            @Jasur
            and this output is still ok?

            console.log("Coordinate:", coord.latitude,coord.longitude );

            J Offline
            J Offline
            Jasur
            wrote on last edited by
            #5

            @raven-worx when i choose desktop kit console.log shows me coordinates, but for android kit there is no console.log output, that is why i used

            text: lat + lon
            

            to check coordinates

            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