comparison src/java/de/intevation/mxd/reader/GdbRasterCatalogLayerReader.java @ 117:6c3d880db7c5

Improved exception handling for layer reader.
author Raimund Renkert <rrenkert@intevation.de>
date Thu, 16 Jun 2011 12:05:34 +0200
parents 59e06c405a9a
children 39957898c694
comparison
equal deleted inserted replaced
116:c8a1361ddd38 117:6c3d880db7c5
4 4
5 import com.esri.arcgis.carto.ILayer; 5 import com.esri.arcgis.carto.ILayer;
6 import com.esri.arcgis.carto.GdbRasterCatalogLayer; 6 import com.esri.arcgis.carto.GdbRasterCatalogLayer;
7 7
8 import org.w3c.dom.Element; 8 import org.w3c.dom.Element;
9 9 import java.io.IOException;
10 import de.intevation.mxd.utils.MapToXMLUtils; 10 import de.intevation.mxd.utils.MapToXMLUtils;
11 11
12 /** 12 /**
13 * Reads Layer information. 13 * Reads Layer information.
14 * 14 *
53 /** 53 /**
54 * Reads the Layer content. 54 * Reads the Layer content.
55 * 55 *
56 * @return The layer XML element. 56 * @return The layer XML element.
57 */ 57 */
58 public Element read() 58 public Element read() {
59 throws Exception {
60 logger.debug("read()"); 59 logger.debug("read()");
61 Element layerElement = util.addLayer();
62 60
63 layerElement.setAttribute("name", layer.getName()); 61 Element layerElement;
64 layerElement.setAttribute("min_scale", 62 try {
65 String.valueOf(layer.getMinimumScale())); 63 layerElement = util.addLayer();
66 layerElement.setAttribute("max_scale", 64 }
67 String.valueOf(layer.getMaximumScale())); 65 catch(Exception e) {
68 if(layer.isVisible()) { 66 logger.error(
67 "Could not create DOM element for layer." +
68 "Stopped reading layer.");
69 return null;
70 }
71
72 try {
73 layerElement.setAttribute("name", layer.getName());
74 }
75 catch(IOException ioe) {
76 logger.warn(
77 "Could not read layer name. " +
78 "Setting layer name to \"default\".");
79 layerElement.setAttribute("name", "default");
80 }
81
82 try {
83 layerElement.setAttribute("min_scale",
84 String.valueOf(layer.getMinimumScale()));
85 }
86 catch(IOException ioe) {
87 logger.warn(
88 "Could not read minimum layer scale." +
89 "Setting minimum layer scale to 1000");
90 layerElement.setAttribute("min_scale", "1000");
91 }
92
93 try {
94 layerElement.setAttribute("max_scale",
95 String.valueOf(layer.getMaximumScale()));
96 }
97 catch(IOException ioe) {
98 logger.warn(
99 "Could not read maximum layer scale." +
100 "Setting maximum layer scale to 1000000");
101 layerElement.setAttribute("max_scale", "1000000");
102 }
103
104 try {
105 if(layer.isVisible()) {
106 layerElement.setAttribute("status", "on");
107 }
108 else {
109 layerElement.setAttribute("status", "off");
110 }
111 }
112 catch(IOException ioe) {
113 logger.warn(
114 "Could not read layer status." +
115 " Setting layer status to \"on\"");
69 layerElement.setAttribute("status", "on"); 116 layerElement.setAttribute("status", "on");
70 } 117 }
71 else { 118
72 layerElement.setAttribute("status", "off"); 119 try {
120 layerElement.setAttribute("definition_query",
121 layer.getDefinitionExpression());
73 } 122 }
74 123 catch(IOException ioe) {
75 layerElement.setAttribute("definition_query", 124 logger.warn(
76 layer.getDefinitionExpression()); 125 "Could not read layer definition query." +
77 126 "Setting empty definition query.");
127 layerElement.setAttribute("definition_query", "");
128 }
78 return layerElement; 129 return layerElement;
79 } 130 }
80 } 131 }
81 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 132 // 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)