annotate src/java/de/intevation/mxd/reader/MXDReader.java @ 261:efab4d62ad3c

Replace umlauts in layer title.
author raimund renkert <raimund.renkert@intevation.de>
date Tue, 16 Aug 2011 16:56:26 +0200
parents 276f63c86f1c
children 2cb2d8eb56ed
rev   line source
243
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
1 /*
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
2 * Copyright (c) 2011 by Intevation GmbH, Germany <info@intevation.de>
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
3 *
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
4 * This file is part of MXD2map.
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
5 *
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
6 * This program is free software under the LGPL (>=v2.1)
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
7 * Read the file LICENCE.txt coming with the software for details
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
8 * or visit http://www.gnu.org/licenses/ if it does not exist.
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
9 *
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
10 * MXD2map has been developed on behalf of the
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
11 * Bundesamt fuer Seeschifffahrt und Hydrographie (BSH) in Hamburg
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
12 * by Intevation GmbH.
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
13 *
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
14 * Authors:
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
15 * Raimund Renkert <raimund.renkert@intevation.de>
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
16 * Bjoern Schilberg <bjoern.schilberg@intevation.de>
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
17 * Stephan Holl <stephan.holl@intevation.de>
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
18 */
df4e0946ef02 Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents: 181
diff changeset
19
33
c51376f8e24c Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents: 31
diff changeset
20 package de.intevation.mxd.reader;
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
21
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
22 import java.io.IOException;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
23
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
24 import org.apache.log4j.Logger;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
26 import com.esri.arcgis.carto.ILayer;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
27 import com.esri.arcgis.carto.IMap;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
28 import com.esri.arcgis.carto.MapDocument;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
29 import com.esri.arcgis.carto.FeatureLayer;
36
472aa36d0e01 Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
30 import com.esri.arcgis.carto.GdbRasterCatalogLayer;
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
31 import com.esri.arcgis.carto.IFeatureRenderer;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
32 import com.esri.arcgis.carto.SimpleRenderer;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
33 import com.esri.arcgis.carto.ClassBreaksRenderer;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
34 import com.esri.arcgis.carto.UniqueValueRenderer;
148
2bf35f0babd0 Implemented new group layer functionality.
vc11884admin@VC11884.win.bsh.de
parents: 133
diff changeset
35 import com.esri.arcgis.carto.GroupLayer;
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
36
27
e5fdc37f8f94 Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
37 import org.w3c.dom.Document;
e5fdc37f8f94 Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
38 import org.w3c.dom.Element;
e5fdc37f8f94 Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
39
33
c51376f8e24c Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents: 31
diff changeset
40 import de.intevation.mxd.ArcGISInitializer;
c51376f8e24c Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents: 31
diff changeset
41 import de.intevation.mxd.utils.MapToXMLUtils;
c51376f8e24c Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents: 31
diff changeset
42
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
43 /**
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
44 * The MXD file reader.
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
45 *
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
46 * @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
47 */
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
48 public class MXDReader
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
49 implements IReader {
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
50 /**
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
51 * The Logger.
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
52 */
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
53 private static final Logger logger = Logger.getLogger(MXDReader.class);
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
54
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
55 /**
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
56 * Private member.
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
57 */
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
58 private String filename = "";
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
59 private ArcGISInitializer initializer = null;
40
a1bc7220efe7 Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 36
diff changeset
60 private MapToXMLUtils util;
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
61 private IMap map;
118
39957898c694 Improved top level exception handling and logging.
Raimund Renkert <rrenkert@intevation.de>
parents: 103
diff changeset
62 private int invalidLayerCount;
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
63
181
0bde090506f9 Added comments.
Raimund Renkert <rrenkert@intevation.de>
parents: 148
diff changeset
64 /**
0bde090506f9 Added comments.
Raimund Renkert <rrenkert@intevation.de>
parents: 148
diff changeset
65 * Default constructor.
0bde090506f9 Added comments.
Raimund Renkert <rrenkert@intevation.de>
parents: 148
diff changeset
66 */
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
67 public MXDReader()
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
68 throws IOException {
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
69 logger.debug("constructor()");
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
70 initializer = new ArcGISInitializer();
40
a1bc7220efe7 Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 36
diff changeset
71 util = new MapToXMLUtils();
118
39957898c694 Improved top level exception handling and logging.
Raimund Renkert <rrenkert@intevation.de>
parents: 103
diff changeset
72 invalidLayerCount = 0;
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
73 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
74
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
75
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
76 /**
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
77 * Initialize the ArcGIS Objects.
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
78 */
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
79 public boolean init()
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
80 throws IOException {
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
81 logger.debug("init()");
103
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 74
diff changeset
82 if(!initializer.initArcGIS()) {
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 74
diff changeset
83 return false;
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 74
diff changeset
84 }
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 74
diff changeset
85 if(!initializer.initArcGISLicenses()) {
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 74
diff changeset
86 return false;
163d474165b0 Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents: 74
diff changeset
87 }
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
88 return true;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
89 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
90
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
91 /**
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
92 * Shutdown the ArcGIS Objects.
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: 40
diff changeset
94 public boolean shutdown()
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
95 throws IOException {
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
96 logger.debug("shutdown()");
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
97 if(initializer == null) {
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
98 throw new IOException("Faild to shutdown!");
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
99 }
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
100 else {
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
101 initializer.shutdownArcGIS();
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
102 return true;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
103 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
104 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
105
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
106 /**
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
107 * Set the path and filename to the MXD-File.
181
0bde090506f9 Added comments.
Raimund Renkert <rrenkert@intevation.de>
parents: 148
diff changeset
108 *
0bde090506f9 Added comments.
Raimund Renkert <rrenkert@intevation.de>
parents: 148
diff changeset
109 * @param name The MXD filename.
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
110 */
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
111 public void setFilename(String name) {
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
112 logger.debug("setFilename()");
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
113 filename = name;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
114 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
115
181
0bde090506f9 Added comments.
Raimund Renkert <rrenkert@intevation.de>
parents: 148
diff changeset
116 /**
0bde090506f9 Added comments.
Raimund Renkert <rrenkert@intevation.de>
parents: 148
diff changeset
117 * Get the map document from MXD.
0bde090506f9 Added comments.
Raimund Renkert <rrenkert@intevation.de>
parents: 148
diff changeset
118 */
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
119 private void openMapDocument()
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
120 throws IOException {
27
e5fdc37f8f94 Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
121 MapDocument m = new MapDocument();
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
122 if(!m.isMapDocument(filename)) {
27
e5fdc37f8f94 Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
123 throw new IOException(filename + " is not a map!");
e5fdc37f8f94 Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
124 }
e5fdc37f8f94 Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
125 m.open(filename, null);
e5fdc37f8f94 Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
126 map = m.getMap(0);
e5fdc37f8f94 Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
127 }
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
128
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
129 /**
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
130 * Read the MXD file content.
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
131 */
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
132 public boolean read()
121
9f74f4d36822 Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 118
diff changeset
133 throws Exception {
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
134 logger.debug("read()");
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
135 if(filename == "") {
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
136 throw new IOException("Please set filename!");
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
137 }
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
138 else {
40
a1bc7220efe7 Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 36
diff changeset
139 util.addFilename(filename);
27
e5fdc37f8f94 Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
140 openMapDocument();
40
a1bc7220efe7 Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 36
diff changeset
141 MapReader mreader;
a1bc7220efe7 Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 36
diff changeset
142 try {
a1bc7220efe7 Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 36
diff changeset
143 mreader = new MapReader (map);
a1bc7220efe7 Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 36
diff changeset
144 mreader.setUtil(util);
a1bc7220efe7 Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 36
diff changeset
145 mreader.read();
a1bc7220efe7 Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 36
diff changeset
146
a1bc7220efe7 Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 36
diff changeset
147 }
a1bc7220efe7 Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 36
diff changeset
148 catch(Exception e) {
121
9f74f4d36822 Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 118
diff changeset
149 throw e;
40
a1bc7220efe7 Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 36
diff changeset
150 }
27
e5fdc37f8f94 Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
151
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
152 for(int i = 0; i < map.getLayerCount();i++) {
27
e5fdc37f8f94 Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
153 ILayer layer = map.getLayer(i);
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
154 try {
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
155 if (layer instanceof FeatureLayer) {
36
472aa36d0e01 Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
156 FeatureLayerReader lr = new FeatureLayerReader(layer);
472aa36d0e01 Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
157 lr.setUtil(util);
472aa36d0e01 Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
158 Element layerElement = lr.read();
133
6b80d2c7536e Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents: 121
diff changeset
159 if (layerElement == null) {
6b80d2c7536e Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents: 121
diff changeset
160 continue;
6b80d2c7536e Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents: 121
diff changeset
161 }
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
162 IFeatureRenderer renderer =
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
163 ((FeatureLayer)layer).getRenderer();
27
e5fdc37f8f94 Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
164 IRendererReader rreader;
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
165 if(renderer instanceof SimpleRenderer) {
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
166 rreader = new SimpleRendererReader(renderer);
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 30
diff changeset
167 rreader.setParent(layerElement);
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 30
diff changeset
168 rreader.setUtil(util);
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
169 rreader.read();
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
170 }
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
171 else if(renderer instanceof ClassBreaksRenderer) {
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
172 rreader = new ClassBreakRendererReader(renderer);
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 30
diff changeset
173 rreader.setParent(layerElement);
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 30
diff changeset
174 rreader.setUtil(util);
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
175 rreader.read();
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
176 }
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
177 else if(renderer instanceof UniqueValueRenderer) {
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
178 rreader = new UniqueValueRendererReader(renderer);
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 30
diff changeset
179 rreader.setParent(layerElement);
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 30
diff changeset
180 rreader.setUtil(util);
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
181 rreader.read();
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
182 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
183 else{
69
b41fcf268827 Removed all "System.out" outputs.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
184 logger.debug("Not a known renderer type " +
b41fcf268827 Removed all "System.out" outputs.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
185 renderer.getClass().toString());
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
186 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
187 }
36
472aa36d0e01 Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
188 else if(layer instanceof GdbRasterCatalogLayer) {
472aa36d0e01 Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
189 GdbRasterCatalogLayerReader gclr =
472aa36d0e01 Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
190 new GdbRasterCatalogLayerReader(layer);
472aa36d0e01 Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
191 gclr.setUtil(util);
472aa36d0e01 Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
192 Element layerElement = gclr.read();
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
193 IFeatureRenderer renderer =
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
194 ((GdbRasterCatalogLayer)layer).getRenderer();
36
472aa36d0e01 Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
195 IRendererReader rreader;
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
196 if(renderer instanceof SimpleRenderer) {
36
472aa36d0e01 Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
197 rreader = new SimpleRendererReader(renderer);
472aa36d0e01 Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
198 rreader.setParent(layerElement);
472aa36d0e01 Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
199 rreader.setUtil(util);
472aa36d0e01 Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
200 rreader.read();
472aa36d0e01 Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
201 }
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
202 else if(renderer instanceof ClassBreaksRenderer) {
36
472aa36d0e01 Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
203 rreader = new ClassBreakRendererReader(renderer);
472aa36d0e01 Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
204 rreader.setParent(layerElement);
472aa36d0e01 Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
205 rreader.setUtil(util);
472aa36d0e01 Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
206 rreader.read();
472aa36d0e01 Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
207 }
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
208 else if(renderer instanceof UniqueValueRenderer) {
36
472aa36d0e01 Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
209 rreader = new UniqueValueRendererReader(renderer);
472aa36d0e01 Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
210 rreader.setParent(layerElement);
472aa36d0e01 Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
211 rreader.setUtil(util);
472aa36d0e01 Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
212 rreader.read();
472aa36d0e01 Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
213 }
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
214 else {
69
b41fcf268827 Removed all "System.out" outputs.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
215 logger.debug("Not a known renderer type " +
b41fcf268827 Removed all "System.out" outputs.
Raimund Renkert <rrenkert@intevation.de>
parents: 43
diff changeset
216 renderer.getClass().toString());
36
472aa36d0e01 Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
217 }
472aa36d0e01 Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
218 }
148
2bf35f0babd0 Implemented new group layer functionality.
vc11884admin@VC11884.win.bsh.de
parents: 133
diff changeset
219 else if(layer instanceof GroupLayer) {
2bf35f0babd0 Implemented new group layer functionality.
vc11884admin@VC11884.win.bsh.de
parents: 133
diff changeset
220 GroupLayerReader gl = new GroupLayerReader(layer);
2bf35f0babd0 Implemented new group layer functionality.
vc11884admin@VC11884.win.bsh.de
parents: 133
diff changeset
221 gl.setUtil(util);
244
276f63c86f1c Refactored group layer handling and "wms_title" metadata.
raimund renkert <raimund.renkert@intevation.de>
parents: 243
diff changeset
222 Element layerElement = gl.read("");
148
2bf35f0babd0 Implemented new group layer functionality.
vc11884admin@VC11884.win.bsh.de
parents: 133
diff changeset
223 if(layerElement == null) {
2bf35f0babd0 Implemented new group layer functionality.
vc11884admin@VC11884.win.bsh.de
parents: 133
diff changeset
224 throw new IOException ("Error reading grouplayer.");
2bf35f0babd0 Implemented new group layer functionality.
vc11884admin@VC11884.win.bsh.de
parents: 133
diff changeset
225 }
2bf35f0babd0 Implemented new group layer functionality.
vc11884admin@VC11884.win.bsh.de
parents: 133
diff changeset
226 }
2bf35f0babd0 Implemented new group layer functionality.
vc11884admin@VC11884.win.bsh.de
parents: 133
diff changeset
227 else {
2bf35f0babd0 Implemented new group layer functionality.
vc11884admin@VC11884.win.bsh.de
parents: 133
diff changeset
228 logger.info(
2bf35f0babd0 Implemented new group layer functionality.
vc11884admin@VC11884.win.bsh.de
parents: 133
diff changeset
229 "Layertype not known: " +
2bf35f0babd0 Implemented new group layer functionality.
vc11884admin@VC11884.win.bsh.de
parents: 133
diff changeset
230 layer.getClass().toString());
2bf35f0babd0 Implemented new group layer functionality.
vc11884admin@VC11884.win.bsh.de
parents: 133
diff changeset
231 }
27
e5fdc37f8f94 Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
232 }
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
233 catch(Exception e) {
118
39957898c694 Improved top level exception handling and logging.
Raimund Renkert <rrenkert@intevation.de>
parents: 103
diff changeset
234 invalidLayerCount++;
133
6b80d2c7536e Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents: 121
diff changeset
235 if(i == 0 && (i + 1) == map.getLayerCount() ||
118
39957898c694 Improved top level exception handling and logging.
Raimund Renkert <rrenkert@intevation.de>
parents: 103
diff changeset
236 invalidLayerCount == map.getLayerCount()) {
39957898c694 Improved top level exception handling and logging.
Raimund Renkert <rrenkert@intevation.de>
parents: 103
diff changeset
237 throw new IOException(
39957898c694 Improved top level exception handling and logging.
Raimund Renkert <rrenkert@intevation.de>
parents: 103
diff changeset
238 "No valid layer in MXD file." +
39957898c694 Improved top level exception handling and logging.
Raimund Renkert <rrenkert@intevation.de>
parents: 103
diff changeset
239 " Aborting.");
39957898c694 Improved top level exception handling and logging.
Raimund Renkert <rrenkert@intevation.de>
parents: 103
diff changeset
240 }
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
241 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
242 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
243 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
244 return true;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
245 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
246
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
247 /**
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
248 * Get the root DOM document.
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
249 */
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
250 public Document getMapDocument() {
27
e5fdc37f8f94 Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
251 logger.debug("getMapDocument()");
40
a1bc7220efe7 Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 36
diff changeset
252 return util.getDocument();
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
253 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
254 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
255 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)