Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting the zoom level of worldwind map

Tags:

java

worldwind

I am trying to setup a layer using worldwind java and i want to render icons on the map at their specific geo locations. I have that working but i want to be able to zoom to where all the icons are. Is there an easy way to do that? Im not really sure where to start.. Are there existing methods for zooming in on a group of points?

like image 780
MBU Avatar asked May 11 '11 19:05

MBU


1 Answers

First you need to calculate the Sector containing all of your points. e.g.

Sector boundingSector = Sector.boundingSector(points);
//public static Sector boundingSector(Iterable<? extends LatLon> itrbl)

Now here's some code taken from ScankortDenmark example to calculate the zoom you need to fit the whole sector on screen:

// From ScankortDenmark example
public static double computeZoomForExtent(Sector sector)
{
    Angle delta = sector.getDeltaLat();
    if (sector.getDeltaLon().compareTo(delta) > 0)
        delta = sector.getDeltaLon();
    double arcLength = delta.radians * Earth.WGS84_EQUATORIAL_RADIUS;
    double fieldOfView = Configuration.getDoubleValue(AVKey.FOV, 45.0);
    return arcLength / (2 * Math.tan(fieldOfView / 2.0));
}
like image 182
I82Much Avatar answered Sep 19 '22 07:09

I82Much