Alex Garbino wrote:
> Hello,
>
> I'm trying to plot GPS points onto a canvas. I'm basing my script on
> the vectorplot demo. I removed drawing the axes, etc. I've tried to
> modify the Plot function but haven't succeeded.
well, what is it doing or not doing?
> SAMPLE SOURCE DATA:
I'll leave the parsing of that to you...
> import os, math
just as a note, numpy provides most of the math functions.
> def Plot(self, event = None):
>
> x =0
> y =0
no need set them to zero first, just set them when you use them
I'd put the file parsing code in a function (or class) but that can
wait 'till you've got it working.
you need to get the Canvas, so you can either do:
Canvas = self.Canvas
here, or just call it self.Canvas everywhere.
> for raw_data_line in raw_data:
> line = ''
> if raw_data_line.startswith('$GPGGA'):
> line = raw_data_line.split(',')
> lat = dmmm2dec(float(line[2]),line[3]) #[2] is lat in
> deg+minutes, [3] is {N|S|W|E}
> lng = dmmm2dec(float(line[4]),line[5]) #[4] is long in
> deg+minutes, [5] is {N|S|W|E}
> time =
> line[1][0:2]+':'+line[1][2:4]+':'+line[1][4:6]+' UTC' ##note: change
> to float
>
> #print time+' Y:'+str(lat-origin_lat)+'
> X:'+str(lng-origin_lng)
>
> x = (lng-origin_lng)
> y = (lat-origin_lat)
> p = (x, y)
> Canvas.AddPoint(p,
> Diameter = 4,
> Color = "Red",
> InForeground = 1)
you probably don't want them in the Foreground.
> self.Canvas.ZoomToBB()
> self.Canvas.Draw()
> self.Canvas.ClearAll()
you don't want to ClearAll right after Drawing!!
That should do it.
Take a look at the Main demo, and the DrawMap demo -- it's coarse
resolution for the whole world but if you can find some vector data of
your region of interest, you could use that. Or maybe a raster map
instead (see Demos/Map.py). I'm working on making map support better, too.
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
_______________________________________________
FloatCanvas mailing list
[email protected]
http://mail.mithis.com/cgi-bin/mailman/listinfo/floatcanvas