Hi there,
i wrote the following code to calculate scale from a given boundingbox (represented by UpperLeft and LowerRight).
Unfortunately the result is not really good. Can someone find the error?
public float getScale(LatLonPoint ul, LatLonPoint lr, Projection projection)
{
float pixPerDegree = ((Proj) projection).getPlanetPixelCircumference() / 360;
// windowsize
float height = projection.getHeight();
float width = projection.getWidth();
// Look at latitude
float lat1 = ul.getLatitude();
float lat2 = lr.getLatitude();
float dlat = Math.abs(lat2 - lat1);
// Look at longitude
float dlon;
float lon1 = ul.getLongitude();
float lon2 = lr.getLongitude();
// allow for crossing dateline
if (lon1 > lon2)
{
dlon = (180 - lon1) + (180 + lon2);
}
else
{
dlon = lon2 - lon1;
}
dlon *= Math.abs(Math.cos(((lat1 + lat2) / 2)));
float quotientLat = height / dlat;
float quotientLon = width / dlon;
// The new scale...
return pixPerDegree / Math.min(quotientLat, quotientLon);
}
Yours Ruediger
--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Mon Aug 09 2004 - 06:37:54 EDT