@Override public void creationSucceeded(LayerFactory factory, Layer layer) { // Add the finished GeoPackage layer to the WorldWindow. getWorldWindow().getLayers().addLayer(layer); // Place the viewer directly over the GeoPackage image. getWorldWindow().getNavigator().setLatitude(36.8139677556754); getWorldWindow().getNavigator().setLongitude(-76.03260320181615); getWorldWindow().getNavigator().setAltitude(20e3); Log.i("gov.nasa.worldwind", "GeoPackage layer creation succeeded"); }
@Override protected void gestureDidBegin() { if (this.activeGestures++ == 0) { this.wwd.getNavigator().getAsCamera(this.wwd.getGlobe(), this.beginCamera); this.camera.set(this.beginCamera); } }
protected void gestureDidBegin() { if (this.activeGestures++ == 0) { this.wwd.getNavigator().getAsLookAt(this.wwd.getGlobe(), this.beginLookAt); this.lookAt.set(this.beginLookAt); } }
protected void positionView(WorldWindow wwd) { LookAt lookAt = new LookAt().set(46.230, -122.190, 500, WorldWind.ABSOLUTE, 1.5e4 /*range*/, 45.0 /*heading*/, 70.0 /*tilt*/, 0 /*roll*/); wwd.getNavigator().setAsLookAt(this.getWorldWindow().getGlobe(), lookAt); } }
@Override public void run() { this.wwd.getNavigator().setAsCamera(this.wwd.getGlobe(), this.camera); this.wwd.requestRedraw(); pool.release(this.reset()); } }
protected void positionView(WorldWindow wwd) { Position mtRainier = new Position(46.852886, -121.760374, 4392.0); Position eye = new Position(46.912, -121.527, 2000.0); // Compute heading and distance from peak to eye Globe globe = wwd.getGlobe(); double heading = eye.greatCircleAzimuth(mtRainier); double distanceRadians = mtRainier.greatCircleDistance(eye); double distance = distanceRadians * globe.getRadiusAt(mtRainier.latitude, mtRainier.longitude); // Compute camera settings double altitude = eye.altitude - mtRainier.altitude; double range = Math.sqrt(altitude * altitude + distance * distance); double tilt = Math.toDegrees(Math.atan(distance / eye.altitude)); // Apply the new view Camera camera = new Camera(); camera.set(eye.latitude, eye.longitude, eye.altitude, WorldWind.ABSOLUTE, heading, tilt, 0.0 /*roll*/); wwd.getNavigator().setAsCamera(globe, camera); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setAboutBoxTitle("About the " + this.getResources().getText(R.string.title_placemarks_milstd2525)); setAboutBoxText("Demonstrates how to add MilStd2525C Symbols to a RenderableLayer."); // Create a TextView to show the MIL-STD-2525 renderer's initialization status this.statusText = new TextView(this); this.statusText.setTextColor(android.graphics.Color.YELLOW); FrameLayout globeLayout = (FrameLayout) findViewById(R.id.globe); globeLayout.addView(this.statusText); // Set the camera to look at the area where the symbols will be displayed. Position pos = new Position(32.4520, 63.44553, 0); LookAt lookAt = new LookAt().set(pos.latitude, pos.longitude, pos.altitude, WorldWind.ABSOLUTE, 1e5 /*range*/, 0 /*heading*/, 45 /*tilt*/, 0 /*roll*/); this.getWorldWindow().getNavigator().setAsLookAt(this.getWorldWindow().getGlobe(), lookAt); // The MIL-STD-2525 rendering library takes time initialize, we'll perform this task via the // AsyncTask's background thread and then load the symbols in its post execute handler. new InitializeSymbolsTask().execute(); }
@Override public void doFrame(long frameTimeNanos) { if (this.lastFrameTimeNanos != 0) { // Compute the frame duration in seconds. double frameDurationSeconds = (frameTimeNanos - this.lastFrameTimeNanos) * 1.0e-9; double cameraDegrees = (frameDurationSeconds * this.cameraDegreesPerSecond); // Move the navigator to continuously bring new tiles into view. Navigator navigator = getWorldWindow().getNavigator(); navigator.setLongitude(navigator.getLongitude() + cameraDegrees); // Redraw the WorldWindow to display the above changes. this.getWorldWindow().requestRedraw(); } Choreographer.getInstance().postFrameCallback(this); this.lastFrameTimeNanos = frameTimeNanos; }
@Override public void doFrame(long frameTimeNanos) { if (this.lastFrameTimeNanos != 0) { // Compute the frame duration in seconds. double frameDurationSeconds = (frameTimeNanos - this.lastFrameTimeNanos) * 1.0e-9; double cameraDegrees = (frameDurationSeconds * this.cameraDegreesPerSecond); // Move the navigator to simulate the Earth's rotation about its axis. Navigator navigator = getWorldWindow().getNavigator(); navigator.setLongitude(navigator.getLongitude() - cameraDegrees); // Redraw the WorldWindow to display the above changes. this.getWorldWindow().requestRedraw(); } if (!this.activityPaused) { // stop animating when this Activity is paused Choreographer.getInstance().postFrameCallback(this); } this.lastFrameTimeNanos = frameTimeNanos; }
@Override public void doFrame(long frameTimeNanos) { if (this.lastFrameTimeNanos != 0) { // Compute the frame duration in seconds. double frameDurationSeconds = (frameTimeNanos - this.lastFrameTimeNanos) * 1.0e-9; double cameraDegrees = (frameDurationSeconds * this.cameraDegreesPerSecond); // Move the navigator to simulate the Earth's rotation about its axis. Navigator navigator = getWorldWindow().getNavigator(); navigator.setLongitude(navigator.getLongitude() - cameraDegrees); // Redraw the WorldWindow to display the above changes. this.getWorldWindow().requestRedraw(); } if (!this.activityPaused) { // stop animating when this Activity is paused Choreographer.getInstance().postFrameCallback(this); } this.lastFrameTimeNanos = frameTimeNanos; }
/** * Creates a new WorldWindow object with a custom WorldWindowController. */ @Override public WorldWindow createWorldWindow() { // Let the super class (BasicGlobeFragment) do the creation WorldWindow wwd = super.createWorldWindow(); // Override the default "look at" gesture behavior with a camera centric gesture controller wwd.setWorldWindowController(new CameraController()); // Create a camera position above KOXR airport, Oxnard, CA Camera camera = new Camera(); camera.set(34.2, -119.2, 10000, WorldWind.ABSOLUTE, 90, // Looking east 70, // Lookup up from nadir 0); // No roll // Apply the new camera position Globe globe = wwd.getGlobe(); wwd.getNavigator().setAsCamera(globe, camera); return wwd; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setAboutBoxTitle("About the " + this.getResources().getText(R.string.title_basic_stress_test)); this.setAboutBoxText("Continuously moves the navigator in an Easterly direction from a low altitude."); // Add the ShowTessellation layer to provide some visual feedback regardless of texture details this.getWorldWindow().getLayers().addLayer(new ShowTessellationLayer()); // Initialize the Navigator so that it's looking in the direction of movement and the horizon is visible. Navigator navigator = this.getWorldWindow().getNavigator(); navigator.setAltitude(1e3); // 1 km navigator.setHeading(90); // looking east navigator.setTilt(75); // looking at the horizon }
protected void handlePinch(GestureRecognizer recognizer) { int state = recognizer.getState(); float scale = ((PinchRecognizer) recognizer).getScale(); if (state == WorldWind.BEGAN) { this.gestureDidBegin(); } else if (state == WorldWind.CHANGED) { if (scale != 0) { // Apply the change in scale to the navigator, relative to when the gesture began. this.lookAt.range = this.beginLookAt.range / scale; this.applyLimits(this.lookAt); this.wwd.getNavigator().setAsLookAt(this.wwd.getGlobe(), this.lookAt); this.wwd.requestRedraw(); } } else if (state == WorldWind.ENDED || state == WorldWind.CANCELLED) { this.gestureDidEnd(); } }
protected void handleRotate(GestureRecognizer recognizer) { int state = recognizer.getState(); float rotation = ((RotationRecognizer) recognizer).getRotation(); if (state == WorldWind.BEGAN) { this.gestureDidBegin(); this.lastRotation = 0; } else if (state == WorldWind.CHANGED) { // Apply the change in rotation to the navigator, relative to the navigator's current values. double headingDegrees = this.lastRotation - rotation; this.lookAt.heading = WWMath.normalizeAngle360(this.lookAt.heading + headingDegrees); this.lastRotation = rotation; this.wwd.getNavigator().setAsLookAt(this.wwd.getGlobe(), this.lookAt); this.wwd.requestRedraw(); } else if (state == WorldWind.ENDED || state == WorldWind.CANCELLED) { this.gestureDidEnd(); } }
@Override protected void handleRotate(GestureRecognizer recognizer) { int state = recognizer.getState(); float rotation = ((RotationRecognizer) recognizer).getRotation(); if (state == WorldWind.BEGAN) { this.gestureDidBegin(); this.lastRotation = 0; } else if (state == WorldWind.CHANGED) { // Apply the change in rotation to the navigator, relative to the navigator's current values. double headingDegrees = this.lastRotation - rotation; this.camera.heading = WWMath.normalizeAngle360(this.camera.heading + headingDegrees); this.lastRotation = rotation; this.wwd.getNavigator().setAsCamera(this.wwd.getGlobe(), this.camera); this.wwd.requestRedraw(); } else if (state == WorldWind.ENDED || state == WorldWind.CANCELLED) { this.gestureDidEnd(); } }
@Override protected void handlePinch(GestureRecognizer recognizer) { int state = recognizer.getState(); float scale = ((PinchRecognizer) recognizer).getScale(); if (state == WorldWind.BEGAN) { this.gestureDidBegin(); } else if (state == WorldWind.CHANGED) { if (scale != 0) { // Apply the change in scale to the navigator, relative to when the gesture began. scale = ((scale - 1) * 0.1f) + 1; // dampen the scale factor this.camera.altitude = this.camera.altitude * scale; this.applyLimits(this.camera); this.wwd.getNavigator().setAsCamera(this.wwd.getGlobe(), this.camera); this.wwd.requestRedraw(); } } else if (state == WorldWind.ENDED || state == WorldWind.CANCELLED) { this.gestureDidEnd(); } }
@Override public void run() { this.wwd.getNavigator().getAsCamera(this.wwd.getGlobe(), this.beginCamera); this.beginPos.set(this.beginCamera.latitude, this.beginCamera.longitude, this.beginCamera.altitude); for (int i = 0; i < this.steps; i++) { double amount = (double) i / (double) (this.steps - 1); this.beginPos.interpolateAlongPath(this.endPos, WorldWind.GREAT_CIRCLE, amount, this.curPos); this.curCamera.latitude = this.curPos.latitude; this.curCamera.longitude = this.curPos.longitude; this.curCamera.altitude = this.curPos.altitude; this.curCamera.heading = WWMath.interpolateAngle360(amount, this.beginCamera.heading, this.endCamera.heading); this.curCamera.tilt = WWMath.interpolateAngle180(amount, this.beginCamera.tilt, this.endCamera.tilt); this.curCamera.roll = WWMath.interpolateAngle180(amount, this.beginCamera.roll, this.endCamera.roll); Runnable setCommand = SetCameraCommand.obtain(this.wwd, this.curCamera); runOnActivityThread(setCommand); sleepQuietly(FRAME_INTERVAL); } } }
@Override public void doFrame(long frameTimeNanos) { if (this.lastFrameTimeNanos != 0) { // Compute the frame duration in seconds. double frameDurationSeconds = (frameTimeNanos - this.lastFrameTimeNanos) * 1.0e-9; double cameraDegrees = (frameDurationSeconds * this.cameraDegreesPerSecond); double lightDegrees = (frameDurationSeconds * this.lightDegreesPerSecond); // Move the navigator to simulate the Earth's rotation about its axis. Navigator navigator = getWorldWindow().getNavigator(); navigator.setLongitude(navigator.getLongitude() - cameraDegrees); // Move the sun location to simulate the Sun's rotation about the Earth. this.sunLocation.set(this.sunLocation.latitude, this.sunLocation.longitude - lightDegrees); this.atmosphereLayer.setLightLocation(this.sunLocation); // Redraw the WorldWindow to display the above changes. this.getWorldWindow().requestRedraw(); } if (!this.activityPaused) { // stop animating when this Activity is paused Choreographer.getInstance().postFrameCallback(this); } this.lastFrameTimeNanos = frameTimeNanos; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setAboutBoxTitle("About the " + this.getResources().getText(R.string.title_day_night_cycle)); setAboutBoxText("Demonstrates how to display a continuous day-night cycle on the WorldWind globe.\n" + "This gradually changes both the Navigator's location and the AtmosphereLayer's light location."); // Initialize the Atmosphere layer's light location to our custom location. By default the light location is // always behind the viewer. LayerList layers = this.getWorldWindow().getLayers(); this.atmosphereLayer = (AtmosphereLayer) layers.getLayer(layers.indexOfLayerNamed("Atmosphere")); this.atmosphereLayer.setLightLocation(this.sunLocation); // Initialize the Navigator so that the sun is behind the viewer. Navigator navigator = this.getWorldWindow().getNavigator(); navigator.setLatitude(20); navigator.setLongitude(this.sunLocation.longitude); // Use this Activity's Choreographer to animate the day-night cycle. Choreographer.getInstance().postFrameCallback(this); }
protected void handleTilt(GestureRecognizer recognizer) { int state = recognizer.getState(); float dx = recognizer.getTranslationX(); float dy = recognizer.getTranslationY(); if (state == WorldWind.BEGAN) { this.gestureDidBegin(); this.lastRotation = 0; } else if (state == WorldWind.CHANGED) { // Apply the change in tilt to the navigator, relative to when the gesture began. double headingDegrees = 180 * dx / this.wwd.getWidth(); double tiltDegrees = -180 * dy / this.wwd.getHeight(); this.lookAt.heading = WWMath.normalizeAngle360(this.beginLookAt.heading + headingDegrees); this.lookAt.tilt = this.beginLookAt.tilt + tiltDegrees; this.applyLimits(this.lookAt); this.wwd.getNavigator().setAsLookAt(this.wwd.getGlobe(), this.lookAt); this.wwd.requestRedraw(); } else if (state == WorldWind.ENDED || state == WorldWind.CANCELLED) { this.gestureDidEnd(); } }