29 March 2009

Maven Plugin for Eclipse Source Bundles

The Maven Source Plugin creates a JAR containing the sources of a project and attaches it to the main artifact of the project.

It would be nice if you could directly use this JAR as source attachment for a bundle in your Eclipse target platform, but Eclipse 3.4 expects a special Source Bundle format with specific headers in the manifest. There is a feature request to support this directly in the Maven Source Plugin.

To fill this gap, I had a look at the sources of the Maven Source and Archiver plugins and wrote my own maven-sourcebundle-plugin. This plugin is available for public use as a subproject of the DataScript project hosted at BerliOS.

There is no public Maven repository for this project yet, but it is contained in the latest binary release rds-bin-0.30, or you can get the sources from Subversion.

3D Rendering in uDig

I've started experimenting with Java3D rendering in uDig. The goal is to use Java3D as a rendering engine first for plain old 2D data, and then for real 3D data in the next step.

More details can be found in the uDig wiki.

25 March 2009

Java3D and Eclipse

The world is not flat, and 3D maps is one of the latest hypes in navigation systems. (Is anybody using them for real, I wonder....)

So there is a need for me to deal with 3D city and terrain models in my applications, and of course the first thing you want is a 3D viewer. I started experimenting with Java3D a few months ago, and it felt such a relief compared to OpenGL programming in C. The only thing that gave me a hard time is the lack of documentation in some areas, but in the end I could answer most of my questions by studying the source code or by trial and error.

At first, I wrote a couple of stand-alone viewers with a Canvas3D embedded in an AWT Frame, but what I really need is Java3D embedded in an Eclipse view or editor.

I found a couple of postings on Java3D with SWT which sounded rather discouraging, but in the end it was rather straightforward. The java3d-eclipse project on Sourceforge gave me some useful hints, but I cannot recommend using it, since the way that it re-bundles the Java3D JARs is definitely not OSGi-compliant.

Now here is my own recipe:
  • Get the sources for Java3D 1.5.2 from https://java3d.dev.java.net. There is no source package, you have to use CVS. You need three subprojects: j3d-core, j3d-core-utils and vecmath.
  • Compile vecmath into a stand-alone OSGi bundle.
  • Follow the Java3D build instructions to build j3d-core and j3d-utils in one go, including some native library compilation and Java code generation.
  • j3d-core and j3d-core-utils mutually depend on each other and cannot be compiled separately, so I really don't understand why Sun created two libraries instead of one. Anyway, to be friendly to Maven and OSGi, I copied the original sources, the generated sources and the native library binaries to just one Maven project, created a POM and built my Java3D OSGi bundle using the maven-bundle-plugin.
  • I did this both for Windows and Linux and managed to launch the HelloUniverse demo from Equinox.
  • For cross-platform use, move the platform specific code (both the native libs and a handful of Java classes) to separate projects and build OSGi fragments for these, similar to SWT.
After these preparations, embedding a Canvas3D into an Eclipse view or editor is as easy as this:

public void createPartControl(Composite parent)
{
awtContainer = new Composite(parent, SWT.EMBEDDED);

Frame frame = SWT_AWT.new_Frame(awtContainer);
frame.setLayout(new BorderLayout());

GraphicsConfiguration config = SimpleUniverse
.getPreferredConfiguration();

Canvas3D canvas = new Canvas3D(config);

createUniverse(canvas);
frame.add(canvas, BorderLayout.CENTER);
}

19 March 2009

Anaconda: A New Architecture for Compiling Navigation Databases

In my previous post, I presented the Anaconda Workbench, without explaining about Anaconda. This is the code name for my current project, a Map Compiler for processing map data into a compact binary database for car navigation systems of Harman/Becker.

I gave a talk about Anaconda at the Eclipse Demo Camp in Hamburg in November last year. The slides of this talk explain the purpose of a Map Compiler and our usage of OSGi and Eclipse and lots of other fabulous Open Source components.

18 March 2009

Anaconda Workbench: A uDig Application

Now here is a glimpse at what we are using uDig for. I think all the digging in the internals of several Open Source projects is now beginning to pay off.

The Anaconda Workbench is an application for viewing and testing car navigation databases in the forthcoming Navigation Data Standard format (NDS). (This is a closed source project of Harman/Becker, so I cannot offer more than some general information here.)

We implemented a Geotools extension for the NDS format, and a corresponding uDig catalog plug-in. This was enough to build an NDS map viewer. The map has multiple levels of detail in separate layers. We use SLD for styling the layers and for activating the appropriate layer depending on the current map scale.

On top of the map viewer functionality, there is a name browser which allows you to select road names and display the road on the map or use it as a start or destination for a route.

There is also a route calculator plug-in which finds the shortest route between two points and highlights the route in a separate layer.

More functionality will be added step by step. In the end, the Anaconda Workbench shall become a front-end for our map compilation process and not just a viewer for the compiled map databases.

udigLite: An OSGi-friendly subset of uDig

At long last, my team and I have succeeded in creating a subset of uDig which suits our environment. The baby is called udigLite, and the first binary releases can be downloaded from BerliOS, the site also hosting our Mercurial clones of the original Subversion source repositories.

Read the whole story in the uDig wiki.