annotate src/java/de/intevation/mxd/ArcGISInitializer.java @ 110:01cd6b736acd

* mapserver/mapfile/mxd.map: Added ows_enable_request-directive to allow OGC-services.
author Stephan Holl <stephan.holl@intevation.de>
date Tue, 14 Jun 2011 12:40:37 +0200
parents 163d474165b0
children 104af51a4717
rev   line source
33
c51376f8e24c Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents: 25
diff changeset
1 package de.intevation.mxd;
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
2
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
3 import java.io.IOException;
103
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
4 import java.io.File;
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
5
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
6 import org.apache.log4j.Logger;
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
7
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
8 import com.esri.arcgis.system.AoInitialize;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
9 import com.esri.arcgis.system.EngineInitializer;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
10 import com.esri.arcgis.system.esriLicenseProductCode;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
11 import com.esri.arcgis.system.esriLicenseStatus;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
12
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
13 /**
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
14 * Initializes the ArcGIS Engine and Objects.
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
15 *
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
16 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
17 */
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 33
diff changeset
18 public class ArcGISInitializer {
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
19
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 33
diff changeset
20 /**
103
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
21 * The Logger.
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
22 */
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
23 private static final Logger logger = Logger.getLogger(ArcGISInitializer.class);
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
24
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
25 /**
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 33
diff changeset
26 * Private member.
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 33
diff changeset
27 */
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
28 private AoInitialize aoInit;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
29 private String engineInstallDir = "";
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
30
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
31
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
32 /**
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
33 * Init ArcGIS Java Objects.
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
34 */
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 33
diff changeset
35 public boolean initArcGIS ()
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 33
diff changeset
36 throws IOException {
103
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
37 logger.debug("initArcGIS()");
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
38 EngineInitializer.initializeEngine();
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
39 aoInit = new AoInitialize();
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
40 engineInstallDir = System.getenv("AGSENGINEJAVA");
103
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
41 File installDir = new File(engineInstallDir);
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
42 if(!installDir.exists()) {
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
43 engineInstallDir = System.getenv("AGSDESKTOPJAVA");
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
44 installDir = new File(engineInstallDir);
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
45 if(!installDir.exists()) {
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
46 logger.error("Could not find ArcGIS Environment. \n" +
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
47 "AGSENGINEJAVA or AGSDESKTOPJAVA not set.");
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
48 return false;
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
49 }
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
50 }
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
51 else {
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
52 return true;
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
53 }
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
54 return true;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
55 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
56
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
57 /**
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
58 * Init ArcGIS License.
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
59 */
103
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
60 public boolean initArcGISLicenses()
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 33
diff changeset
61 throws IOException {
103
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
62 logger.debug("initArcGISLicenses()");
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
63 if(aoInit.isProductCodeAvailable
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
64 (esriLicenseProductCode.esriLicenseProductCodeEngine) ==
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 33
diff changeset
65 esriLicenseStatus.esriLicenseAvailable) {
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
66 aoInit.initialize
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
67 (esriLicenseProductCode.esriLicenseProductCodeEngine);
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
68 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
69 else if (aoInit.isProductCodeAvailable
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
70 (esriLicenseProductCode.esriLicenseProductCodeArcView) ==
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 33
diff changeset
71 esriLicenseStatus.esriLicenseAvailable) {
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
72 aoInit.initialize
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
73 (esriLicenseProductCode.esriLicenseProductCodeArcView);
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
74 }
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 33
diff changeset
75 else {
103
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
76 logger.error("Engine Runtime or ArcView" +
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
77 " license not initialized.\n" +
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
78 "Please install an ArcGIS product and set the" +
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
79 " PATH-variable correctly.");
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
80 return false;
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
81 }
103
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
82 return true;
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
83 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
84
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
85 /**
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
86 * Shutdown the ArcGIS Objects.
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
87 */
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 33
diff changeset
88 public boolean shutdownArcGIS()
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 33
diff changeset
89 throws IOException {
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 33
diff changeset
90 if(aoInit != null) {
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
91 aoInit.shutdown();
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
92 return true;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
93 }
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 33
diff changeset
94 else {
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
95 return false;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
96 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
97 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
98
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
99 /**
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
100 * Get the ArcGIS Engine Directory.
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
101 */
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 33
diff changeset
102 public String getEngineDirectory()
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 33
diff changeset
103 throws Exception {
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 33
diff changeset
104 if(engineInstallDir == "") {
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
105 throw new Exception("Call initArcGIS() first!");
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 33
diff changeset
106 }
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 33
diff changeset
107 else {
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
108 return engineInstallDir;
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 33
diff changeset
109 }
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
110 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
111 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)