我正在尝试使用worldwind java设置图层,我想在地图上的特定地理位置渲染图标.我有那个工作,但我希望能够缩放到所有图标的位置.有一个简单的方法吗?我不确定从哪里开始..是否有现有的放大一组点的方法?
首先,您需要计算包含所有点的扇区.例如
Sector boundingSector = Sector.boundingSector(points);
//public static Sector boundingSector(Iterable<? extends LatLon> itrbl)
Run Code Online (Sandbox Code Playgroud)
现在这里是一些从ScankortDenmark示例中获取的代码来计算您需要在屏幕上显示整个扇区的缩放:
// 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));
}
Run Code Online (Sandbox Code Playgroud)