OSM2World/Using OSM2World as a library
Jump to navigation
Jump to search
This documentation page is still under construction. |
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!
Basics
Preparations
- Download OSM2World. The archive contains OSM2World and all libraries it depends on.
- Make sure that OSM2World.jar and its dependencies (the .jar files in the subdirectories of "lib") are in your class path.
- 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 cf.createRepresentations( osmFile, null, null, targets);