How to get boundaries of WorldWind's globe in geographic coordinates

98 views Asked by At

I have implemented WorldWind in my application. I need to get the visible portion of the globe so that I can find the Northeast and Southwest latitude and longitude coordinates of this visible part.

How do I get the boundaries of the visible part of the globe?

1

There are 1 answers

0
naugler On

The question can be complicated. For example, if the horizon is visible, then your view is not bounded by four geodetic positions.

If you are in a method that provides a DrawContext, there is a convenience method for returning the visible sector:

Sector visibleSector = dc.getVisibleSector();
LatLon[] corners = visibleSector.getCorners();

If you don't have access to the DrawContext, but you can guarantee that all four corners of your view will intersect the globe, then you can use the following snippet from the worldwind forums:

View view = WorldwindCore.getInstance().getWw().getView();
Rectangle viewport = view.getViewPort();
LatLon corners[] = new LatLon[4];
corners[0] = view.computePositionFromScreenPoint(viewport.getMinX(), viewport.getMinY());
corners[1] = view.computePositionFromScreenPoint(viewport.getMinX(), viewport.getMaxY());
corners[2] = view.computePositionFromScreenPoint(viewport.getMaxX(), viewport.getMaxY());
corners[3] = view.computePositionFromScreenPoint(viewport.getMaxX(), viewport.getMinY());