POINT TO PIXEL

G Casey gabrial.casey at GMAIL.COM
Wed Jun 8 13:23:30 PDT 2005


Does anyone have a good way to convert point in meters to pixel I am
trying to compute this for the ability to zoom to a point without a
click.

the click2map (php mapscript) function (below) works  however i need
to solve for click_x and click_y for a large extent with a known x_map
and y_map. I have tried and seem to be getting very strange numbers.

Why can I not just solve for click_x with a known x_map ????

My extent is in meters and is: 

 -2889574.369897 -1870163.5788935 2951185.294103 2023676.1971065  
my image size is 600X400

yet I never get the correct numbers. 


function click2map ($click_x, $click_y) {
    global $map;	
	
    $e = &$map->extent; 
    $x_pct = ($click_x / $map->width);
    $y_pct = 1 - ($click_y / $map->height);
    $x_map = $e->minx + ( ($e->maxx - $e->minx) * $x_pct);
    $y_map = $e->miny + ( ($e->maxy - $e->miny) * $y_pct);
}

I hope this is obvious.



More information about the MapServer-users mailing list