CS211 NASA WorldWind Project
In
this project you will learn to use NASA WorldWind (http://worldwind.arc.nasa.gov/).
The NASA WorldWind project is a free Java software development kit used
to create a virtual world, similar to Google Earth. One of the great
powers in software devlopment is using other people's code and adding
your own functioality. In this project that is what you will do.
We
will use NASA WorldWind to create a virtual guided tour program for
George Mason University and an interactive user driven tour.
This project will give you experience with Stacks, Listeners, SortedSet (TreeSet), Reading and parsing files.
You will do several steps.
Step One: Getting Started with NASA WorldWind in Netbeans
1. Download the NASA WorldWind project Java SDK.
2. Unzip the SDK into a directory (we'll assume <<worldwind>> for now)
3. You now need to create a Worldwind library in Netbeans
4. In Netbeans select Tools->Library Manager
5. Select "New library"
- Library name: Worldwind
- Library type: Class libraries
6. Click Add Jar/Folder and select:
- <<worldwind>>/worldwind.jar
- <<worldwind>>/gluegen-rt.jar
- <<worldwind>>/jogl.jar
7. Choose the sources tab
- Click add Jar/Folder
- Select the directory <<worldwind>>/src
8. Choose the Javadoc tab
- Click Add ZIP/Folder
- Select the directory <<worldwind>>/doc
9. Finally click "ok".
You now have a library you can use to access the NASA WorldWind SDK easily in Java.
Step Two: Create the Netbeans Project
1. Create a new Netbeans project. Name it <<Lastname>>WorldWind (e.g. mine is FleckWorldWind)
2. Right click on the project in Netbeans and select properties
- Select Run
- In the VM Options box you need to add: -Djava.library.path=<<worldwind>>
- Note: You must replace <<worldwind>> with your real path
to the worldwind files mine is /users/dfleck/javacode/worldwind
- Note: We assume you're using Unix. Your library path
should not include any spaces (like "My Documents" on Windows).
- Note: A good windows path looks like this: -Djava.library.path=c:\worldwind
- Now select Libraries on the left side.
- Choose "add library"
- Select the WorldWind library you created in Step One above.
3. Download these files and add them to your project
- GMUWorldWindDemo.java
- GMUWorldWindCommands.java
- WorldWindAppFrame.java
- GMUPositionListener.java
- DistanceListener.java
4. Try to compile and run GmuWorldWindDemo.
- Note: You need an internet connection to download imagery while running!
Step Three: Create a Guided Virtual Tour Application for George Mason
In
this part you will use the power of NASA WorldWind to create a virtual
tour of the George Mason campus. The tour will take a set of GPS points
(latitude and longtiude). You will read these in from a file and create
a Stack of them. Then, pop each value off the Stack and go to that
location. Once you are in the correct location display the information
about the building you are at. Wait 5 seconds, and move on to the next
building by popping the next value from the Stack.
BuildingInfo.txt - Information about each building on the tour (in order that you should tour them), including the GPS coordinates
The building info file has four fields separated by tilde "~".
Building Name~Description~latitude~longitude
NOTE: A successful implementation of this must use a java.util.Stack data structure!
Hint:
To wait 5 seconds you can use this line:
try
{ Thread.sleep(5000); } catch (Exception e) { } // Wait
Hint: After you go to each building, before going to the next building set your altitude to 1000m and wait 5 seconds.
Hint: After you startup the app frame wait 1 second BEFORE you try to goToGPS.
Hint:
You should probably create a Class (mine was called Building.java) to
hold the building information (name, desc, lat, long). This should be
what goes in your Stack. You then pop it off, go to the lat/long and
display the description in the information window using the
setInfoText(String txt) method.
Step Four: Create an interactive Virtual Tour of George Mason
In
the interactive tour the user drags the map wherever they want to go.
Once the map stops moving you will give them the information about the
closest building assuming it is within 1 km. If they are more than
1km from any GMU building, you should give them a message that they are
not close to any GMU building.
You need to be able to do a few things to make this all work.
- First
you need to be able to determine how far you are from any building.
This requires calculating the distance between two points on the globe.
(There are methods around to do this in the code you have.)
- Next
you need to know when the globe has stopped you need to implement the
GMUPositionListener interface. This interface will allow you to listen
for globe moving events. Everytime the globe is moved and then stops,
the method moved(PositionEvent e) will be called. When this is
called you should check how far you are from all of the buildings. Put
up the information for the closest building if you are within 1km of
that building.
- Note:
The moved() method may be called many times... the idea of "stopped"
isn't very stable in NASA WorldWind. Try to make it work and see what
you get.
Step Five: Display the distance to all buildings from your current location (sorted)
In
the interface there is a button "Show Distances". If the user presses
this button they want to see all the building names and distances from
the current location sorted (closest building first).
You need to be able to do a few things to make this all work.
- First
you need to implement the DistanceListener interface. This is
essentially a single method that will be called when the user hits the
"Show Distances" button.
- You then need to add yourself as a registered listener by calling the addDistanceListener() method of WorldWindAppFrame.
- Next,
you need to create a new class "BuildingDistance". This class should
hold a Building object and a distance to the current point. In addition
it must implement the Comparable interface so it can be sorted
automatically using Java's TreeSet class.
- When the
user presses the Get Distance button you must create a new TreeSet of
BuildingDistance objects. Then insert every building into that Set.
They should automatically be sorted. You then just need to iterate
through them adding each building name and distance into the
information window by calling setInfoText.
What to turn in:
- A single JAR file with all your source code including:
- Code that implements the guided virtual tour
- Code that implements the Interactive virtual tour
- Code that responds to the getDistance button
- Any corresponding data structure classes (I had Building.java and BuildingDistance.java)