getting map coordinates from mouse click

Sandeep Kumar Jakkaraju sandeepkumar.jakkaraju at GMAIL.COM
Sat Oct 7 01:22:14 EDT 2006


Hi

I am doing this ....

I have lat/lon of Top Left Corner of the Map and  Bottom Right Corner of The
Map
iam converting them to projected X,Y using this projection defintion

World Mercator <54004> +proj=merc +latts=0 +lon0=0 +k=1.000000 +x0=0
+y0=0 +ellps=WGS84 +datum=WGS84 +units=m no_defs <>

For example:

       tl_lat = 42.8483;
       tl_lon = -74.2935;
       br_lat = 42.3813;
       br_lon = -73.6509;


using pj_transform of proj4.. iam converting them to X,Y.


top left xy

-8270314.5893 , 5259843.0071

btm right xy

-8198780.6845 , 5189458.4882

I calculate the Centre cX,cY using the top left X,Y and Btm right X,Y...

The Size of the Image I have generated from the Map is (1031,801)...

width = absolute value of (btm right X - top left X)

height = absolute value of (btm right Y - top left Y)

Now I am trying to get the pixel x,y from the projected X,Y using this
formula

       px = 515.5 +  (1031/width)*(X-cX);
       py = 400.5  -  (801/height)*(Y-cY);

This gives correct pixels if i give top left or bottom right or the centre
X,Y...

But for some point inside the Image ...

the calcualted pixel X is some 2/3 pixels away from actual pixel X

the calcualted pixel Y is some 8/10 pixels away from actual pixel Y

where am I going wrong ... is the projection iam using correct for such
calculations ..???



Thanks in advance.

sandeep






On 10/6/06, Alessandro Pasotti <ale.pas at tiscali.it> wrote:
>
> Il 16:04, venerdì 6 ottobre 2006, Sandeep Kumar Jakkaraju ha scritto:
> > Hi
> >
> > a similar problem ...
> >
> > I want to know the img_x and img_y  for a corresponding MAPLON,
> MAPLAT....
>
> I believe the only way is to do some math on the server or on the client
> (with
> javascript code).
>
> You already know the map extent and jpeg size, don't you?
>
> You can find a lot of examples on the net, just look at the js code of one
> of
> the many webgis clients (p.mapper, openlayers or ka-map to cite a few).
>
> Regards.
> --
> Alessandro Pasotti
> itOpen - "Open Solutions for the Net Age"
> w3:  www.itopen.it
> Linux User# 167502
>



-- 
Sandeep Kumar Jakkaraju
WeBlog:
http://jakkarajus.blogspot.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20061007/465ba2d5/attachment.html


More information about the mapserver-users mailing list