PDA

View Full Version : QPainter; Setting correct coordinatesystem



roband915
4th February 2011, 11:11
Hello!
I have two questions and I hope someone here can help me out a bit.
Question nr 1:
I'm using ShapeLib to import a shape-file into a QGLWidget. At the moment the map is really small and positioned at the top left corner of the widget. The shapes coordinates are in wgs84 and I want my widget to have the same coordinates as the shapefile. Is this possible? (I have spent two days trying to understand QPainters window, viewport, matrix etc but I'm seriously starting to doubt myself because I just don't get it.)

Question nr 2:
If the above is possible and I would like to draw things on the map(Basic primitives really). How would I solve this? Some kind of overlay?

/Robert

certqt
5th February 2011, 22:32
I expect that you have already read the documentation about coordinate systems, but I also found this video quite helpful.

http://qt.nokia.com/developer/learning/online/training/specialized-elearning/graphics-view/graphics-view-transformations-and-coordinate-systems/

I am interested in how you are using ShapeLib in Qt - do you have a simple example project?

roband915
8th February 2011, 11:34
Yes you are so right. I have read everything there is to read about this topic. Obviously not enough though... Very interesting video. I will look into it as soon as everything else is working. (I just posted a new thread about a problem I´m afraid).
And I will post the code so you can see how I´m using shapelib when it´s working again :) Thank you for the reply sir it was very helpful :)

swapan_gh
26th October 2013, 10:44
Hi,

I am also trying to render shapefile but fail using Shapelib and qgraphicsview. I can render shapefile using QtOpengl but this is not suitable for my ARM device so want to do that using qgraphicsview. Can you please share me the source code.

Regards,

Swapan ghosh

folibis
27th October 2013, 13:07
wgs84 is coordinates on sphere, you need to transform all the points to x,y coordinates
I have my own library to read and draw SHAPE files.
I use QWidget to draw primitives and it very fast for me. For example, about 500 000 points(points, polylines, polygons) and it takes about 0.5 sec to draw. QgraphicsView was too slow.
for coordination transformation i use proj.4.

swapan_gh
28th October 2013, 10:05
Is it possible to share your library ang usage to display shapefile.

Swapan

swapan_gh
28th November 2013, 07:36
Hi folibis,
till I am failed to display shape file. Can you please help me by supplying source code.

Swapan

swapan_gh
5th December 2013, 07:02
yes I could..........