private void adjustDateLineCrossingPoints() { ArrayList<LatLon> corners = new ArrayList<LatLon>(Arrays.asList(sw, se, nw, ne)); if (!LatLon.locationsCrossDateLine(corners)) return; double lonSign = 0; for (LatLon corner : corners) { if (Math.abs(corner.getLongitude().degrees) != 180) lonSign = Math.signum(corner.getLongitude().degrees); } if (lonSign == 0) return; if (Math.abs(sw.getLongitude().degrees) == 180 && Math.signum(sw.getLongitude().degrees) != lonSign) sw = new Position(sw.getLatitude(), sw.getLongitude().multiply(-1), sw.getElevation()); if (Math.abs(se.getLongitude().degrees) == 180 && Math.signum(se.getLongitude().degrees) != lonSign) se = new Position(se.getLatitude(), se.getLongitude().multiply(-1), se.getElevation()); if (Math.abs(nw.getLongitude().degrees) == 180 && Math.signum(nw.getLongitude().degrees) != lonSign) nw = new Position(nw.getLatitude(), nw.getLongitude().multiply(-1), nw.getElevation()); if (Math.abs(ne.getLongitude().degrees) == 180 && Math.signum(ne.getLongitude().degrees) != lonSign) ne = new Position(ne.getLatitude(), ne.getLongitude().multiply(-1), ne.getElevation()); }
protected Vec4 getSurfacePoint(LatLon latlon, double elevation) { Vec4 point = null; SceneController sc = this.getApp().getWwd().getSceneController(); Globe globe = this.getApp().getWwd().getModel().getGlobe(); if (sc.getTerrain() != null) { point = sc.getTerrain() .getSurfacePoint( latlon.getLatitude(), latlon.getLongitude(), elevation * sc.getVerticalExaggeration()); } if (point == null) { double e = globe.getElevation(latlon.getLatitude(), latlon.getLongitude()); point = globe.computePointFromPosition( latlon.getLatitude(), latlon.getLongitude(), (e + elevation) * sc.getVerticalExaggeration()); } return point; }
protected Vec4 getPoint(LatLon latlon, double elevation) { SceneController sc = this.getApp().getWwd().getSceneController(); Globe globe = this.getApp().getWwd().getModel().getGlobe(); double e = globe.getElevation(latlon.getLatitude(), latlon.getLongitude()); return globe.computePointFromPosition( latlon.getLatitude(), latlon.getLongitude(), (e + elevation) * sc.getVerticalExaggeration()); }
protected void initializePolygon(WorldWindow wwd, Polygon polygon, boolean fitShapeToViewport) { // Creates a rectangle in the center of the viewport. Attempts to guess at a reasonable size // and height. Position position = ShapeUtils.getNewShapePosition(wwd); Angle heading = ShapeUtils.getNewShapeHeading(wwd, true); double sizeInMeters = fitShapeToViewport ? ShapeUtils.getViewportScaleFactor(wwd) : DEFAULT_SHAPE_SIZE_METERS; java.util.List<LatLon> locations = ShapeUtils.createSquareInViewport(wwd, position, heading, sizeInMeters); double maxElevation = -Double.MAX_VALUE; Globe globe = wwd.getModel().getGlobe(); for (LatLon ll : locations) { double e = globe.getElevation(ll.getLatitude(), ll.getLongitude()); if (e > maxElevation) maxElevation = e; } polygon.setAltitudes(0.0, maxElevation + sizeInMeters); polygon.setTerrainConforming(true, false); polygon.setLocations(locations); }