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. GeocodeModel does not work
Forum Updated to NodeBB v4.3 + New Features

GeocodeModel does not work

Scheduled Pinned Locked Moved Solved QML and Qt Quick
14 Posts 5 Posters 1.5k 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.
  • S Offline
    S Offline
    Samuel Ives
    wrote on last edited by
    #1
    import QtQuick 2.0
    import QtLocation 5.11
    import QtPositioning 5.11
    
    Rectangle{
    
        // Icone que representa um marcador no mapa
        Image {
            id: ic_marker
            source: "qrc:///icons/icons/ic_map_marker.svg"
            sourceSize.width:  50
            sourceSize.height: 50
        }
    
        // Plugin responsavel por executar requisicoes de dados para o mapa
        Plugin{
            id: osm
            name: "osm"
            PluginParameter{name: "osm.useragent"; value: "TGAdmin"}
            PluginParameter{name: "osm.mapping.custom.host"; value: "https://tile.openstreetmap.org"}
            PluginParameter{name: "osm.mapping.providersrepository.disabled"; value: true}
        }
    
        // Marcador da posicao do tiro de guerra no mapa
        MapQuickItem{
            id: tgMarker
            anchorPoint.x: tgMarker.width / 4
            anchorPoint.y: tgMarker.height
            coordinate: QtPositioning.coordinate(latitude, longitude)
            sourceItem: ic_marker
        }
    
        Address {
            id :fromAddress
            street: "Sandakerveien 116"
            city: "Oslo"
            country: "Norway"
            state : ""
            postalCode: "0484"
        }
    
        GeocodeModel{
            id: geoAt
            plugin: osm
            autoUpdate: false
        }
    
        // O mapa em si
        Map{
    
            id: mapa
            anchors.fill: parent
            plugin: osm
            zoomLevel: 17
            center: QtPositioning.coordinate(latitude, longitude)
    
            Component.onCompleted: {
                addMapItem(tgMarker)
    
                geoAt.query = fromAddress
                geoAt.update()
    
                console.log("Enderecos obtidos: ", geoAt.count)
            }
    
        }
    
    }
    

    I've been trying to get the geographic coordinates of an address for about a week but nothing is returned.

    The rest of the map works normally, I need this because the system I'm developing must trace a route to the address provided by the register.

    KillerSmathK 1 Reply Last reply
    0
    • S Samuel Ives
      import QtQuick 2.0
      import QtLocation 5.11
      import QtPositioning 5.11
      
      Rectangle{
      
          // Icone que representa um marcador no mapa
          Image {
              id: ic_marker
              source: "qrc:///icons/icons/ic_map_marker.svg"
              sourceSize.width:  50
              sourceSize.height: 50
          }
      
          // Plugin responsavel por executar requisicoes de dados para o mapa
          Plugin{
              id: osm
              name: "osm"
              PluginParameter{name: "osm.useragent"; value: "TGAdmin"}
              PluginParameter{name: "osm.mapping.custom.host"; value: "https://tile.openstreetmap.org"}
              PluginParameter{name: "osm.mapping.providersrepository.disabled"; value: true}
          }
      
          // Marcador da posicao do tiro de guerra no mapa
          MapQuickItem{
              id: tgMarker
              anchorPoint.x: tgMarker.width / 4
              anchorPoint.y: tgMarker.height
              coordinate: QtPositioning.coordinate(latitude, longitude)
              sourceItem: ic_marker
          }
      
          Address {
              id :fromAddress
              street: "Sandakerveien 116"
              city: "Oslo"
              country: "Norway"
              state : ""
              postalCode: "0484"
          }
      
          GeocodeModel{
              id: geoAt
              plugin: osm
              autoUpdate: false
          }
      
          // O mapa em si
          Map{
      
              id: mapa
              anchors.fill: parent
              plugin: osm
              zoomLevel: 17
              center: QtPositioning.coordinate(latitude, longitude)
      
              Component.onCompleted: {
                  addMapItem(tgMarker)
      
                  geoAt.query = fromAddress
                  geoAt.update()
      
                  console.log("Enderecos obtidos: ", geoAt.count)
              }
      
          }
      
      }
      

      I've been trying to get the geographic coordinates of an address for about a week but nothing is returned.

      The rest of the map works normally, I need this because the system I'm developing must trace a route to the address provided by the register.

      KillerSmathK Offline
      KillerSmathK Offline
      KillerSmath
      wrote on last edited by KillerSmath
      #2

      @Samuel-Ives
      GeocodeModel's request is not synchronous. It means your code will always print Enderecos obtidos: 0, because the count has not changed.

      If you need to capture the coordinate when the request ends, you may connect a function to locationsChanged signal.
      See a example:

      GeocodeModel{
              id: geoAt
              plugin: osm
              autoUpdate: false
              onLocationsChanged: { // when reply
                  if (count > 0){ // found a location
                      console.log(get(0).coordinate); // print the coordinate
                  }
              }
          }
      

      @Computer Science Student - Brazil
      Web Developer and Researcher
      “Sometimes it’s the people no one imagines anything of who do the things that no one can imagine.” - Alan Turing

      1 Reply Last reply
      2
      • S Offline
        S Offline
        Samuel Ives
        wrote on last edited by Samuel Ives
        #3

        still without any coordinates, I made this small change as suggested:

        GeocodeModel{
                id: geoAt
                plugin: osm
                autoUpdate: false
                onLocationsChanged: {
        
                    if(count > 0){
        
                        mapa.Center = QtPositioning.coordinate(get(0).coordinate.latitude, get(0).coordinate.longitude)
                        console.log("Coordenadas: ", get(0).coordinate.latitude, " ", get(0).coordinate.longitude)
        
                    }
        
                }
            }
        
            // O mapa em si
            Map{
        
                id: mapa
                anchors.fill: parent
                plugin: osm
                zoomLevel: 17
                center: QtPositioning.coordinate(latitude, longitude)
        
                Component.onCompleted: {
                    addMapItem(tgMarker)
        
                    geoAt.query = fromAddress.text
                    console.log("Endereco: ", fromAddress.text)
                    geoAt.update()
        
        
                    console.log("Enderecos obtidos: ", geoAt.count)
                }
        
            }
        

        And this is the result:

        0_1557236981412_6328759f-e93f-4c0c-8b04-a0fcd18c0872-image.png

        *This time I also tried with a text in place of the address

        raven-worxR 1 Reply Last reply
        0
        • S Samuel Ives

          still without any coordinates, I made this small change as suggested:

          GeocodeModel{
                  id: geoAt
                  plugin: osm
                  autoUpdate: false
                  onLocationsChanged: {
          
                      if(count > 0){
          
                          mapa.Center = QtPositioning.coordinate(get(0).coordinate.latitude, get(0).coordinate.longitude)
                          console.log("Coordenadas: ", get(0).coordinate.latitude, " ", get(0).coordinate.longitude)
          
                      }
          
                  }
              }
          
              // O mapa em si
              Map{
          
                  id: mapa
                  anchors.fill: parent
                  plugin: osm
                  zoomLevel: 17
                  center: QtPositioning.coordinate(latitude, longitude)
          
                  Component.onCompleted: {
                      addMapItem(tgMarker)
          
                      geoAt.query = fromAddress.text
                      console.log("Endereco: ", fromAddress.text)
                      geoAt.update()
          
          
                      console.log("Enderecos obtidos: ", geoAt.count)
                  }
          
              }
          

          And this is the result:

          0_1557236981412_6328759f-e93f-4c0c-8b04-a0fcd18c0872-image.png

          *This time I also tried with a text in place of the address

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @Samuel-Ives
          i know that GeoCodeModel (using osm) was broken in Qt 5.10 (or at least in the meantime broken) and working again with 5.12.
          I can't tell if that was still the case with Qt 5.11

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

          1 Reply Last reply
          1
          • S Offline
            S Offline
            Samuel Ives
            wrote on last edited by
            #5

            esri is not working either, I do not think it's a plugin specific problem

            Pablo J. RoginaP KillerSmathK 2 Replies Last reply
            0
            • S Samuel Ives

              esri is not working either, I do not think it's a plugin specific problem

              Pablo J. RoginaP Offline
              Pablo J. RoginaP Offline
              Pablo J. Rogina
              wrote on last edited by
              #6

              @Samuel-Ives could it be possible you do network traffic capture (i.e. using Wireshark) to check if the request(s) made by the plugin(s) (either osm or esri) are reaching the Internet and what response(s) do you received, if any?
              At least you could figure out if the problem is the request/response (network operations) or the display of information received?

              Upvote the answer(s) that helped you solve the issue
              Use "Topic Tools" button to mark your post as Solved
              Add screenshots via postimage.org
              Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

              1 Reply Last reply
              0
              • S Samuel Ives

                esri is not working either, I do not think it's a plugin specific problem

                KillerSmathK Offline
                KillerSmathK Offline
                KillerSmath
                wrote on last edited by KillerSmath
                #7

                @Samuel-Ives
                I got the same behavior when i used geoAt.query = fromAddress.text instead of geoAt.query = fromAddress

                Edit: It is possible to know if something wrong happens if you connect onStatusChanged signal with a function.

                onStatusChanged: {
                    if(status === GeocodeModel.Ready){
                        console.log("Sucess, the request has been found "+count+" result(s).");
                    }
                    else if(status === GeocodeModel.Error){
                        console.log("Error: " + errorString);
                    }
                }
                

                @Computer Science Student - Brazil
                Web Developer and Researcher
                “Sometimes it’s the people no one imagines anything of who do the things that no one can imagine.” - Alan Turing

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  Samuel Ives
                  wrote on last edited by
                  #8
                  onStatusChanged: {
                  
                              switch(geoAt.status){
                  
                              case GeocodeModel.Loading:
                                  console.log("Loading")
                                  break;
                  
                              case GeocodeModel.Ready:
                                  console.log("Ready")
                                  break;
                  
                              case GeocodeModel.Error:
                                  console.log("Error: ", errorString)
                                  break;
                  
                              }
                  
                          }
                  

                  I got this

                  qml: Endereco: Sandakerveien 116<br/>0484 Oslo<br/>Norway
                  qml: Loading
                  qml: Enderecos obtidos: 0
                  qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed
                  qml: Error: TLS initialization failed

                  The strangest thing is that I do not remember any time using SSL

                  Pablo J. RoginaP KillerSmathK 2 Replies Last reply
                  0
                  • S Samuel Ives
                    onStatusChanged: {
                    
                                switch(geoAt.status){
                    
                                case GeocodeModel.Loading:
                                    console.log("Loading")
                                    break;
                    
                                case GeocodeModel.Ready:
                                    console.log("Ready")
                                    break;
                    
                                case GeocodeModel.Error:
                                    console.log("Error: ", errorString)
                                    break;
                    
                                }
                    
                            }
                    

                    I got this

                    qml: Endereco: Sandakerveien 116<br/>0484 Oslo<br/>Norway
                    qml: Loading
                    qml: Enderecos obtidos: 0
                    qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed
                    qml: Error: TLS initialization failed

                    The strangest thing is that I do not remember any time using SSL

                    Pablo J. RoginaP Offline
                    Pablo J. RoginaP Offline
                    Pablo J. Rogina
                    wrote on last edited by
                    #9

                    @Samuel-Ives

                    The strangest thing is that I do not remember any time using SSL

                    From you 1st post:

                    PluginParameter{name: "osm.mapping.custom.host"; value: "https://tile.openstreetmap.org"}
                    

                    Are you still using the same values? if so, that could be the answer...

                    Upvote the answer(s) that helped you solve the issue
                    Use "Topic Tools" button to mark your post as Solved
                    Add screenshots via postimage.org
                    Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                    1 Reply Last reply
                    1
                    • S Samuel Ives
                      onStatusChanged: {
                      
                                  switch(geoAt.status){
                      
                                  case GeocodeModel.Loading:
                                      console.log("Loading")
                                      break;
                      
                                  case GeocodeModel.Ready:
                                      console.log("Ready")
                                      break;
                      
                                  case GeocodeModel.Error:
                                      console.log("Error: ", errorString)
                                      break;
                      
                                  }
                      
                              }
                      

                      I got this

                      qml: Endereco: Sandakerveien 116<br/>0484 Oslo<br/>Norway
                      qml: Loading
                      qml: Enderecos obtidos: 0
                      qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed
                      qml: Error: TLS initialization failed

                      The strangest thing is that I do not remember any time using SSL

                      KillerSmathK Offline
                      KillerSmathK Offline
                      KillerSmath
                      wrote on last edited by
                      #10

                      @Samuel-Ives
                      https://doc.qt.io/qt-5/location-plugin-osm.html#overview

                      Since Qt 5.9.6 the default nominatim endpoint, used for geocoding and places, has also changed to HTTPS-only.

                      @Computer Science Student - Brazil
                      Web Developer and Researcher
                      “Sometimes it’s the people no one imagines anything of who do the things that no one can imagine.” - Alan Turing

                      1 Reply Last reply
                      1
                      • S Offline
                        S Offline
                        Samuel Ives
                        wrote on last edited by
                        #11

                        Well, I compiled the openssl source code, I added the libraries in my project and added the dlls, but it still has the same error

                        N 1 Reply Last reply
                        0
                        • S Samuel Ives

                          Well, I compiled the openssl source code, I added the libraries in my project and added the dlls, but it still has the same error

                          N Offline
                          N Offline
                          Nifiro
                          wrote on last edited by
                          #12

                          @Samuel-Ives
                          https://slproweb.com/download/Win64OpenSSL_Light-1_0_2r.exe
                          https://doc.qt.io/qt-5/qsslsocket.html#sslLibraryBuildVersionString

                          1 Reply Last reply
                          0
                          • S Offline
                            S Offline
                            Samuel Ives
                            wrote on last edited by
                            #13

                            the version returned was OpenSSL 1.0.2p, and the one I compiled was 1.1.1, could that influence something? What I find strange is that I'm not using a ssl resource directly, just that url, the compiler does not accuse me of linking errors regarding openssl

                            1 Reply Last reply
                            0
                            • S Offline
                              S Offline
                              Samuel Ives
                              wrote on last edited by
                              #14

                              Problem solved, I downloaded the dlls from here and it worked http://slproweb.com/products/Win32OpenSSL.html, I'm already getting the coordinates, the libraries were not being loaded because they had a different name

                              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