[mapserver-users] I have a question about the GMapPix2Geo fun ction (listed below).

Puneet Kishor pkishor at GeoAnalytics.com
Wed Oct 23 15:03:08 EDT 2002


well, the function is doing its best to map pixels (cartesian space) to
whatever the actual geographic coords might be... would work best if they
were also cartesian.

lat long is its own beast. Zoom in sufficiently and it behaves (converges
toward) like a cartesian space. Same thing if you are near the equator.
Travel away from the equator, or zoom out, and you are suddenly trying to
map curved "orange peels" onto the flat surface of the monitor.

huh! I mean, hth!

;-)


> -----Original Message-----
> From: Debbie Pagurek [mailto:pagurekd at agr.gc.ca]
> Sent: Wednesday, October 23, 2002 10:15 AM
> To: mapserver-users at lists.gis.umn.edu
> Subject: [mapserver-users] I have a question about the GMapPix2Geo
> function (listed below).
> 
> 
> I have a question about the GMapPix2Geo function (listed below).
> I have a map of the world showing in lat long.  The below 
> function only seems to work if I am zoomed IN really far and 
> it doesn't work if I am at the full extent of the map 
> (minx=-180, maxx=180, miny=-90, maxy=90)
> 
> Can anyone comment on this?  I wanted to build a mouseover 
> function that will show the coordinates of the mouse position 
> in the windows status bar.
> 
> Thanks,
> D. Pagurek
> 
> 
> /*************************************************************
> ***********/
> /*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);
> }
> 
> 
> 



More information about the mapserver-users mailing list