Java Code Examples for gov.nasa.worldwind.geom.Angle#fromDegrees()

The following examples show how to use gov.nasa.worldwind.geom.Angle#fromDegrees() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ViewControlsSelectListener.java    From hortonmachine with GNU General Public License v3.0 6 votes vote down vote up
protected Angle computePanAmount(Globe globe, OrbitView view, ScreenAnnotation control, double panStep)
{
    // Compute last pick point distance relative to pan control center
    double size = control.getAttributes().getSize().width * control.getAttributes().getScale();
    Vec4 center = new Vec4(control.getScreenPoint().x, control.getScreenPoint().y + size / 2, 0);
    double px = lastPickPoint.x - center.x;
    double py = view.getViewport().getHeight() - lastPickPoint.y - center.y;
    double pickDistance = Math.sqrt(px * px + py * py);
    double pickDistanceFactor = Math.min(pickDistance / 10, 5);

    // Compute globe angular distance depending on eye altitude
    Position eyePos = view.getEyePosition();
    double radius = globe.getRadiusAt(eyePos);
    double minValue = 0.5 * (180.0 / (Math.PI * radius)); // Minimum change ~0.5 meters
    double maxValue = 1.0; // Maximum change ~1 degree

    // Compute an interpolated value between minValue and maxValue, using (eye altitude)/(globe radius) as
    // the interpolant. Interpolation is performed on an exponential curve, to keep the value from
    // increasing too quickly as eye altitude increases.
    double a = eyePos.getElevation() / radius;
    a = (a < 0 ? 0 : (a > 1 ? 1 : a));
    double expBase = 2.0; // Exponential curve parameter.
    double value = minValue + (maxValue - minValue) * ((Math.pow(expBase, a) - 1.0) / (expBase - 1.0));

    return Angle.fromDegrees(value * pickDistanceFactor * panStep);
}
 
Example 2
Source File: WWJPanel.java    From openvisualtraceroute with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected void focusPoint(final GeoPoint point, final boolean isRunning, final boolean animation) {
	final long elevation = 5000 * 1000;
	if (_controller == null || _controller.getWWd() == null) {
		return;
	}
	// center the map on the given point
	final LabeledPath label = point == null ? null : _pointToLabel.get(point);
	if (label != null) {
		highlightAnnotation(label, point);
		final View view = _controller.getWWd().getView();
		final OrbitViewInputHandler ovih = (OrbitViewInputHandler) view.getViewInputHandler();
		if (animation && Env.INSTANCE.getAnimationSpeed() > 0) {
			final Position pos = new Position(label.getLocations().iterator().next(), 10);
			ovih.addPanToAnimator(pos, view.getHeading(), view.getPitch(), elevation, Env.INSTANCE.getAnimationSpeed(), true);
			//				if (_mode == Mode.TRACE_ROUTE && isRunning) {
			//					// if tracing, move at the speed of the timeout
			//					final Position pos = new Position(label.getLocations().iterator().next(), 10);
			//					ovih.addPanToAnimator(pos, view.getHeading(), view.getPitch(), elevation,
			//							Env.INSTANCE.getAnimationSpeed(), true);
			//				} else if (_mode == Mode.TRACE_ROUTE || !isRunning) {
			//					_controller.getWWd().getView()
			//							.goTo(new Position(label.getLocations().iterator().next(), 10), elevation);
			//				}
		} else {
			final Position p = new Position(Angle.fromDegrees(point.getLat()), Angle.fromDegrees(point.getLon()), 2000);
			((OrbitView) view).setCenterPosition(p);
		}
	}
}
 
Example 3
Source File: CurrentGpsPointLayer.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
public void updatePosition( double lat, double lon ) {
    if (gpsMarker == null) {
        gpsMarker = new BasicMarker(Position.fromDegrees(lat, lon, 0), basicMarkerAttributes);
        addMarker(gpsMarker);
    } else {
        if (doHeading) {
            double azimuth = GeometryUtilities.azimuth(new Coordinate(previousLon, previousLat), new Coordinate(lon, lat));
            Angle heading = Angle.fromDegrees(azimuth);
            gpsMarker.setHeading(heading);
        }
        gpsMarker.setPosition(Position.fromDegrees(lat, lon, 10));
    }
    previousLat = lat;
    previousLon = lon;
}
 
Example 4
Source File: ViewControlsSelectListener.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
protected Angle computeLookPitch(OrbitView view, ScreenAnnotation control, double pitchStep)
{
    // Compute last pick point 'pitch' relative to look control center on y
    double size = control.getAttributes().getSize().width * control.getAttributes().getScale();
    Vec4 center = new Vec4(control.getScreenPoint().x, control.getScreenPoint().y + size / 2, 0);
    double py = view.getViewport().getHeight() - lastPickPoint.y - center.y;
    double pickDistanceFactor = Math.min(Math.abs(py) / 3000, 5) * Math.signum(py);
    // New pitch
    Angle pitch = view.getPitch().add(Angle.fromRadians(pitchStep * pickDistanceFactor));
    pitch = pitch.degrees >= 0 ? (pitch.degrees <= 90 ? pitch : Angle.fromDegrees(90)) : Angle.ZERO;
    return pitch;
}
 
Example 5
Source File: Mgrs.java    From constellation with Apache License 2.0 4 votes vote down vote up
public static final String encode(final double latitude, final double longitude) {
    final Angle latAngle = Angle.fromDegrees(latitude);
    final Angle lonAngle = Angle.fromDegrees(longitude);
    return MGRSCoord.fromLatLon(latAngle, lonAngle).toString();
}
 
Example 6
Source File: Coordinates.java    From DataHubSystem with GNU Affero General Public License v3.0 4 votes vote down vote up
public static String mgrsFromLatLon(double lat, double lon)
{
   Angle latitude = Angle.fromDegrees(lat);
   Angle longitude = Angle.fromDegrees(lon);
   return MGRSCoord.fromLatLon(latitude, longitude).toString();
}
 
Example 7
Source File: NwwUtilities.java    From hortonmachine with GNU General Public License v3.0 4 votes vote down vote up
public static LatLon getEnvelopeCenter( Envelope bounds ) {
    Coordinate centre = bounds.centre();
    LatLon latLon = new LatLon(Angle.fromDegrees(centre.y), Angle.fromDegrees(centre.x));
    return latLon;
}
 
Example 8
Source File: NwwUtilities.java    From hortonmachine with GNU General Public License v3.0 4 votes vote down vote up
public static LatLon toLatLon( double lat, double lon ) {
    LatLon latLon = new LatLon(Angle.fromDegrees(lat), Angle.fromDegrees(lon));
    return latLon;
}
 
Example 9
Source File: NwwPanel.java    From hortonmachine with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Move to a given location.
 * 
 * @param lon
 *            the longitude.
 * @param lat
 *            the latitude.
 * @param elev
 *            the eye elevation.
 * @param azimuth
 *            if supplied, the map is rotated to follow that angle.
 * @param animate
 *            if <code>true</code>, it animates to the position.
 */
public synchronized Position goTo( Double lon, Double lat, Double elev, Double azimuth, boolean animate ) {
    View view = getWwd().getView();
    view.stopAnimations();
    view.stopMovement();

    Position eyePosition;
    if (lon == null || lat == null) {
        Position currentEyePosition = wwd.getView().getCurrentEyePosition();
        if (currentEyePosition != null) {
            lat = currentEyePosition.latitude.degrees;
            lon = currentEyePosition.longitude.degrees;
        } else {
            return null;
        }
    }

    if (elev == null) {
        // use the current
        elev = wwd.getView().getCurrentEyePosition().getAltitude();
    }
    if (Double.isNaN(elev)) {
        if (!Double.isNaN(lastElevation)) {
            elev = lastElevation;
        } else {
            elev = NwwUtilities.DEFAULT_ELEV;
        }
    }
    eyePosition = NwwUtilities.toPosition(lat, lon, elev);
    if (animate) {
        view.goTo(eyePosition, elev);
    } else {
        view.setEyePosition(eyePosition);
    }
    if (azimuth != null) {
        Angle heading = Angle.fromDegrees(azimuth);
        view.setHeading(heading);
    }
    lastElevation = elev;
    return eyePosition;
}
 
Example 10
Source File: Util.java    From openvisualtraceroute with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * Distance between two points on the globe (in km)
 *
 * @param point1
 * @param point2
 * @param globe
 * @return
 */
public static int distance(final RoutePoint point1, final RoutePoint point2) {
	final LatLon ll1 = new LatLon(Angle.fromDegrees(point1.getLat()), Angle.fromDegrees(point1.getLon()));
	final LatLon ll2 = new LatLon(Angle.fromDegrees(point2.getLat()), Angle.fromDegrees(point2.getLon()));
	return (int) (Earth.WGS84_EQUATORIAL_RADIUS * LatLon.greatCircleDistance(ll1, ll2).getRadians() / 1000);
}