### Question:
Viewer2D extends AbstractDynamicViewer { @Override public double getAltitude() { Projection proj = getMapContext().getProjection(Viewer2D.class); if (proj instanceof AbstractGeographicProjection) { double widthStretch = myStretchFactor > 1. ? myStretchFactor : 1.; double metersPerModel = WGS84EarthConstants.CIRCUMFERENCE_MEAN_M / proj.getModelWidth(); double viewWidthMeters = 0.5 * (metersPerModel * proj.getModelWidth() / getScale() / widthStretch); return viewWidthMeters / Math.tan(0.5 * MathUtil.QUARTER_PI); } return 0.; } Viewer2D(AbstractDynamicViewer.Builder builder);  Viewer2D(AbstractDynamicViewer.Builder builder, boolean displayedViewer); @Override float[] getAdjustedModelViewMatrix(Matrix4d adjustment); @Override double getAltitude(); @Override KMLCompatibleCamera getCamera(ViewerPosition position); @Override ViewerPosition2D getCenteredView(Vector3d position); @Override ViewerPosition getCenteredView(Vector3d position, Vector3d centroidHit); @Override double getHeading(); @Override MapContext<DynamicViewer> getMapContext(); double getMaxZoom(); double getMinZoom(); double getModelHeight(); @Override Vector3d getModelIntersection(); @Override synchronized float[] getModelViewMatrix(); double getModelWidth(); @Override double getPitch(); @Override double getPixelWidth(Ellipsoid ellipsoid); @Override ViewerPosition2D getPosition(); @Override float[] getProjectionMatrix(); @Override ViewerPosition2D getRightedView(Vector3d location); @Override ViewerPosition2D getRightedView(ViewerPosition position); @Override ViewerPosition2D getRightedViewAtIntersection(ViewerPosition location); double getScale(); double getStretchFactor(); @Override Vector3d getTerrainIntersection(); @Override Vector3d getTerrainIntersection(Vector2i screenLoc); @Override ViewerPosition2D getViewerPosition(KMLCompatibleCamera camera); @Override double getViewLength(Vector3d ptA, Vector3d ptB); @Override double getViewVolumeWidthAt(Vector3d modelPosition); @Override double getViewVolumeWidthAtIntersection(); @Override ViewerPosition2D getZoomToFitView(RectangularCylinder bounds); @Override ViewerPosition getZoomToFitView(RectangularCylinder bounds, Vector3d centroidHit); @Override boolean isInView(Ellipsoid ellipsoid, double cullCosine); @Override boolean isInView(Vector3d point, double radius); @Override final void reset(Builder builder); @Override void resetView(); @Override void setMapContext(MapContext<DynamicViewer> context); @Override synchronized void setPosition(ViewerPosition viewerPosition); @Override void startAnimationToPreferredPosition(); @Override boolean supportsAdjustedModelView(); static final String POSITION_PREF_KEY; }### Answer:
@Test public void testGetAltitude() { Viewer2D viewer = new Viewer2D(myBuilder, false); viewer.setMapContext(myMapManager); ViewerPosition2D pos = new ViewerPosition2D(Vector3d.ORIGIN, 2.); viewer.reshape(800, 400); viewer.setPosition(pos); double eightMagAltitude = 2.4160380260805476E7; double alt = viewer.getAltitude(); Assert.assertEquals(eightMagAltitude, alt, 0.00001); viewer.reshape(1000, 400); alt = viewer.getAltitude(); Assert.assertEquals(eightMagAltitude, alt, 0.00001); }