Mercurial > mxd2map
comparison src/java/de/intevation/mxd/ArcGISInitializer.java @ 25:cbd67b1100d8
Initial commit of the first prototype.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Fri, 08 Apr 2011 11:47:59 +0200 |
parents | |
children | c51376f8e24c |
comparison
equal
deleted
inserted
replaced
24:c0060abb7457 | 25:cbd67b1100d8 |
---|---|
1 //package de.intevation.mxd; | |
2 | |
3 import java.io.IOException; | |
4 | |
5 import com.esri.arcgis.system.AoInitialize; | |
6 import com.esri.arcgis.system.EngineInitializer; | |
7 import com.esri.arcgis.system.esriLicenseProductCode; | |
8 import com.esri.arcgis.system.esriLicenseStatus; | |
9 | |
10 /** | |
11 * Initializes the ArcGIS Engine and Objects. | |
12 * | |
13 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> | |
14 */ | |
15 public class ArcGISInitializer{ | |
16 | |
17 //Member | |
18 private AoInitialize aoInit; | |
19 private String engineInstallDir = ""; | |
20 | |
21 | |
22 //Methods | |
23 /** | |
24 * Init ArcGIS Java Objects. | |
25 */ | |
26 public boolean initArcGIS () throws IOException{ | |
27 EngineInitializer.initializeEngine(); | |
28 aoInit = new AoInitialize(); | |
29 engineInstallDir = System.getenv("AGSENGINEJAVA"); | |
30 return true; | |
31 } | |
32 | |
33 /** | |
34 * Init ArcGIS License. | |
35 */ | |
36 public void initArcGISLicenses() throws IOException{ | |
37 if(aoInit.isProductCodeAvailable | |
38 (esriLicenseProductCode.esriLicenseProductCodeEngine) == | |
39 esriLicenseStatus.esriLicenseAvailable){ | |
40 aoInit.initialize | |
41 (esriLicenseProductCode.esriLicenseProductCodeEngine); | |
42 } | |
43 else if (aoInit.isProductCodeAvailable | |
44 (esriLicenseProductCode.esriLicenseProductCodeArcView) == | |
45 esriLicenseStatus.esriLicenseAvailable){ | |
46 aoInit.initialize | |
47 (esriLicenseProductCode.esriLicenseProductCodeArcView); | |
48 } | |
49 else{ | |
50 System.err.println("Engine Runtime or ArcView license not initialized."); | |
51 System.err.println("Exiting application."); | |
52 System.exit(-1); | |
53 } | |
54 } | |
55 | |
56 /** | |
57 * Shutdown the ArcGIS Objects. | |
58 */ | |
59 public boolean shutdownArcGIS() throws IOException{ | |
60 if(aoInit != null){ | |
61 aoInit.shutdown(); | |
62 return true; | |
63 } | |
64 else{ | |
65 return false; | |
66 } | |
67 } | |
68 | |
69 /** | |
70 * Get the ArcGIS Engine Directory. | |
71 */ | |
72 public String getEngineDirectory() throws Exception{ | |
73 if(engineInstallDir == "") | |
74 throw new Exception("Call initArcGIS() first!"); | |
75 else | |
76 return engineInstallDir; | |
77 } | |
78 } |