view src/java/de/intevation/mxd/ArcGISInitializer.java @ 54:2cbf8bdf20b2

* doku/funktionsweise/Makefile, doku/funktionsweise/funktionsweise-MXD-konverter.svg: New. Added a schema how the converter works
author Stephan Holl <stephan.holl@intevation.de>
date Mon, 16 May 2011 16:20:13 +0200
parents ef7ca23c4233
children 163d474165b0
line wrap: on
line source
package de.intevation.mxd;

import java.io.IOException;

import com.esri.arcgis.system.AoInitialize;
import com.esri.arcgis.system.EngineInitializer;
import com.esri.arcgis.system.esriLicenseProductCode;
import com.esri.arcgis.system.esriLicenseStatus;

/**
 * Initializes the ArcGIS Engine and Objects.
 *
 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
 */
public class ArcGISInitializer {

    /**
     * Private member.
     */
    private AoInitialize    aoInit;
    private String          engineInstallDir = "";


    /**
     * Init ArcGIS Java Objects.
     */
    public boolean initArcGIS ()
    throws IOException {
        EngineInitializer.initializeEngine();
        aoInit              = new AoInitialize();
        engineInstallDir    = System.getenv("AGSENGINEJAVA");
        return true;
    }

    /**
     * Init ArcGIS License.
     */
    public void initArcGISLicenses()
    throws IOException {
        if(aoInit.isProductCodeAvailable
           (esriLicenseProductCode.esriLicenseProductCodeEngine) ==
           esriLicenseStatus.esriLicenseAvailable) {
           aoInit.initialize
               (esriLicenseProductCode.esriLicenseProductCodeEngine);
        }
        else if (aoInit.isProductCodeAvailable
                 (esriLicenseProductCode.esriLicenseProductCodeArcView) ==
                 esriLicenseStatus.esriLicenseAvailable) {
                 aoInit.initialize
                     (esriLicenseProductCode.esriLicenseProductCodeArcView);
        }
        else {
            System.err.println("Engine Runtime or ArcView" +
                " license not initialized.");
            System.err.println("Exiting application.");
            System.exit(-1);
        }
    }

    /**
     * Shutdown the ArcGIS Objects.
     */
    public boolean shutdownArcGIS()
    throws IOException {
        if(aoInit != null) {
            aoInit.shutdown();
            return true;
        }
        else {
            return false;
        }
    }

    /**
     * Get the ArcGIS Engine Directory.
     */
    public String getEngineDirectory()
    throws Exception {
        if(engineInstallDir == "") {
            throw new Exception("Call initArcGIS() first!");
        }
        else {
            return engineInstallDir;
        }
    }
}
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)