You Are Here:

Community: Wiki

This page was last modified on 26 September 2009, at 18:43.

How to read GPS data in Python for S60

From Forum Nokia Wiki

(Redirected from How to read GPS data)
Reviewer Approved   
Reviewer Approved   



ID Creation date July 28, 2008
Platform S60 2nd Edition FP 2, S60 3rd Edition Tested on devices
Category Python Subcategory Location Based Services


Keywords (APIs, classes, methods, functions): positioning

Overview

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

Prerequisites

It is recommended to get a GPS lock at least once before using this code to maximize efficiency.

Code

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}
}
try:
positioning.select_module(positioning.default_module())
positioning.set_requestors([{"type":"service","format":"application","data":"gps_app"}])
positioning.position(course=1,satellites=1,callback=gps, interval=200000,partial=0)
e32.ao_sleep(3)
except:
appuifw.note(u'Problem with GPS','error')
 
def gps(event):
global gps_data
gps_data = event
 
def gps_stop():
#This function stops GPS
try:
positioning.stop_position()
except:
appuifw.note(u'Problem with GPS','error')
 
 
#Testing
gps_init()
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
e32.ao_sleep(1)

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fHowE5ftoE5freadE5fGPSE5fdataE5finE5fPythonE5fforE5fS60X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZpythonQ qfnZtopicQUqfnTopicZseriesE5f60Q qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qfnZuserE5ftagQSxpythonX qfnZuserE5ftagQSxs60X qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ