[Qt-interest] Using Qpainter/Qgraphics for a gps car-like
Andre Somers
andre at familiesomers.nl
Mon Mar 15 16:48:18 CET 2010
Gustavo B. Schenkel wrote:
> The problem is the points, they have too much numbers after the
> dot, in the screen they show all in the same place.
>
> Then i don't know if i need do some calculation to transform this
> numbers to others.
>
> i am sending my painter code. I am using the setWindow function
> but i still don't know much about it.
>
> void RenderArea::paintEvent(QPaintEvent * /* event */)
> {
>
> static const QPointF square[4] = {
> QPointF(-29.683436, -53.800570),
> QPointF(-29.683795, -53.799620),
> QPointF(-29.684242, -53.800749),
> QPointF(-29.684478, -53.799623)
> };
>
>
> QPainter painter(this);
> painter.setRenderHint(QPainter::Antialiasing, true);
> painter.setWindow(-33,-57, 10, 10);
> painter.save();
> painter.drawPolygon(square, 4);
> painter.restore();
> }
>
>
So... are you trying to plot GPS coordinates directly, and expect to see
something? Realize that one pixel on your screen will end up
representing an entire degree. In north-south direction, that is 100
nauticle miles, or about 180 km. In the east/west direction, it depends
on the latitude. You can see that that's not going to work. You will
need some kind of map projection. There are many to choose from,
depending on what features of the map you find most important. None of
these are available in Qt by default, you'll have to implement them
yourself. They usually involve a bit of math :-) Perhaps this link will
get you started: http://en.wikipedia.org/wiki/Map_projection
André
More information about the Qt-interest-old
mailing list