Mercurial > mxd2map
annotate src/java/de/intevation/mxd/reader/MXDReader.java @ 170:b9ee44070056
Manage projections and units.
author | vc11884admin@VC11884.win.bsh.de |
---|---|
date | Wed, 06 Jul 2011 15:17:05 +0200 |
parents | 2bf35f0babd0 |
children | 0bde090506f9 |
rev | line source |
---|---|
33
c51376f8e24c
Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents:
31
diff
changeset
|
1 package de.intevation.mxd.reader; |
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; |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
4 |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
5 import org.apache.log4j.Logger; |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
6 |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
7 import com.esri.arcgis.carto.ILayer; |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
8 import com.esri.arcgis.carto.IMap; |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
9 import com.esri.arcgis.carto.MapDocument; |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
10 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
|
11 import com.esri.arcgis.carto.GdbRasterCatalogLayer; |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
12 import com.esri.arcgis.carto.IFeatureRenderer; |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
13 import com.esri.arcgis.carto.SimpleRenderer; |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
14 import com.esri.arcgis.carto.ClassBreaksRenderer; |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
15 import com.esri.arcgis.carto.UniqueValueRenderer; |
148
2bf35f0babd0
Implemented new group layer functionality.
vc11884admin@VC11884.win.bsh.de
parents:
133
diff
changeset
|
16 import com.esri.arcgis.carto.GroupLayer; |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
17 |
27
e5fdc37f8f94
Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
18 import org.w3c.dom.Document; |
e5fdc37f8f94
Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
19 import org.w3c.dom.Element; |
e5fdc37f8f94
Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
20 |
33
c51376f8e24c
Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents:
31
diff
changeset
|
21 import de.intevation.mxd.ArcGISInitializer; |
c51376f8e24c
Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents:
31
diff
changeset
|
22 import de.intevation.mxd.utils.MapToXMLUtils; |
c51376f8e24c
Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents:
31
diff
changeset
|
23 |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
24 /** |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
25 * The MXD file reader. |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
26 * |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
27 * @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
|
28 */ |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
29 public class MXDReader |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
30 implements IReader { |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
31 /** |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
32 * The Logger. |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
33 */ |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
34 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
|
35 |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
36 /** |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
37 * Private member. |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
38 */ |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
39 private String filename = ""; |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
40 private ArcGISInitializer initializer = null; |
40
a1bc7220efe7
Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
36
diff
changeset
|
41 private MapToXMLUtils util; |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
42 private IMap map; |
118
39957898c694
Improved top level exception handling and logging.
Raimund Renkert <rrenkert@intevation.de>
parents:
103
diff
changeset
|
43 private int invalidLayerCount; |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
44 |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
45 public MXDReader() |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
46 throws IOException { |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
47 logger.debug("constructor()"); |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
48 initializer = new ArcGISInitializer(); |
40
a1bc7220efe7
Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
36
diff
changeset
|
49 util = new MapToXMLUtils(); |
118
39957898c694
Improved top level exception handling and logging.
Raimund Renkert <rrenkert@intevation.de>
parents:
103
diff
changeset
|
50 invalidLayerCount = 0; |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
51 } |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
52 |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
53 |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
54 /** |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
55 * Initialize the ArcGIS Objects. |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
56 */ |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
57 public boolean init() |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
58 throws IOException { |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
59 logger.debug("init()"); |
103
163d474165b0
Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents:
74
diff
changeset
|
60 if(!initializer.initArcGIS()) { |
163d474165b0
Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents:
74
diff
changeset
|
61 return false; |
163d474165b0
Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents:
74
diff
changeset
|
62 } |
163d474165b0
Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents:
74
diff
changeset
|
63 if(!initializer.initArcGISLicenses()) { |
163d474165b0
Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents:
74
diff
changeset
|
64 return false; |
163d474165b0
Added check for ArcGISDesktop environment.
Raimund Renkert <rrenkert@intevation.de>
parents:
74
diff
changeset
|
65 } |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
66 return true; |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
67 } |
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 /** |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
70 * Shutdown the ArcGIS Objects. |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
71 */ |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
72 public boolean shutdown() |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
73 throws IOException { |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
74 logger.debug("shutdown()"); |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
75 if(initializer == null) { |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
76 throw new IOException("Faild to shutdown!"); |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
77 } |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
78 else { |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
79 initializer.shutdownArcGIS(); |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
80 return true; |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
81 } |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
82 } |
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 * Set the path and filename to the MXD-File. |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
86 */ |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
87 public void setFilename(String name) { |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
88 logger.debug("setFilename()"); |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
89 filename = name; |
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 |
27
e5fdc37f8f94
Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
92 |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
93 private void openMapDocument() |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
94 throws IOException { |
27
e5fdc37f8f94
Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
95 MapDocument m = new MapDocument(); |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
96 if(!m.isMapDocument(filename)) { |
27
e5fdc37f8f94
Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
97 throw new IOException(filename + " is not a map!"); |
e5fdc37f8f94
Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
98 } |
e5fdc37f8f94
Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
99 m.open(filename, null); |
e5fdc37f8f94
Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
100 map = m.getMap(0); |
e5fdc37f8f94
Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
101 } |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
102 |
25
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 * Read the MXD file content. |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
105 */ |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
106 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
|
107 throws Exception { |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
108 logger.debug("read()"); |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
109 if(filename == "") { |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
110 throw new IOException("Please set filename!"); |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
111 } |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
112 else { |
40
a1bc7220efe7
Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
36
diff
changeset
|
113 util.addFilename(filename); |
27
e5fdc37f8f94
Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
114 openMapDocument(); |
40
a1bc7220efe7
Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
36
diff
changeset
|
115 MapReader mreader; |
a1bc7220efe7
Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
36
diff
changeset
|
116 try { |
a1bc7220efe7
Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
36
diff
changeset
|
117 mreader = new MapReader (map); |
a1bc7220efe7
Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
36
diff
changeset
|
118 mreader.setUtil(util); |
a1bc7220efe7
Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
36
diff
changeset
|
119 mreader.read(); |
a1bc7220efe7
Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
36
diff
changeset
|
120 |
a1bc7220efe7
Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
36
diff
changeset
|
121 } |
a1bc7220efe7
Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
36
diff
changeset
|
122 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
|
123 throw e; |
40
a1bc7220efe7
Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
36
diff
changeset
|
124 } |
27
e5fdc37f8f94
Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
125 |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
126 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
|
127 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
|
128 try { |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
129 if (layer instanceof FeatureLayer) { |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
130 FeatureLayerReader lr = new FeatureLayerReader(layer); |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
131 lr.setUtil(util); |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
132 Element layerElement = lr.read(); |
133
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
121
diff
changeset
|
133 if (layerElement == null) { |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
121
diff
changeset
|
134 continue; |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
121
diff
changeset
|
135 } |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
136 IFeatureRenderer renderer = |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
137 ((FeatureLayer)layer).getRenderer(); |
27
e5fdc37f8f94
Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
138 IRendererReader rreader; |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
139 if(renderer instanceof SimpleRenderer) { |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
140 rreader = new SimpleRendererReader(renderer); |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
30
diff
changeset
|
141 rreader.setParent(layerElement); |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
30
diff
changeset
|
142 rreader.setUtil(util); |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
143 rreader.read(); |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
144 } |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
145 else if(renderer instanceof ClassBreaksRenderer) { |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
146 rreader = new ClassBreakRendererReader(renderer); |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
30
diff
changeset
|
147 rreader.setParent(layerElement); |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
30
diff
changeset
|
148 rreader.setUtil(util); |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
149 rreader.read(); |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
150 } |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
151 else if(renderer instanceof UniqueValueRenderer) { |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
152 rreader = new UniqueValueRendererReader(renderer); |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
30
diff
changeset
|
153 rreader.setParent(layerElement); |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
30
diff
changeset
|
154 rreader.setUtil(util); |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
155 rreader.read(); |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
156 } |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
157 else{ |
69
b41fcf268827
Removed all "System.out" outputs.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
158 logger.debug("Not a known renderer type " + |
b41fcf268827
Removed all "System.out" outputs.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
159 renderer.getClass().toString()); |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
160 } |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
161 } |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
162 else if(layer instanceof GdbRasterCatalogLayer) { |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
163 GdbRasterCatalogLayerReader gclr = |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
164 new GdbRasterCatalogLayerReader(layer); |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
165 gclr.setUtil(util); |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
166 Element layerElement = gclr.read(); |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
167 IFeatureRenderer renderer = |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
168 ((GdbRasterCatalogLayer)layer).getRenderer(); |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
169 IRendererReader rreader; |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
170 if(renderer instanceof SimpleRenderer) { |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
171 rreader = new SimpleRendererReader(renderer); |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
172 rreader.setParent(layerElement); |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
173 rreader.setUtil(util); |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
174 rreader.read(); |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
175 } |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
176 else if(renderer instanceof ClassBreaksRenderer) { |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
177 rreader = new ClassBreakRendererReader(renderer); |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
178 rreader.setParent(layerElement); |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
179 rreader.setUtil(util); |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
180 rreader.read(); |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
181 } |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
182 else if(renderer instanceof UniqueValueRenderer) { |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
183 rreader = new UniqueValueRendererReader(renderer); |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
184 rreader.setParent(layerElement); |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
185 rreader.setUtil(util); |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
186 rreader.read(); |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
187 } |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
188 else { |
69
b41fcf268827
Removed all "System.out" outputs.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
189 logger.debug("Not a known renderer type " + |
b41fcf268827
Removed all "System.out" outputs.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
190 renderer.getClass().toString()); |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
191 } |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
192 } |
148
2bf35f0babd0
Implemented new group layer functionality.
vc11884admin@VC11884.win.bsh.de
parents:
133
diff
changeset
|
193 else if(layer instanceof GroupLayer) { |
2bf35f0babd0
Implemented new group layer functionality.
vc11884admin@VC11884.win.bsh.de
parents:
133
diff
changeset
|
194 GroupLayerReader gl = new GroupLayerReader(layer); |
2bf35f0babd0
Implemented new group layer functionality.
vc11884admin@VC11884.win.bsh.de
parents:
133
diff
changeset
|
195 gl.setUtil(util); |
2bf35f0babd0
Implemented new group layer functionality.
vc11884admin@VC11884.win.bsh.de
parents:
133
diff
changeset
|
196 Element layerElement = gl.read(); |
2bf35f0babd0
Implemented new group layer functionality.
vc11884admin@VC11884.win.bsh.de
parents:
133
diff
changeset
|
197 if(layerElement == null) { |
2bf35f0babd0
Implemented new group layer functionality.
vc11884admin@VC11884.win.bsh.de
parents:
133
diff
changeset
|
198 throw new IOException ("Error reading grouplayer."); |
2bf35f0babd0
Implemented new group layer functionality.
vc11884admin@VC11884.win.bsh.de
parents:
133
diff
changeset
|
199 } |
2bf35f0babd0
Implemented new group layer functionality.
vc11884admin@VC11884.win.bsh.de
parents:
133
diff
changeset
|
200 } |
2bf35f0babd0
Implemented new group layer functionality.
vc11884admin@VC11884.win.bsh.de
parents:
133
diff
changeset
|
201 else { |
2bf35f0babd0
Implemented new group layer functionality.
vc11884admin@VC11884.win.bsh.de
parents:
133
diff
changeset
|
202 logger.info( |
2bf35f0babd0
Implemented new group layer functionality.
vc11884admin@VC11884.win.bsh.de
parents:
133
diff
changeset
|
203 "Layertype not known: " + |
2bf35f0babd0
Implemented new group layer functionality.
vc11884admin@VC11884.win.bsh.de
parents:
133
diff
changeset
|
204 layer.getClass().toString()); |
2bf35f0babd0
Implemented new group layer functionality.
vc11884admin@VC11884.win.bsh.de
parents:
133
diff
changeset
|
205 } |
27
e5fdc37f8f94
Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
206 } |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
207 catch(Exception e) { |
118
39957898c694
Improved top level exception handling and logging.
Raimund Renkert <rrenkert@intevation.de>
parents:
103
diff
changeset
|
208 invalidLayerCount++; |
133
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
121
diff
changeset
|
209 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
|
210 invalidLayerCount == map.getLayerCount()) { |
39957898c694
Improved top level exception handling and logging.
Raimund Renkert <rrenkert@intevation.de>
parents:
103
diff
changeset
|
211 throw new IOException( |
39957898c694
Improved top level exception handling and logging.
Raimund Renkert <rrenkert@intevation.de>
parents:
103
diff
changeset
|
212 "No valid layer in MXD file." + |
39957898c694
Improved top level exception handling and logging.
Raimund Renkert <rrenkert@intevation.de>
parents:
103
diff
changeset
|
213 " Aborting."); |
39957898c694
Improved top level exception handling and logging.
Raimund Renkert <rrenkert@intevation.de>
parents:
103
diff
changeset
|
214 } |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
215 } |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
216 } |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
217 } |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
218 return true; |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
219 } |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
220 |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
221 /** |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
222 * Get the root DOM document. |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
223 */ |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
224 public Document getMapDocument() { |
27
e5fdc37f8f94
Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
225 logger.debug("getMapDocument()"); |
40
a1bc7220efe7
Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
36
diff
changeset
|
226 return util.getDocument(); |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
227 } |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
228 } |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
229 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |