<div>Hi, I have *.jpg of a map and want to get lat\lon of mouse position on *.jpg.<br>I know the *.jpg file size (ex. 1024x768) and *.jpg lat\lon top_left corner(ex. N2030,320,E01015,400)<br>and bottom_right corner(ex.N1030,220,E01814,300 )<br>
I do this as below code.<br>How to do this with proj4 lib or another more efficient way.<br>(if ı use another *.jpg of map projections different from mercator below code wil be fail.(?) )</div>
<p><br>QString Map::Y2Lat(int Y_size_of_image)//Y_size of jpg ( 768 )<br>{</p>
<div>//distVincenty(lat1,long1,lat2,long2) returns distance in NM. <br>//here give long same because , want to know *.jpg y size in real.<br>double YRealDist = distVincenty("2030,320","N","01015,400","E", "1030,220","N","01015,400","E");</div>
<div><br>double YPerPixel=YRealDist/Y_size_of_image;// real distance per pixel of image</div>
<div><br>double convfaktor=YPerPixel*currentMousePosY;//real distance from top to current mouse pos.</div>
<div><br>//gives destination lat from top_left convfaktor miles with course 180<br>QString newLatLon = destinationVincenty("2030,320","N","01015,400","E",180.,convfaktor);<br>QString Latitude =toDMS(newLatLon.toDouble(),"NS");</div>
<div><br>qDebug()<<"Current mouse position Lat = "<< Latitude ;<br>return Latitude;</div>
<div>} </div>
<div><br>QString Map::X2Long(int X_size_of_image)//X_size of jpg ( 1024 )<br>{</div>
<div>double top_left_lon = dm2dd("01015,400","E");//long in degree</div>
<div><br>double bottom_right_lon = dm2dd("01814,300","E");//long in degree</div>
<div><br>double XRealDist=(bottom_right_lon-top_left_lon)*60.;//using mercator map 1 degree 60 miles</div>
<div><br>double XPerPixel=XRealDist/X_size_of_image;</div>
<div><br>double convfaktor=XPerPixel*currentPosX;//top left to mouse pos distance in X</div>
<div><br>double newLong=top_left_lon + convfaktor/60.;</div>
<div><br>QString Long=toDMS(newLong,"EW");</div>
<div><br>qDebug()<<"Current mouse position Long = "<< Long ;<br>return Long;</div>
<p>}</p>