[Proj] get lat\lon from mouse position on image

Doğan -- doganay44 at gmail.com
Thu Apr 3 09:14:03 PDT 2008


thanks , i will get code from QLandkarte :) i will learn a lot from your
prog.

2008/4/2, Oliver Eichler <oliver.eichler at dspsolutions.de>:
>
> Hi Doğan
>
> I do the same in QLandkarte GT but I convert the image to a referenced
> GeoTiff first. By that I can simply read all necessary information from the
> file instead of calculating it over and over again. That will make the
> render function more generic. I use GDAL to do so. gdalwarp will skew your
> image to any projection you want. Most likely you want the image's original
> projection to avoid heavy distortions. As QLandkarte GT is open source you
> are welcome to extract any information you need from it's source code. The
> classes CCreateMapGeoTiff and CMapQMAP will be of interest for you.
>
> HTH
>
> Oliver
>
> > Hi, I have *.jpg of a map and want to get lat\lon of mouse position on
> > *.jpg.
> > I know the *.jpg file size (ex. 1024x768) and *.jpg lat\lon top_left
> > corner(ex. N2030,320,E01015,400)
> > and bottom_right corner(ex.N1030,220,E01814,300 )
> > I do this as below code.
> > How to do this with proj4 lib or another more efficient way.
> > (if ı use another *.jpg of map projections different from mercator below
> > code wil be fail.(?)  )
> >
> >
> > QString Map::Y2Lat(int Y_size_of_image)//Y_size of jpg ( 768 )
> > {
> >
> > //distVincenty(lat1,long1,lat2,long2) returns distance in NM. //here
> > give long same because , want to know *.jpg y size in real.
> > double YRealDist = distVincenty("2030,320","N","01015,400","E",
> > "1030,220","N","01015,400","E");
> >
> > double YPerPixel=YRealDist/Y_size_of_image;// real distance per pixel of
> > image
> >
> > double convfaktor=YPerPixel*currentMousePosY;//real distance from top to
> > current mouse pos.
> >
> > //gives destination lat  from top_left  convfaktor miles with course 180
> > QString newLatLon =
> > destinationVincenty("2030,320","N","01015,400","E",180.,convfaktor);
> > QString Latitude =toDMS(newLatLon.toDouble(),"NS");
> >
> > qDebug()<<"Current mouse position Lat = "<< Latitude ;
> > return Latitude;
> > }
> >
> > QString Map::X2Long(int X_size_of_image)//X_size of jpg ( 1024 )
> > {
> > double top_left_lon = dm2dd("01015,400","E");//long in degree
> >
> > double bottom_right_lon = dm2dd("01814,300","E");//long in degree
> >
> > double XRealDist=(bottom_right_lon-top_left_lon)*60.;//using mercator
> > map 1 degree 60 miles
> >
> > double XPerPixel=XRealDist/X_size_of_image;
> >
> > double convfaktor=XPerPixel*currentPosX;//top left to mouse pos distance
> > in X
> >
> > double newLong=top_left_lon + convfaktor/60.;
> >
> > QString Long=toDMS(newLong,"EW");
> >
> > qDebug()<<"Current mouse position Long = "<< Long ;
> > return Long;
> >
> > }
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Proj mailing list
> > Proj at lists.maptools.org
> > http://lists.maptools.org/mailman/listinfo/proj
> >
>
>
> --
> ------------------------------------------------------------------------
> Ingenieure Kellermann, Voigt, Hoepfl, Eichler und Weidner, Partnerschaft
>
> Email: oliver.eichler at dspsolutions.de         http://www.dspsolutions.de
> Phone: +49(0) 941 / 830 551                   Embedded Signal Processing
> Fax:   +49(0) 941 / 830 5579                  DIN EN ISO 9001:2000
>
> Sitz der Partnerschaft ist Regensburg         Schwandorfer Str. 3a
> Registergericht Regensburg: PR14              93059 Regensburg, Germany
> ------------------------------------------------------------------------
>
>
> _______________________________________________
> Proj mailing list
> Proj at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/proj
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/proj/attachments/20080403/39fb22bc/attachment.html>


More information about the Proj mailing list