Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Archived:How to read GPS data in PySymbian

From Wiki
Jump to: navigation, search

Archived.pngAquivado: Este artigo foi arquivado, pois o conteúdo não é mais considerado relevante para se criar soluções comerciais atuais. Se você achar que este artigo ainda é importante, inclua o template {{ForArchiveReview|escreva a sua justificativa}}.

All PySymbian articles have been archived. PySymbian is no longer maintained by Nokia and is not guaranteed to work on more recent Symbian devices. It is not possible to submit apps to Nokia Store.

This code snippet explains how to use the positioning module to get information from an internal or external GPS module in PySymbian.

Article Metadata
Platform(s): S60 2nd Edition FP 2, S60 3rd Edition
Keywords: positioning
Created: ilpo55 (28 Jul 2008)
Last edited: hamishwillee (31 May 2013)


Get a GPS lock at least once before using this code to maximize efficiency.


import e32, appuifw, positioning
def gps_init():
#This function will start the updating of global variable (dictionary) 'gps_data' every 0.2 sec.
#0.2 sec comes form 'interval = 200000' set according to your needs
#This function uses callback funtion gps
global gps_data
#First this fills the gps_data with 0.0 so that there is something before the first gps update
gps_data = {
'satellites': {'horizontal_dop': 0.0, 'used_satellites': 0, 'vertical_dop': 0.0, 'time': 0.0,'satellites': 0, 'time_dop':0.0},
'position': {'latitude': 0.0, 'altitude': 0.0, 'vertical_accuracy': 0.0, 'longitude': 0.0, 'horizontal_accuracy': 0.0},
'course': {'speed': 0.0, 'heading': 0.0, 'heading_accuracy': 0.0, 'speed_accuracy': 0.0}
positioning.position(course=1,satellites=1,callback=gps, interval=200000,partial=0)
appuifw.note(u'Problem with GPS','error')
def gps(event):
global gps_data
gps_data = event
def gps_stop():
#This function stops GPS
appuifw.note(u'Problem with GPS','error')
count = 0
while True:
count = count + 1
sat = gps_data['satellites']['used_satellites']
pos_lat = gps_data['position']['latitude']
pos_long = gps_data['position']['longitude']
speed = gps_data['course']['speed']
print count, sat, pos_lat, pos_long,speed
This page was last modified on 31 May 2013, at 01:05.
42 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.