Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Drawing GPS coordinates on screen.
I want to draw GPS location as a dot on screen. please let me know the correct way of doing this.
How can i convert latitude & longitude into coordinates to draw on screen?
Thanks in Advance.
That would ultimately depend on your map projection. What map projection is suitable, depends on your purposes: a display to indicate a point in a city on a map is different from one that would do the same for the whole world, for instance. Are you looking for a map to display on that screen as well (for reference perhaps)?
Thanks for the reply.
Actually i want to draw a point on blank screen only, not on map. (this is the requirement)
There are @50 location available that i need to draw on screen relatively to each othere.
Again: on what scale? A park? A city? A small country? A continent? The world? And even: near the equator, or near the poles?
it is small park. or you can say play area of @1000 meter.
I need info about how to convert latitude and longitude in coordinate system (x,y) so that I can draw it on my screen.
koahnig last edited by
I understand that, but in order to recommend a "map projection":http://en.wikipedia.org/wiki/Map_projection it is important to understand the scale you're working on.
In your case, the distances are so small, that you can use a quite simple one. Perhaps a simple "equirectangular projection":http://en.wikipedia.org/wiki/Equirectangular_projection will do fine for your purpose.
You can use the formula in the article referenced above to get a set of x, y coordinates. Then, all you need to do is to scale and transpose these coordinates so they can be mapped in a sensible way to your screen.
Thanks for the reply.
My requirement is to draw GPS location which are very near to each other.
I tried to draw it is but becuase of GPS location are very close @10 meter range, two points are getting overlapped.
Do you have any solution for this?
bq. Do you have any solution for this?
Zoom in closer on the area in your view?
Otherwise, what behavior would you like to see if the points overlap?
Munkhtamir last edited by
@MyQT Hello. Did you find any solution for drawing GPS point as overlay on widget ?
Buckwheat last edited by
Since you do not have requirements for projections and mappings, you could use flat-earth approximation which converts decimal degrees to nautical miles. From there you can convert to feet, meters, etc.
Flat-earth approximation is really quite simple. There are 60nm per degree. So
y = latitude * 60;
x = longitude * 60 / cos (latitude);
This is fast and light weight. If you really want to localize and minimize errors, you can also subtract a local reference latitude/longitude for the park or area in question. For more robust map projections, I use GDAL (gdal.org) and PROJ.4 (proj4.org). This allows me to position anywhere in the world with surveyor accuracy. It is not as light weight but it is robust and well supported. GeographicLib also has great API for UTM/UPS and MGRS conversion.
One problem you could have with tight points and scaling is that if you do NOT use line width 0 in your pen, the pen width will scale as you zoom. I typically make my point diameters 1ft or .3048m and this tends to make zooming better.