comparison src/java/de/intevation/mxd/reader/FeatureLayerReader.java @ 135:a4ab239509f1

Updated the default values and reader error handling.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 22 Jun 2011 13:55:22 +0200
parents 6b80d2c7536e
children f3a91cd7440b
comparison
equal deleted inserted replaced
134:acc9e5430177 135:a4ab239509f1
73 try { 73 try {
74 layerElement.setAttribute("name", layer.getName()); 74 layerElement.setAttribute("name", layer.getName());
75 } 75 }
76 catch(IOException ioe) { 76 catch(IOException ioe) {
77 logger.warn( 77 logger.warn(
78 "Could not read name." + 78 "Could not read layer name." +
79 " Setting name to \"default-layer\""); 79 " Stopped reading layer.");
80 layerElement.setAttribute("name", "default-layer"); 80 throw new IOException("Error reading layer name.");
81 } 81 }
82 82
83 try { 83 try {
84 layerElement.setAttribute("min_scale", 84 layerElement.setAttribute("min_scale",
85 String.valueOf(layer.getMinimumScale())); 85 String.valueOf(layer.getMinimumScale()));
86 } 86 }
87 catch(IOException ioe) { 87 catch(IOException ioe) {
88 logger.warn( 88 logger.warn("Could not read minimum scale.");
89 "Could not read minimum scale." +
90 " Setting minimum scale to 0.");
91 layerElement.setAttribute("min_scale", "0");
92 } 89 }
93 90
94 try { 91 try {
95 layerElement.setAttribute("max_scale", 92 layerElement.setAttribute("max_scale",
96 String.valueOf(layer.getMaximumScale())); 93 String.valueOf(layer.getMaximumScale()));
97 } 94 }
98 catch(IOException ioe) { 95 catch(IOException ioe) {
99 logger.warn( 96 logger.warn(
100 "Could not read maximum scale." + 97 "Could not read maximum scale.");
101 " Setting maximum scale to 0.");
102 layerElement.setAttribute("max_scale", "0");
103 } 98 }
104 99
105 try { 100 try {
106 if(layer.isVisible()) { 101 if(layer.isVisible()) {
107 layerElement.setAttribute("status", "on"); 102 layerElement.setAttribute("status", "on");
120 int type = 0; 115 int type = 0;
121 try { 116 try {
122 type = layer.getShapeType(); 117 type = layer.getShapeType();
123 } 118 }
124 catch(IOException ioe) { 119 catch(IOException ioe) {
125 logger.warn( 120 logger.warn("Could not read shape type.");
126 "Could not read shape type." + 121 throw new IOException("Error reading shape type.");
127 " Setting shape type to \"none\".");
128 type = 0;
129 } 122 }
130 switch (type) { 123 switch (type) {
131 case 0: layerElement.setAttribute("type", "none"); break; 124 case 0: layerElement.setAttribute("type", "none"); break;
132 case 1: layerElement.setAttribute("type", "point"); break; 125 case 1: layerElement.setAttribute("type", "point"); break;
133 case 3: layerElement.setAttribute("type", "line"); break; 126 case 3: layerElement.setAttribute("type", "line"); break;
138 layerElement.setAttribute("definition_query", 131 layerElement.setAttribute("definition_query",
139 layer.getDefinitionExpression()); 132 layer.getDefinitionExpression());
140 } 133 }
141 catch(IOException ioe) { 134 catch(IOException ioe) {
142 logger.warn( 135 logger.warn(
143 "Could not read definition query." + 136 "Could not read definition query.");
144 " Setting empty definition query.");
145 layerElement.setAttribute("definition_query", "");
146 } 137 }
147 try { 138 try {
148 IName fcn = layer.getDataSourceName(); 139 IName fcn = layer.getDataSourceName();
149 if(fcn instanceof FeatureClassName) { 140 if(fcn instanceof FeatureClassName) {
150 FeatureClassName name = (FeatureClassName)fcn; 141 FeatureClassName name = (FeatureClassName)fcn;
228 catch(Exception e) { 219 catch(Exception e) {
229 logger.error( 220 logger.error(
230 "Could not read layer datasource." + 221 "Could not read layer datasource." +
231 " Stopped reading layer " + layer.getName() + "."); 222 " Stopped reading layer " + layer.getName() + ".");
232 util.removeLayer(layerElement); 223 util.removeLayer(layerElement);
233 return null; 224 return null;
234 } 225 }
235 return layerElement; 226 return layerElement;
236 } 227 }
237 } 228 }
238 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 229 // 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)