[Mapserver-users] Converting an image point to a geog. space point

Charlton Purvis cpurvis@asg.sc.edu
Tue, 13 May 2003 11:02:50 -0400


Give this a shot.

<?php
// from
http://mapserver.gis.umn.edu/data2/wilma/mapserver-users/0204/msg00177.h
tml
//
function pixelToGeo($map,$x,$y) {
        # Convert x,y pixel values to georeferenced coords.  Returns a
        # pointObj.

        $minx = $map->extent->minx;
        $miny = $map->extent->miny;
        $maxx = $map->extent->maxx;
        $maxy = $map->extent->maxy;

        $dx = $maxx - $minx;
        $dy = $maxy - $miny;

        $width = $map->width;
        $height = $map->height;

        $dxpp = (double)$dx/$width;
        $dypp = (double)$dy/$height;

        $geox = $minx + $dxpp*$x;
        $geoy = $maxy - $dypp*$y;

        $pointObj = ms_newPointObj();
        $pointObj->setXY($geox,$geoy);

        return $pointObj;
}
?>

-----Original Message-----
From: Adam Zornes [mailto:zornes@athenic.com] 
Sent: Tuesday, May 13, 2003 10:54 AM
To: mapserver-users@lists.gis.umn.edu
Subject: [Mapserver-users] Converting an image point to a geog. space
point

All,

	I am trying to query points in php/mapscript.  I get a point
from the previous form just fine, but I can't seem to get it to convert
to a proper geog. space point.  Does anyone have an example of how to do
this, or just an explanation of how to find the actual map size and the
current map size so that I can work up a formula of my own?

Cheers,

Adam Zornes

_______________________________________________
Mapserver-users mailing list
Mapserver-users@lists.gis.umn.edu
http://lists.gis.umn.edu/mailman/listinfo/mapserver-users