Mercurial > mxd2map
annotate src/java/de/intevation/mxd/reader/GdbRasterCatalogLayerReader.java @ 187:ea7858d75459
* website/img/inmenulogo.png ,website/img/logo_single.png
,website/img/logo_single_100.png ,website/img/logo_wide.png: Added
new Logo for MXD2map
author | Stephan Holl <stephan.holl@intevation.de> |
---|---|
date | Wed, 20 Jul 2011 14:06:07 +0200 |
parents | 0bde090506f9 |
children | df4e0946ef02 |
rev | line source |
---|---|
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.mxd.reader; |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
2 |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
3 import org.apache.log4j.Logger; |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
4 |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
5 import com.esri.arcgis.carto.ILayer; |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
6 import com.esri.arcgis.carto.GdbRasterCatalogLayer; |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
7 |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
8 import org.w3c.dom.Element; |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
9 import java.io.IOException; |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
10 import de.intevation.mxd.utils.MapToXMLUtils; |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
11 |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
12 /** |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
36
diff
changeset
|
13 * Reads Layer information. |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
14 * |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
15 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
16 */ |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
36
diff
changeset
|
17 public class GdbRasterCatalogLayerReader |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
36
diff
changeset
|
18 implements ILayerReader { |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
19 |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
20 /** |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
21 * The logger. |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
22 */ |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
23 private static final Logger logger = |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
24 Logger.getLogger(GdbRasterCatalogLayerReader.class); |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
25 |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
26 /** |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
27 * Privte member. |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
28 */ |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
29 private GdbRasterCatalogLayer layer; |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
30 private MapToXMLUtils util; |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
31 |
181 | 32 /** |
33 * Constructor with layer. | |
34 * | |
35 * @param layer The ArcGIS layer object. | |
36 */ | |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
37 public GdbRasterCatalogLayerReader(ILayer layer) |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
38 throws Exception { |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
36
diff
changeset
|
39 if(layer instanceof GdbRasterCatalogLayer) { |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
40 this.layer = (GdbRasterCatalogLayer)layer; |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
36
diff
changeset
|
41 } |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
36
diff
changeset
|
42 else { |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
43 throw new Exception("Not an instance of GdbRastaCatalogLayer: " + |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
44 layer.getClass().toString()); |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
36
diff
changeset
|
45 } |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
46 } |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
47 |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
48 /** |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
49 * Setter for XML document helper. |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
50 * |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
51 * @param util The helper for storing map information. |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
52 */ |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
36
diff
changeset
|
53 public void setUtil(MapToXMLUtils util) { |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
54 this.util = util; |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
55 } |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
56 |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
57 /** |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
58 * Reads the Layer content. |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
59 * |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
60 * @return The layer XML element. |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
61 */ |
118
39957898c694
Improved top level exception handling and logging.
Raimund Renkert <rrenkert@intevation.de>
parents:
117
diff
changeset
|
62 public Element read() |
39957898c694
Improved top level exception handling and logging.
Raimund Renkert <rrenkert@intevation.de>
parents:
117
diff
changeset
|
63 throws IOException { |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
64 logger.debug("read()"); |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
65 |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
66 Element layerElement; |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
67 try { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
68 layerElement = util.addLayer(); |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
69 } |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
70 catch(Exception e) { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
71 logger.error( |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
72 "Could not create DOM element for layer." + |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
73 "Stopped reading layer."); |
118
39957898c694
Improved top level exception handling and logging.
Raimund Renkert <rrenkert@intevation.de>
parents:
117
diff
changeset
|
74 throw new IOException( |
135
a4ab239509f1
Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents:
118
diff
changeset
|
75 this.getClass().toString() + |
118
39957898c694
Improved top level exception handling and logging.
Raimund Renkert <rrenkert@intevation.de>
parents:
117
diff
changeset
|
76 "Error creating dom element"); |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
77 } |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
78 |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
79 try { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
80 layerElement.setAttribute("name", layer.getName()); |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
81 } |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
82 catch(IOException ioe) { |
135
a4ab239509f1
Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents:
118
diff
changeset
|
83 logger.warn("Could not read layer name. Stopped reading layer."); |
a4ab239509f1
Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents:
118
diff
changeset
|
84 throw new IOException("Error reading layer name."); |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
85 } |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
86 |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
87 try { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
88 layerElement.setAttribute("min_scale", |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
89 String.valueOf(layer.getMinimumScale())); |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
90 } |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
91 catch(IOException ioe) { |
135
a4ab239509f1
Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents:
118
diff
changeset
|
92 logger.warn("Could not read minimum layer scale."); |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
93 } |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
94 |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
95 try { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
96 layerElement.setAttribute("max_scale", |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
97 String.valueOf(layer.getMaximumScale())); |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
98 } |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
99 catch(IOException ioe) { |
135
a4ab239509f1
Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents:
118
diff
changeset
|
100 logger.warn("Could not read maximum layer scale."); |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
101 } |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
102 |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
103 try { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
104 if(layer.isVisible()) { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
105 layerElement.setAttribute("status", "on"); |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
106 } |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
107 else { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
108 layerElement.setAttribute("status", "off"); |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
109 } |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
110 } |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
111 catch(IOException ioe) { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
112 logger.warn( |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
113 "Could not read layer status." + |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
114 " Setting layer status to \"on\""); |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
115 layerElement.setAttribute("status", "on"); |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
116 } |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
117 |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
118 try { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
119 layerElement.setAttribute("definition_query", |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
120 layer.getDefinitionExpression()); |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
121 } |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
122 catch(IOException ioe) { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
123 logger.warn( |
135
a4ab239509f1
Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents:
118
diff
changeset
|
124 "Could not read layer definition query."); |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
125 } |
36
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
126 return layerElement; |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
127 } |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
128 } |
472aa36d0e01
Added a new layer reader and symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
129 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |