[mapserver-users] confusion about postgis bounding box -> val id map extent

Puneet Kishor pkishor at GeoAnalytics.com
Fri Aug 23 12:23:24 PDT 2002


> 
> - In php_mapscript.c  there are functions for dealing with the 
> map extent based on a box inside the visible image, or a point + 
> scale, etc.  Does anyone have example Perl code, for instance, of 
> the map->zoomRectange() function in php_mapscript.c? I have seen 
> the &set_extent() method from mapquakes.pl and seen the examples 
> Lowell posted in Perl, but those are zoom & pan, not fitting an 
> extent to another rect. If there isn't sample perl code


Is this what you might want...

# calculate cellsize in x and y directions. 
# cellsize is the geographic size of 
# each pixel on the screen
$cx = ($g_maxx - $g_minx) / ($mapObj->{width}); 
$cy = ($g_maxy - $g_miny) / ($mapObj->{height});

# (p_minx, p_miny) (p_maxx, p_maxy) are your direction 
# corrected screen lower left and upper right box coords
$x1 = $g_minx + ($cx * $p_minx);
$y1 = $g_miny + ($cy * $p_miny);
$x2 = $g_minx + ($cx * $p_maxx);
$y2 = $g_miny + ($cy * $p_maxy);
    
$g_minx = $mapObj->{extent}->{minx} = $x1;
$g_miny = $mapObj->{extent}->{miny} = $y1;
$g_maxx = $mapObj->{extent}->{maxx} = $x2;
$g_maxy = $mapObj->{extent}->{maxy} = $y2;



More information about the MapServer-users mailing list