1

I am currently involved in a student project which is to turn string GPS coordinates into a GPS tracker. This is my current work: First, the UDP data is shared through a LAN (No internet available) therefore, I get it with an UDP socket. The frame: (DDS coordinates)

"lat+4542000lon-00019590alt+658"

Then I translate it in DD coordinates so that I can show it on the map using this code:

plane=QgsVertexMarker(canvas)
plane.setColor(QColor("blue"))
plane.setIconSize(10)
plane.setIconType(QgsVertexMarker.ICON_CROSS)
plane.setPenWidth(3)
plane.setCenter(QgsPoint(lon,lat))
plane.show()

With 1 mark it works very well. But I receive new frame every second and I'd like to move this mark simultaneously. That's why I tried this:

#I assumed that the first point is already shown
while n<3600:
    data,addr=sock.recvfrom(1024)
    lat,lon,alt=prepare(data)
    plane.hide()
    plane.setCenter(QgsPoint(lon,lat))
    plane.show()
    n+=1

But when I run this, Qgis is frozen until the last mark appears while I expect to see one mark after another and to run QGIS normally. How can I fix it? --QGIS 2.14, Python 2.7, Windows 7 32bits, no internet--

  • 1
    Is there a specific reason you are working with QGIS 2.14? – Erik Aug 14 at 11:56
  • Yes, in fact this project is for an aeroclub which uses QGIS 2.14. Do you think it causes difficulties? – MiddleC Aug 14 at 12:11
  • I have no idea, I just know that newer versions of QGIS tend to incorporate more/better working functionalities. – Erik Aug 14 at 12:22
0

Maybe your can try the try and except condition to make sure where things goes wrong. Something like this :

while n<3600 :
try :
your code
except:
whatever condition you want to test

At least if it still doesn't work it should not freeze anymore.

  • Thanks for your advice. I tried it but it still doesn't work. So, I tried with a list of coordinates adding time.sleep(1) and it froze again. I concluded that my issue is not specifically linked to my way to get data. Have you any idea where I'm doing wrong? – MiddleC Aug 26 at 8:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.