April 11, 2012

pascal95abc pascal95abc
Lab Rat
121 posts

[Solved] Get geographic data from point on map

 

Hello,

I am creating an application in which the user should create a polygon on a map dynamically.

Therefore, I have a Map and a MapPolygon as the Map’s child. With “addCoordinate” I can add coordinates. This is my idea.
The user should click anywhere on the map and this point should be added.
I can get the position with mouse.x and mouse.y, this is my first step; but howto *convert them into latitude and longitude *which are the required paramters for addCoordinate ?

Someone understood my problem and can help me ?
Thank you!

 Signature 

Qt 4.7.3
Symbian OS v9.4 / Symbian^1, S60 5th Edition
on N97

7 replies

April 11, 2012

koahnig koahnig
Mad Scientist
2114 posts

there has been a similar discussion in this thread [qt-project.org] today.

The same question for the map projection comes up here too.
Size of your area?
If you want to draw on a map, you definitely need to know the mapping projection used.

April 11, 2012

pascal95abc pascal95abc
Lab Rat
121 posts

The size of my area is very small, i.e. not more than 100metres X 100metres. So, the earth’s curvature can be neglected.
I am working with coordinates in degree as a float, so I just have to know the factor to be multiplied with to get, say a pixel, stretched to one degree.
I think in N/S direction and W/O the factor shall be the same.

And sorry, I didn’t saw the other thread.

 Signature 

Qt 4.7.3
Symbian OS v9.4 / Symbian^1, S60 5th Edition
on N97

April 11, 2012

mlong mlong
Mad Scientist
1517 posts

You are probably looking for Map::toCoordinate() [doc.qt.nokia.com]

[Edit: I may have misread the question…]

 Signature 

Senior Software Engineer
AccuWeather Enterprise Solutions
/* My views and opinions do not necessarily reflect those of my employer.  Void where prohibited. */

April 11, 2012

koahnig koahnig
Mad Scientist
2114 posts

The simplest conversion from degree of latitude to meters is quite simple (as long as you do not get to the details ;-) )
The great circle of Earth is the basis for the definition of the meter. A meter is 1 / 40 000 000 of the length of this circle. Or 1 degree is 111.111 km in latitude. The scaling for longitude is only the same at the equator. The scaling there is about 111.111*cos(latitude) km per degree.

I think you mean double (8 byte) not float (4 byte) to store lat and lon.

April 11, 2012

pascal95abc pascal95abc
Lab Rat
121 posts

Hello again.
@koahnig: This is a very simple and good idea!
I first had to think of the use of cosinus here what I had to clear up for me with a picture I drew.
geographic

Because radius and the length of the circle is proportional for all latitudes, this leads to the formula which is really good.

And of course “Map::toCoordinate()” which I tested and worked, is the easiest way without thinking of maths.

 Signature 

Qt 4.7.3
Symbian OS v9.4 / Symbian^1, S60 5th Edition
on N97

April 11, 2012

koahnig koahnig
Mad Scientist
2114 posts

Thinking of what you are doing help sometimes a bit. Using already available code as well ;-)

April 11, 2012

pascal95abc pascal95abc
Lab Rat
121 posts

Yes, thank you all, this really helped.

Maybe, you want to write in the thread linked above (this one [qt-project.org]).

 Signature 

Qt 4.7.3
Symbian OS v9.4 / Symbian^1, S60 5th Edition
on N97

 
  ‹‹ QtQuick Desktop components      "default property alias content" under QML Designer ››

You must log in to post a reply. Not a member yet? Register here!