OSM2World/Using OSM2World as a library

From OpenStreetMap Wiki
Jump to: navigation, search

OSM2World can be used as a library in Java programs running on a JVM. As always: If you need more functionality, don't understand the code, etc., just ask!



  1. Download OSM2World. The archive contains OSM2World and all libraries it depends on.
  2. Make sure that OSM2World.jar and its dependencies (the .jar files in the subdirectories of "lib") are in your class path.
  3. If you are going to use the OpenGL-related features of OSM2World, make sure that the native JOGL files for your platform are accessible when running your program. The files are in the lib/jogl/ directory. For a 64 bit Linux system, for example, you would call your program with a VM parameter like -Djava.library.path="lib/jogl/linux-amd64.

Hello OSM2World

This code snippet demonstrates the use of the ConversionFacade class.

List<Target<?>> targets = new ArrayList<>();
targets.add(new POVRayTarget(out));            // output to POVRay
targets.add(new ObjTarget(outOBJ, outMTL));    // output to OBJ
targets.add(new JOGLTarget(gl, camera));       // output to OpenGL (uncached)
targets.add(new PrimitiveBuffer());            // cached output

ConversionFacade cf = new ConversionFacade();

// Results results =                           // if you want to work with some of the results directly
        osmFile, null, null, targets);