Fork me on GitHub

Paths

This example renders four different wing-shaped or chevron-shaped paths on the globe.

  • The northern most path is above ground, using the default ABSOLUTE altitude mode and default attributes.
  • The next path is on the terrain surface, using a CLAMP_TO_GROUND altitude mode and setFollowTerrain(true).
  • The third path is above ground, like the first, but with setExtrude(true).
  • The southern most path is like the third, but with custom attributes.

PathsFragment.java

The PathsFragment class extends the BasicGlobeFragment and overrides the createWorldWindow method. Here we create and add a RenderableLayer to the globe, and then define and add four Paths to the layer.

package gov.nasa.worldwindx;
...
public class PathsFragment extends BasicGlobeFragment {

    /**
     * Creates a new WorldWindow (GLSurfaceView) object with a set of Path shapes
     *
     * @return The WorldWindow object containing the globe.
     */
    @Override
    public WorldWindow createWorldWindow() {
        // Let the super class (BasicGlobeFragment) do the creation
        WorldWindow wwd = super.createWorldWindow();

        // Create a layer to display the tutorial paths.
        RenderableLayer layer = new RenderableLayer();
        wwd.getLayers().addLayer(layer);

        // Create a basic path with the default attributes, the default altitude mode (ABSOLUTE),
        // and the default path type (GREAT_CIRCLE).
        List<Position> positions = Arrays.asList(
        Position.fromDegrees(50, -180, 1e5),
        Position.fromDegrees(30, -100, 1e6),
        Position.fromDegrees(50, -40, 1e5)
        );
        Path path = new Path(positions);
        layer.addRenderable(path);

        // Create a terrain following path with the default attributes, and the default path type (GREAT_CIRCLE).
        positions = Arrays.asList(
        Position.fromDegrees(40, -180, 0),
        Position.fromDegrees(20, -100, 0),
        Position.fromDegrees(40, -40, 0)
        );
        path = new Path(positions);
        path.setAltitudeMode(WorldWind.CLAMP_TO_GROUND); // clamp the path vertices to the ground
        path.setFollowTerrain(true); // follow the ground between path vertices
        layer.addRenderable(path);

        // Create an extruded path with the default attributes, the default altitude mode (ABSOLUTE),
        // and the default path type (GREAT_CIRCLE).
        positions = Arrays.asList(
        Position.fromDegrees(30, -180, 1e5),
        Position.fromDegrees(10, -100, 1e6),
        Position.fromDegrees(30, -40, 1e5)
        );
        path = new Path(positions);
        path.setExtrude(true); // extrude the path from the ground to each path position's altitude
        layer.addRenderable(path);

        // Create an extruded path with custom attributes that display the extruded vertical lines,
        // make the extruded interior 50% transparent, and increase the path line with.
        positions = Arrays.asList(
        Position.fromDegrees(20, -180, 1e5),
        Position.fromDegrees(0, -100, 1e6),
        Position.fromDegrees(20, -40, 1e5)
        );
        ShapeAttributes attrs = new ShapeAttributes();
        attrs.setDrawVerticals(true); // display the extruded verticals
        attrs.setInteriorColor(new Color(1, 1, 1, 0.5f)); // 50% transparent white
        attrs.setOutlineWidth(3);
        path = new Path(positions, attrs);
        path.setExtrude(true); // extrude the path from the ground to each path position's altitude
        layer.addRenderable(path);

        return wwd;
    }
}


Server maintenance notice

Dear WorldWind Community,

The geospatial data services that feed WorldWind clients by default with data are undergoing maintenance. Outages between 2 to 4 hours per server may occur during the month of April 2023.

As always, if you have any inquiries or concerns, please contact us at:

arc-worldwind@mail.nasa.gov