FW: [Mapserver-users] Set map scale rather than extent

Ryan, Adam ARyan at co.linn.or.us
Wed Jul 7 12:49:25 EDT 2004


Doug,

Here's a php routine I call to set the extent of the map object prior to
doing much else.  It relies on either four coordinates or two coordinates
and a scale.  It could easily be tweaked for miles.  I havn't looked at this
in a while.  It looks like it is dependent on a resolution of 96 when using
the unit conversion factor; probably needs work.

//	Map_calcExtent
//	$map = map object
function Map_calcExtent(&$map){
	if
(isset($_POST["minx"])&&isset($_POST["miny"])&&isset($_POST["maxx"])&&isset(
$_POST["maxy"])){
	
$map->setExtent($_POST["minx"],$_POST["miny"],$_POST["maxx"],$_POST["maxy"])
;
	}else if (isset($_POST["minx"])&&isset($_POST["miny"])){
		if ($map->units==MS_FEET){
			$uc = 0.083333333333333333333333333333333;
		}
		$dx =
((($map->width)/($map->resolution))*($_POST["scale"]*$uc))/2;
		$dy =
((($map->height)/($map->resolution))*($_POST["scale"]*$uc))/2;
	
$map->setExtent($_POST["minx"]-$dx,$_POST["miny"]-$dy,$_POST["minx"]+$dx,$_P
OST["miny"]+$dy);
	}
}

Best regards,

Adam Ryan
GIS Analyst
Linn County GIS Department
County Courthouse / Room 25
300 SW Fourth Ave.
Albany, OR 97321
541.812.8760
aryan at co.linn.or.us
 


-----Original Message-----
From: Doug [mailto:ummmmm at myrealbox.com] 
Sent: Wednesday, July 07, 2004 9:00 AM
To: Mapserver-users
Subject: Re: [Mapserver-users] Set map scale rather than extent


Anyone?

Doug wrote:

>  From PHP-Mapscript, how would you specify a Map's scale in miles, 
> rather than extent in coordinates?  We want to specify, ideally, a 
> center point, then something like "show me a mile on each side this 
> point".  In some of the archives I see references to specifying a 
> "buffer" region, but I can't find that capability, nor the ability to 
> translated geo coordinates to distance measurements.
> 
> Thanks,
> Doug
_______________________________________________
Mapserver-users mailing list
Mapserver-users at lists.gis.umn.edu
http://lists.gis.umn.edu/mailman/listinfo/mapserver-users



More information about the mapserver-users mailing list