[mapserver-users] getting coordinates from pixel

CATHIGNOL, Frederic Frederic.CATHIGNOL at astrium-space.com
Mon Nov 26 23:21:42 PST 2001


Hello;

If I understand your problem, there is a function in the example gmap75 :

/************************************************************************/
/*function GMapPix2Geo($nPixPos, $dfPixMin, $dfPixMax, $dfGeoMin,
dfGeoMax,*/
/*                           $nInversePix)                              */
/*                                                                      */
/*      Utility function to convert a pixel position to geocoded        */
/*      position.                                                       */
/*                                                                      */
/*       The parameter $nInversePix could be set to 1 for Y pixel       */
/*      coordinates where the UL > LR. Else set to 0.                   */
/************************************************************************/
function GMapPix2Geo($nPixPos, $dfPixMin, $dfPixMax, $dfGeoMin, $dfGeoMax, 
                     $nInversePix) 
{
   // $nPixPos : pixel position (X or Y)
   // $dfPixMin, $dfPixMax : Pixel minimum and maximum (X or Y) of your map
on the screen (should be 0 to xxx)
  //  $dfGeoMin, $dfGeoMax : Geographic coordinate min max (X or Y) of your
map on the screen 

    $dfWidthGeo = $dfGeoMax - $dfGeoMin;
    $dfWidthPix = $dfPixMax - $dfPixMin;
   
    
    $dfPixToGeo = $dfWidthGeo / $dfWidthPix;

    if (!$nInversePix)
        $dfDeltaPix = $nPixPos - $dfPixMin;
    else
        $dfDeltaPix = $dfPixMax - $nPixPos;

    $dfDeltaGeo = $dfDeltaPix * $dfPixToGeo;


    $dfPosGeo = $dfGeoMin + $dfDeltaGeo;

    return ($dfPosGeo);
}

Regards,

F.CATHIGNOL

-------------- next part --------------
An embedded message was scrubbed...
From: Nicolau Werneck <nwerneck at yahoo.com.br>
Subject: [mapserver-users] getting coordinates from pixel
Date: Mon, 26 Nov 2001 22:25:10 +0100
Size: 887
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20011127/60c4295f/attachment.eml>


More information about the MapServer-users mailing list