[mapserver-dev] Calculate Bounding Box...

Dan Little danlittle at yahoo.com
Thu Mar 12 13:39:39 EDT 2009


I'm thinking the most accurate way to do it is to use a projection that supports miles that is close to your current extent...  or  use something crappy like Mercator.

This code is off the top of my head, without looking at any docs... so bear with me if there are errors.

$latlon = ms_newProjectionObj("proj=EPSG:4230"); # IIRC
$proj = ms_newProjectionObj("proj=EPSG:3758"); # Popular Web-mapping projection

$centerPoint = ms_newPointObj($x, $y); # in lat long

$centerPoint->project($latlon, $proj);

$minPoint = ms_newPointObj();
$maxPoint = ms_newPointObj();

$mInM = 1609; # mile in meters, as 3758 is in meters
$minPoint->setXY($centerPoint.x - $mInM, $centerPoint.y - $mInM);
$maxPoint->setXY($centerPoint.x + $mInM, $centerPoint.y + $mInM);

$minPoint->project($proj, $latlon);
$maxPoint->project($proj, $latlon);

return implode(',',array($minPoint->x,$minPoint->y,$maxPoint->x,$maxPoint->y));






________________________________
From: Oscar Fdez. <ofarcis at gmail.com>
To: mapserver-dev at lists.osgeo.org
Sent: Wednesday, March 11, 2009 11:53:26 PM
Subject: [mapserver-dev] Calculate Bounding Box...

 
Hi to all,

Any people know how to calculate the bounding box from lon/lat coordinates.

An example:

I have a point in -8.0572,42.4702 (lon/lan). I like a bounding box arround 1
mile of this site. Can use any SRS like EPSG:4230 or another.

Any solution is accepted independent of language. I translate to
my need. I hope develop in php mapscript, but the solution can made in any
language…
 
Thanks for all,
Oscar.


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-dev/attachments/20090312/fc8cbc0e/attachment.html


More information about the mapserver-dev mailing list