reverse of click2map (convert geographic coordinates into pixel value)

Stuart Eve stuarteve at LPARCHAEOLOGY.COM
Thu Jan 26 12:19:50 PST 2006


Hi all,

I'm trying to convert a geographic coordinate into a pixel value (i.e. 
the reverse of the click2map demo script).

I have searched around and found Ace Suares' script:

function map2click ( $map, $bounds ) {
        $bounds_average_x = ( $bounds->maxx + $bounds->minx ) / 2;
        $bounds_average_y = ( $bounds->miny + $bounds->maxy ) / 2;
        $x_pct = ( ( $bounds_average_x - $map->extent->minx ) / ( 
$map->extent->maxx - $map->extent->minx ) );
        $y_pct = ( ( $bounds_average_y - $map->extent->miny ) / ( 
$map->extent->maxy - $map->extent->miny ) );
        $x_map = intval( $map->width * $x_pct );
        $y_map = intval( $map->height * (1 - $y_pct) );
        return array( $x_map, $y_map );
}

But this doesn't seem to be working for me - it just returns a very big 
negative number.

I am using a point theme - with the data stored in LatLongs.

Has anyone seen a script to do this?

Thanks in advance,

Stuart

-- 
Stuart Eve
L - P : Archaeology
stuarteve at lparchaeology.com 



More information about the MapServer-users mailing list