WorldWind Android


The GeoPackageFragment class extends BasicGlobeFragment and overrides the createWorldWindow method. Here we use WorldWind’s LayerFactory to display the contents of a local OGC GeoPackage database. LayerFactory asynchronously reads the GeoPackage contents to configure a WorldWind layer, then notifies the application when it’s done.

package gov.nasa.worldwindx;
public class GeoPackageFragment extends BasicGlobeFragment {

     * Creates a new WorldWindow (GLSurfaceView) object with a GeoPackage Layer
     * @return The WorldWindow object containing the globe.
    public WorldWindow createWorldWindow() {
        // Let the super class (BasicGlobeFragment) do the creation
        WorldWindow wwd = super.createWorldWindow();

        // Unpack the tutorial GeoPackage asset to the Android application cache. GeoPackage relies on the Android
        // SQLite library which operates only on files in the local Android filesystem.
        File geoPackageFile = TutorialUtil.unpackAsset(this.getContext(), "geopackage_tutorial.gpkg");

        // Create a layer factory, WorldWind's general component for creating layers
        // from complex data sources.
        LayerFactory layerFactory = new LayerFactory();

        // Create an OGC GeoPackage layer to display a high resolution monochromatic image of Naval Air Station Oceana
        // in Virginia Beach, VA.
            geoPackageFile.getPath(), // file path on the local Android filesystem
            new LayerFactory.Callback() {
                public void creationSucceeded(LayerFactory factory, Layer layer) {
                    // Add the finished GeoPackage layer to the WorldWindow.
                    // Place the viewer directly over the GeoPackage image.
                    Log.i("gov.nasa.worldwind", "GeoPackage layer creation succeeded");

                public void creationFailed(LayerFactory factory, Layer layer, Throwable ex) {
                    // Something went wrong reading the GeoPackage.
                    Log.e("gov.nasa.worldwind", "GeoPackage layer creation failed", ex);

        return wwd;