Live map widget

Alex Garbino wrote:

Hello,

I'm just starting with python, and I'm trying develop a widget that
shows my position on a map, and updates it as new position information
comes in.
I found some examples with tk (pyGPS), but I want to use wxPython.
Furthermore, this is to use in a racecar (track the car position as it
goes around the circuit), so I don't need to use some big database of
the world (like basemap in the matlibplot module); I can draw the map
form aerial pictures (from Google earth) as a vector graphic, or I
could also do a few laps and use that data to draw the map.

Can someone give me some pointers on how to do this?
Specifically, I don't know:
- How I should build the window that draws the map: is it a picture
display? (I've gone through the simple text editor example, and looked
at demos)

- How do I update the position on the track? Do I draw a dot, delete
it, and then redraw it? (I get GPS position data every second)

You can do this with a custom window class without too much trouble. The basic drawing sequence would be something like this:

  1. draw the background image to a bitmap
  2. draw icons (or whatever) for the racers on the same bitmap
  3. draw the bitmap to the screen

See the samples in the demo and wiki for double buffered drawing for code showing the basic techniques of doing the above. If you ever have very many racers or need more than 1 second accuracy then there are some things you can do to optimize the drawing, but I expect that the simpler approach will be good enough for most situations.

- I found some examples (in the pyGPS/basemap examples) on how to
convert the lat/long to x,y coords, but how do I draw a dot on the map
with this (hopefully an example is out there..)

I don't have any experience with something like this, but I would think that utilizing some sort of calibration/setup phase would be a good way to go. In other words, your app can have a mode where you can take GPS readings and allow the user to manually mark that position on the image of the track. If you store a number of those positions then when the software is running in race mode you can take the incoming GPS data and interpolate positions on your track image based on the prior readings.

ยทยทยท

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!