# Thread: converting latitude and longitude into x y

1. ## converting latitude and longitude into x y

hello, i would like to know if there is a way of converting latitude and longitude data (from internal gps from n95) into x and y values that can fit on my canvas size. I would like to make a python game that can use my movement in the city to control an avatar . Is there any formula for suck a task?

any hint would be aprreciated.

oyuky.

2. ## Re: converting latitude and longitude into x y

Originally Posted by oyuky
hello, i would like to know if there is a way of converting latitude and longitude data (from internal gps from n95) into x and y values that can fit on my canvas size. I would like to make a python game that can use my movement in the city to control an avatar . Is there any formula for suck a task?

any hint would be aprreciated.

oyuky.
Hi oyuky,

You can have your own formula, but 1st you need to find out the relationship between the Latitude and Longitude values and the X & Y coordinates on the CANVAS. This has its applications in Location based Services (LBS) that make use of maps.
If Someone is working on a similar project, he might be able to help you; otherwise you need to do some testing and on the basis of that devise an formula or algorithm that works.

Best Regards,
Croozeus

3. ## Re: converting latitude and longitude into x y

Check out Nick Burch's excellent site on lat/long conversions, getting internal gps position etc. His code is here http://gagravarr.org/code/

4. ## Re: converting latitude and longitude into x y

Originally Posted by jtullis
Check out Nick Burch's excellent site on lat/long conversions, getting internal gps position etc. His code is here http://gagravarr.org/code/
LocationRequestor module is not mandatory.

There is some possibly useful information at:http://www.ga.gov.au/geodesy/datums/distance.jsp

Ilpo

5. ## Re: converting latitude and longitude into x y

Originally Posted by oyuky
i would like to know if there is a way of converting latitude and longitude data (from internal gps from n95) into x and y values that can fit on my canvas size.
1. convert WGS84 coordinates (from GPS) to UTM (XY) coordinates
2. scale UTM coordinates to fit your canvas

If lat and lon from the internal GPS are N60.2 E25.00 the corresponding UTM coordinates are 389130 (Easting) 6675364 (Northing), zone 35V. Units are meters.

So if you have 100px*100px canvas and 1 pixel is 100 meters, you should be able to show 10km*10km geographical area. If
389130 6675364 is in the middle,
389130 6674364 should be 10 pixels below.

Python library to handle LatLongUTMconversion

Some mapping guru could tell me if I'm missing something here?

6. ## Re: converting latitude and longitude into x y

Originally Posted by aaaaapo
1. convert WGS84 coordinates (from GPS) to UTM (XY) coordinates
2. scale UTM coordinates to fit your canvas

If lat and lon from the internal GPS are N60.2 E25.00 the corresponding UTM coordinates are 389130 (Easting) 6675364 (Northing), zone 35V. Units are meters.

So if you have 100px*100px canvas and 1 pixel is 100 meters, you should be able to show 10km*10km geographical area. If
389130 6675364 is in the middle,
389130 6674364 should be 10 pixels below.

Python library to handle LatLongUTMconversion

Some mapping guru could tell me if I'm missing something here?
Hi aaaaapo,

I think oyuky would be quite happy with that input of yours

Best Regards,
Croozeus

7. ## Re: converting latitude and longitude into x y

yes, thanks for the replies, that LatLongUTMconversion module is cool and works fine, i been experimenting with it, but now i have a new problem: i been trying to adapt the non blocking call of the python for s60 documentation, but instead of printing in the console im trying ti print the latitude and longitude(and the x y converted wih latlongutmconversion) in the canvas, the problem im having is when i run the script my program stays in the console window, do anybody know what is going wrong?

here is the code:

import LatLongUTMconversion
from LatLongUTMconversion import LLtoUTM, UTMtoLL
from graphics import *
import appuifw
import e32
import positioning

appuifw.app.screen='normal'
appuifw.app.title=unicode('My Test App')
canvas=appuifw.Canvas()
appuifw.app.body=canvas

positioning.select_module(positioning.default_module())

positioning.set_requestors([{"type":"service",
"format":"application",
"data":"test_app"}])

def cb(event):
e = d["position"]
canvas.clear()
canvas.text( (2,12), unicode(str(e["latitude"])))
canvas.text( (2,24), unicode(str(e["longitude"])))
l=LLtoUTM(19, e["latitude"], e["longitude"])
canvas.text( (2,34), unicode(str(l[1])))
canvas.text( (2,46), unicode(str(l[2])))
e32.ao_yield()
e32.ao_sleep(1115)

d= positioning.position(course=1,satellites=1,callback=cb, interval=500000,partial=0)

8. ## Re: converting latitude and longitude into x y

oops sorry for pasting not indented code, but when i pasted it itappeared indented before posting.
is there any special way for identing?

9. ## Re: converting latitude and longitude into x y

Originally Posted by oyuky
oops sorry for pasting not indented code, but when i pasted it itappeared indented before posting.
is there any special way for identing?
You need to use the CODE tags (#) for keeping your posts to the indent.

10. ## Re: converting latitude and longitude into x y

cool, thanks

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•