Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Embed the NASA World Wind Java SDK in Eclipse

Develop GIS applications with this open source SDK

  Vladimir Silva
Vladimir Silva is a former IBM software engineer who worked for the IBM WebAhead technology think tank on projects such as the IBM Grid Toolbox. Some of his work on server-side security has been incorporated into Globus Toolkit. He is the author of Grid Computing for Developers (Charles River Media, 2005). His other interests include neural nets and artificial intelligence. Vladimir holds numerous IT certifications.

Summary:  The open source World Wind Java (WWJ) SDK by NASA creates new possibilities for the open Geographic Information Systems (GIS) community. World Wind, a 3D interactive world viewer written in the Java™ language and OpenGL, lets users zoom from outer space into any place on Earth. This article explains how GIS developers who want to enhance their Eclipse-based applications can embed the WWJ SDK as an Eclipse plug-in.

Date:  03 Jun 2008
Level:  Intermediate PDF:  A4 and Letter (224KB)Get Adobe® Reader®
Also available in:   Chinese  Japanese  Vietnamese

Activity:  25006 views
Comments:  

The WWJ SDK is a 3D graphics globe built on top of the Java OpenGL (JOGL) extensions. At the core of the WWJ class hierarchy is the WorldWindowGLCanvas, which is a subclass of GLCanvas. GLCanvas is in turn an Abstract Window Toolkit (AWT) component.

WWJ's dependence on AWT is an obstacle for GIS developers who want to use WWJ in their Eclipse applications. As you probably know, Eclipse uses the Standard Widget Toolkit (SWT), which is incompatible with AWT. Furthermore, AWT and JOGL are tightly integrated, making a port of the AWT interfaces to SWT difficult. This article presents a solution that enables you to use the WWJ SDK with your Eclipse applications.

Datasets bundled with WWJ

WWJ bundles the following low-, medium-, and high-resolution datasets (see Resources for links to them):

  • Blue Marble (1-km/pixel resolution)
  • i-cubed Landsat 7 (15-meter/pixel resolution) from the Global Land Cover Facility of the University of Maryland Institute for Advanced Computer Studies
  • Elevation data (SRTM30Plus/SRTMv2/USGS NED derived dataset) from the NASA Jet Propulsion Laboratory
  • USGS Topographic, B&W Ortho, and Color Urban Area USGS and Microsoft® Research
  • U.S. placenames from the USGS Geographic Names Information System
  • World placenames from the National Geospatial-Intelligence Agency

Enter the SWT/AWT bridge

The SWT is rapidly becoming a top-tier windowing toolkit for quickly building scalable and powerful client applications. Both SWT and AWT/Swing are battling for supremacy of Java user interface development. Given the fact that both have advantages and disadvantages, the Eclipse Foundation recognized the need to build a SWT/AWT bridge that allows you to embed AWT/Swing components into SWT. The bridge has been part of SWT since Eclipse version 3.0. This simple API is located in the org.eclipse.swt.awt package (see Resources).

The SWT/AWT bridge is the key component you need to embed the AWT-based World Wind 3D Globe into an Eclipse application via SWT.

Eclipse view for WWJ 3D Earth

With the SWT/AWT bridge already in SWT, embedding a WWJ 3D Earth within your view is a snap. Listing 1 demonstrates a basic Eclipse view that performs this task:


Listing 1. Basic Eclipse view for the WWJ 3D Earth
                
package org.eclipse.plugin.worldwind.views;
_

/**
 * World Wind Eclipse RCP Earth View
 * @author Vladimir Silva
 *
 */
public class EarthView extends ViewPart
{
   private static final Logger logger = Logger.getLogger(EarthView.class);
   
   public static final String ID = EarthView.class.getName(); 
   final WorldWindowGLCanvas world = new WorldWindowGLCanvas();
   

   /**
    * Initialize the default WW layers
    */
   static {
      initWorldWindLayerModel();
   }

   public EarthView() {
      
   }
   
   /**
    * This is a callback that will allow us to create the viewer and initialize
    * it.
    */
   public void createPartControl(Composite parent) 
   {
      // GUI: an SWT composite on top
      Composite top = new Composite(parent, SWT.EMBEDDED);
      top.setLayoutData(new GridData(GridData.FILL_BOTH));
        
      // Swing Frame and Panel
      java.awt.Frame worldFrame = SWT_AWT.new_Frame(top);
      java.awt.Panel panel = new java.awt.Panel(new java.awt.BorderLayout());
      
      worldFrame.add(panel);

      // Add the WWJ 3D OpenGL Canvas to the Swing Panel
      panel.add(world, BorderLayout.CENTER);

      parent.setLayoutData(new GridData(GridData.FILL_BOTH));
        
   }

   /*
    * Initialize WW model with default layers
    */
   static void initWorldWindLayerModel () 
   {
      Model m = (Model) WorldWind.createConfigurationComponent(
            AVKey.MODEL_CLASS_NAME);

      world.setModel(m);
   }

   /**
    * Passing the focus request to the viewer's control.
    */
   public void setFocus() {
   }
   
   public static void repaint() {
      world.repaint();
   }

   @Override
   public void dispose() {
      super.dispose();
   }
   
}

Listing 1 starts by creating a top SWT component that uses the bridge to embed the WWJ swing OpenGL canvas:

Composite top = new Composite(parent, SWT.EMBEDDED);
top.setLayoutData(new GridData(GridData.FILL_BOTH));

Next, a child AWT frame is created within the top SWT component, using the bridge, to host the Swing panel required by the WWJ OpenGL canvas:

java.awt.Frame worldFrame = SWT_AWT.new_Frame(top);
java.awt.Panel panel = new java.awt.Panel(new java.awt.BorderLayout());

Finally, the WWJ GL canvas is added to the Swing panel:

WorldWindowGLCanvas world = new WorldWindowGLCanvas();
panel.add(world, BorderLayout.CENTER);

Figure 1 shows Earth embedded within an Eclipse view as part of a Rich Client Platform (RCP) application:


Figure 1. WWJ Earth as an Eclipse view
Figure 1. WWJ Earth as an Eclipse View

WWJ vs. Google Earth and Virtual Earth

Google Earth and Virtual Earth are popular 3D globes that are also available. They too are 3D Earths that let users zoom in and view locations. But despite their similarities to WWJ, these tools have fundamentally different philosophies. Google Earth and Virtual Earth are commercial products, not SDKs, so developers cannot enhance the client to fit their needs. For example, scientists can't add support for scientific data formats or interfaces to mapping services such as OpenGIS Web Map Services (WMS) or Web Feature Services (WFS). WWJ's open source nature allows you to embed the globe in virtually any type of client, as you've seen in this article. WWJ can also be modified to access any type of data service. This is a huge advantage over its commercial counterparts.

Flying to a location within a globe

If you want your application to fly to a specific latitude/longitude in a Google Earth style, three objects are required:

  • A View that provides a coordinate transformation from model coordinates to eye coordinates, following the OpenGL convention of a left-handed coordinate system

  • A Globe representing the 3D ellipsoidal sphere of the world you are looking at

  • The latitude/longitude coordinates of the point you wish to fly to

Optional information includes angles for heading and pitch and altitude in meters.

Listing 2 demonstrates how to fly to a location:


Listing 2. Flying to given latitude/longitude coordinates
                
public void flyTo (LatLon latlon) 
{
   View view       = world.getView();
   Globe globe = world.getModel().getGlobe();
   
   view.applyStateIterator(FlyToOrbitViewStateIterator.createPanToIterator(
           (OrbitView)view
           , globe
           , latlon      // bbox
           , Angle.ZERO   // Heading
           , Angle.ZERO   // Pitch
           , 3e3 )       // Altitude/Zoom (m)
           );
}

The applyStateIterator() method of the View class pans or zooms the globe, producing a smooth fly-to or an instantaneous zoom effect on the globe's target coordinates.

WWJ bundles other globes besides Earth; 3D worlds available as of WWJ version 0.4.1 are:

  • Earth (see Resources for the included datasets).
  • Moon: 40xx/30xx color/grayscale layers, created using a combination of several spectral bands from the Clementine mission.
  • Mars: Including high-resolution imagery from missions such as Mars Orbital Camera (MOC), Elevation Maps created using data from the NASA Jet Propulsion Laboratory, and data from NASA Mars Odyssey/THEMIS.

Figure 2 shows the Earth, moon, and Mars as three distinct Eclipse views:


Figure 2. Earth, moon, and Mars views within a RCP application
Figure 2. Earth, moon, and Mars views within a Rich Client Application

Conclusion

The World Wind Java SDK is a 3D interactive world viewer written in Java and OpenGL that allows any user to zoom from outer space into any place on Earth. This article gives you the foundation for embedding the WWJ SDK as an Eclipse view to gain a new set of powerful tools for GIS development within Eclipse.


Resources

Learn

Get products and technologies

Discuss

About the author

  Vladimir Silva

Vladimir Silva is a former IBM software engineer who worked for the IBM WebAhead technology think tank on projects such as the IBM Grid Toolbox. Some of his work on server-side security has been incorporated into Globus Toolkit. He is the author of Grid Computing for Developers (Charles River Media, 2005). His other interests include neural nets and artificial intelligence. Vladimir holds numerous IT certifications.

Report abuse help

Report abuse

Thank you. This entry has been flagged for moderator attention.


Report abuse help

Report abuse

Report abuse submission failed. Please try again later.


developerWorks: Sign in


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

Choose your display name

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


Rate this article

Comments

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Java technology, Open source
ArticleID=311635
ArticleTitle=Embed the NASA World Wind Java SDK in Eclipse
publish-date=06032008
author1-email=vladimir_silva@hotmail.com
author1-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

For articles in technology zones (such as Java technology, Linux, Open source, XML), Popular tags shows the top tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), Popular tags shows the top tags for just that product zone.

For articles in technology zones (such as Java technology, Linux, Open source, XML), My tags shows your tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), My tags shows your tags for just that product zone.

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Special offers