Friday, September 28, 2007

Text and messages translation in WWJ

In the WWJ SDK you may have noticed a file named MessageStrings.properties and several others named the same but with an extra two characters country code like de, ja,or zh. These are simple text files that contain all the constant character strings for one language. WWJ will use the one that has the same country code as your computer settings.


To have WWJ 'speak' your tongue, just make a copy of the default english file - the only one that contains all the messages, and name it MessageStrings_xx.properties, xx being your country code. Then translate the messages you want and delete all the others. You dont need to have all the messages translated in your file, the missing ones will fall back to english.

Note that special characters must be specified as Unicode hexadecimal numbers (eg. \u00c9 for 'É').

Here is a portion of a french property file with translated layer names. Get MessageStrings_fr.properties, and after removing the .txt extension, place it with the other MessageStrings files. Run one of the demo or example applications.

Also note that this doesnt translate the placenames...

Tuesday, September 25, 2007

3D stereo anaglyph view in WWJ

3D graphics are great, but stereo 3D is even better. Here is a quickly put together AnaglyphSceneController for WWJ. Is is to be used in place of the BasicSceneController from the SDK and will produce real time red/cyan anaglyphs whenever the view is pitched more than twenty degrees.


Download AnaglyphSceneController.java (updated sept 27) and add it to src.gov.nasa.worldwind - after removing the .txt extension. To use it, edit src.config.worldwind.properties and change the class name for the gov.nasa.worldwind.avkey.SceneControllerClassName entry:

gov.nasa.worldwind.avkey.SceneControllerClassName
                =gov.nasa.worldwind.AnaglyphSceneController


Overall it works reasonably well considering the amount of code - its quite simple. However, the stereo effect tends to shift when the view is being moved or rotated, but it eventually settles down to the proper settings when you stop moving around.


You need red and cyan glasses (with the red filter on the left eye) to view those anaglyphs. Caution, you may quickly feel sick... reduce the focusAngle to 1.5 or 1 degree if the stereo separation is too sharp.

Enjoy the world in real 3D ;)

World Wind Java forum tread.

Monday, September 24, 2007

Sky gradient and atmosphere for WWJ

Here is a preview of the SkyGradientLayer for WWJ. It works very well with the fog and stars layers, and makes for some nice screenshots. Still needs some tuning and cleanup though.


Download SkyGradientLayer.java (updated sept 27) and add it to the layers.earth package of the SDK - after removing the .txt extension.


The layer should be placed between the stars and the fog like : stars, sky gradient, fog, blue marble, I3 Landsat...

World Wind Java forum tread.

Saturday, September 22, 2007

Saving a WWJ layer tiles composite

Many have asked on the WW forum how to 'extract' a portion of a layer imagery and save it for further use with other applications. It happens that WWJ has a built in public method in TiledImageLayer that does exactly that - at least the hard part of it, the tiles retrieval and composition. All what's left to do is save the composited BufferedImage.

Here is some test code:

// Save a composite of a layer's tiles into a file
private void saveImageForSector(TiledImageLayer layer)
{
int imageSize = 1024; // Saved image max dimension
int level = 0; // level number (-1 = best)
Sector sector = new Sector(
Angle.fromDegrees(43.4), Angle.fromDegrees(44.4),
Angle.fromDegrees(6), Angle.fromDegrees(8));
java.awt.image.BufferedImage image =
layer.composeImageForSector(sector, imageSize, level);
try
{
javax.imageio.ImageIO.write(image, "png",
new java.io.File("SavedImageSector.png"));
}
catch (IOException e) {}
}

The above method needs a TiledImageLayer reference - the like of BMNGSurfaceLayer or LandsatI3. The level number must take into account the layer empty levels: if it has 10 levels with 4 empty ones then the first real level is 4, the second 5 and so on until 9. Chosing level zero will always give you the first non empty level anyway.

The composeImageForSector() method does quite a tedious work of tracking down all the tiles needed and will trigger download requests if necessary. It will then scale and paste each of them into the final image.

It works but would probably need some tuning, as you seem to quickly run out of memory when dealing with larger numbers of tiles or larger output dimensions. The final composited image quality may vary a lot too, depending on how much scaling has been applied to the original tiles... so dont expect too much ;)

Monday, September 17, 2007

Community maintained geotags in a WWJ applet

And again a new World Wind Java applet is online. GeoFlexy is a web site that lets you add community shared geographic tags and view them over a 2D Google Map or a 3D WWJ applet.

The 'spots' can be added by navigating a map and filling a form with description, address, Zip code and other informations, including one picture and a link to a web site.

Developed by turman a forum contributor, the site as of now is more an experiment than a fully operational community portal, but it is the most interesting WWJ applet usage i've seen so far.