[MXD2map-commits] r313:9bb629743d2c
scm-commit at wald.intevation.org
scm-commit at wald.intevation.org
Mon Sep 17 17:10:48 CEST 2012
details: http://hg.intevation.org/geospatial/mxd2map/rev/9bb629743d2c
changeset: 313:9bb629743d2c
user: Andre Heinecke <aheinecke at intevation.de>
date: Fri Sep 14 17:03:54 2012 +0200
description:
Remove uneccessary else and indention
diffstat:
src/java/de/intevation/mxd/reader/MXDReader.java | 318 +++++++++++-----------
1 files changed, 158 insertions(+), 160 deletions(-)
diffs (331 lines):
diff -r 503d3a453a04 -r 9bb629743d2c src/java/de/intevation/mxd/reader/MXDReader.java
--- a/src/java/de/intevation/mxd/reader/MXDReader.java Fri Sep 14 17:03:15 2012 +0200
+++ b/src/java/de/intevation/mxd/reader/MXDReader.java Fri Sep 14 17:03:54 2012 +0200
@@ -139,169 +139,167 @@
if(filename.isEmpty()) {
throw new IOException("Please set filename!");
}
- else {
- util.addFilename(filename);
- openMapDocument();
- MapReader mreader;
+ util.addFilename(filename);
+ openMapDocument();
+ MapReader mreader;
+ try {
+ mreader = new MapReader (map);
+ mreader.setUtil(util);
+ mreader.read();
+
+ }
+ catch(Exception e) {
+ throw e;
+ }
+
+ for(int i = 0; i < map.getLayerCount();i++) {
+ ILayer layer = map.getLayer(i);
try {
- mreader = new MapReader (map);
- mreader.setUtil(util);
- mreader.read();
-
+ if (layer instanceof FeatureLayer) {
+ FeatureLayerReader lr = new FeatureLayerReader(layer);
+ lr.setUtil(util);
+ Element layerElement = lr.read();
+ if (layerElement == null) {
+ continue;
+ }
+ IFeatureRenderer renderer =
+ ((FeatureLayer)layer).getRenderer();
+ IRendererReader rreader;
+ if(renderer instanceof SimpleRenderer) {
+ rreader = new SimpleRendererReader(renderer);
+ rreader.setParent(layerElement);
+ rreader.setUtil(util);
+ rreader.read();
+ }
+ else if(renderer instanceof ClassBreaksRenderer) {
+ rreader = new ClassBreakRendererReader(renderer);
+ rreader.setParent(layerElement);
+ rreader.setUtil(util);
+ rreader.read();
+ }
+ else if(renderer instanceof UniqueValueRenderer) {
+ rreader = new UniqueValueRendererReader(renderer);
+ rreader.setParent(layerElement);
+ rreader.setUtil(util);
+ rreader.read();
+ }
+ else{
+ logger.debug("Not a known renderer type " +
+ renderer.getClass().toString());
+ }
+ }
+ else if(layer instanceof GdbRasterCatalogLayer) {
+ GdbRasterCatalogLayerReader gclr =
+ new GdbRasterCatalogLayerReader(layer);
+ gclr.setUtil(util);
+ Element layerElement = gclr.read();
+ IFeatureRenderer renderer =
+ ((GdbRasterCatalogLayer)layer).getRenderer();
+ IRendererReader rreader;
+ if(renderer instanceof SimpleRenderer) {
+ rreader = new SimpleRendererReader(renderer);
+ rreader.setParent(layerElement);
+ rreader.setUtil(util);
+ rreader.read();
+ }
+ else if(renderer instanceof ClassBreaksRenderer) {
+ rreader = new ClassBreakRendererReader(renderer);
+ rreader.setParent(layerElement);
+ rreader.setUtil(util);
+ rreader.read();
+ }
+ else if(renderer instanceof UniqueValueRenderer) {
+ rreader = new UniqueValueRendererReader(renderer);
+ rreader.setParent(layerElement);
+ rreader.setUtil(util);
+ rreader.read();
+ }
+ else {
+ logger.debug("Not a known renderer type " +
+ renderer.getClass().toString());
+ }
+ }
+ else if(layer instanceof GroupLayer) {
+ GroupLayerReader gl = new GroupLayerReader(layer);
+ gl.setUtil(util);
+ Element layerElement = gl.read("");
+ if(layerElement == null) {
+ throw new IOException ("Error reading grouplayer.");
+ }
+ }
+ else if(layer instanceof WMSMapLayer) {
+ WMSMapLayerReader lr = new WMSMapLayerReader(layer);
+ lr.setUtil(util);
+ Element layerElement = lr.read("");
+ if(layerElement == null) {
+ throw new IOException ("Error reading WMSMapLayer.");
+ }
+ }
+ else if(layer instanceof WMSGroupLayer) {
+ WMSGroupLayerReader lr = new WMSGroupLayerReader(layer);
+ lr.setUtil(util);
+ Element layerElement = lr.read("");
+ if(layerElement == null) {
+ throw new IOException ("Error reading WMSGrouplayer.");
+ }
+ }
+ else if(layer instanceof WMSLayer) {
+ WMSLayerReader lr = new WMSLayerReader(layer);
+ lr.setUtil(util);
+ Element layerElement = lr.read();
+ if(layerElement == null) {
+ throw new IOException ("Error reading WMSlayer.");
+ }
+ }
+ else if(layer instanceof RasterLayer) {
+ RasterLayerReader lr =
+ new RasterLayerReader(layer);
+ lr.setUtil(util);
+ Element layerElement = lr.read();
+ if(layerElement == null) {
+ throw new IOException ("Error reading RasterLayer.");
+ }
+/* TODO implement support for classes in Raster Layers
+ IRasterRenderer renderer =
+ ((RasterLayer)layer).getRenderer();
+ IRendererReader rreader;
+ if(renderer instanceof SimpleRenderer) {
+ rreader = new SimpleRendererReader(renderer);
+ rreader.setParent(layerElement);
+ rreader.setUtil(util);
+ rreader.read();
+ }
+ else if(renderer instanceof ClassBreaksRenderer) {
+ rreader = new ClassBreakRendererReader(renderer);
+ rreader.setParent(layerElement);
+ rreader.setUtil(util);
+ rreader.read();
+ }
+ else if(renderer instanceof UniqueValueRenderer) {
+ rreader = new UniqueValueRendererReader(renderer);
+ rreader.setParent(layerElement);
+ rreader.setUtil(util);
+ rreader.read();
+ }
+ else {
+ logger.debug("Not a known renderer type " +
+ renderer.getClass().toString());
+ }
+*/
+ }
+ else {
+ logger.info(
+ "Layertype not known: " +
+ layer.getClass().toString());
+ }
}
catch(Exception e) {
- throw e;
- }
-
- for(int i = 0; i < map.getLayerCount();i++) {
- ILayer layer = map.getLayer(i);
- try {
- if (layer instanceof FeatureLayer) {
- FeatureLayerReader lr = new FeatureLayerReader(layer);
- lr.setUtil(util);
- Element layerElement = lr.read();
- if (layerElement == null) {
- continue;
- }
- IFeatureRenderer renderer =
- ((FeatureLayer)layer).getRenderer();
- IRendererReader rreader;
- if(renderer instanceof SimpleRenderer) {
- rreader = new SimpleRendererReader(renderer);
- rreader.setParent(layerElement);
- rreader.setUtil(util);
- rreader.read();
- }
- else if(renderer instanceof ClassBreaksRenderer) {
- rreader = new ClassBreakRendererReader(renderer);
- rreader.setParent(layerElement);
- rreader.setUtil(util);
- rreader.read();
- }
- else if(renderer instanceof UniqueValueRenderer) {
- rreader = new UniqueValueRendererReader(renderer);
- rreader.setParent(layerElement);
- rreader.setUtil(util);
- rreader.read();
- }
- else{
- logger.debug("Not a known renderer type " +
- renderer.getClass().toString());
- }
- }
- else if(layer instanceof GdbRasterCatalogLayer) {
- GdbRasterCatalogLayerReader gclr =
- new GdbRasterCatalogLayerReader(layer);
- gclr.setUtil(util);
- Element layerElement = gclr.read();
- IFeatureRenderer renderer =
- ((GdbRasterCatalogLayer)layer).getRenderer();
- IRendererReader rreader;
- if(renderer instanceof SimpleRenderer) {
- rreader = new SimpleRendererReader(renderer);
- rreader.setParent(layerElement);
- rreader.setUtil(util);
- rreader.read();
- }
- else if(renderer instanceof ClassBreaksRenderer) {
- rreader = new ClassBreakRendererReader(renderer);
- rreader.setParent(layerElement);
- rreader.setUtil(util);
- rreader.read();
- }
- else if(renderer instanceof UniqueValueRenderer) {
- rreader = new UniqueValueRendererReader(renderer);
- rreader.setParent(layerElement);
- rreader.setUtil(util);
- rreader.read();
- }
- else {
- logger.debug("Not a known renderer type " +
- renderer.getClass().toString());
- }
- }
- else if(layer instanceof GroupLayer) {
- GroupLayerReader gl = new GroupLayerReader(layer);
- gl.setUtil(util);
- Element layerElement = gl.read("");
- if(layerElement == null) {
- throw new IOException ("Error reading grouplayer.");
- }
- }
- else if(layer instanceof WMSMapLayer) {
- WMSMapLayerReader lr = new WMSMapLayerReader(layer);
- lr.setUtil(util);
- Element layerElement = lr.read("");
- if(layerElement == null) {
- throw new IOException ("Error reading WMSMapLayer.");
- }
- }
- else if(layer instanceof WMSGroupLayer) {
- WMSGroupLayerReader lr = new WMSGroupLayerReader(layer);
- lr.setUtil(util);
- Element layerElement = lr.read("");
- if(layerElement == null) {
- throw new IOException ("Error reading WMSGrouplayer.");
- }
- }
- else if(layer instanceof WMSLayer) {
- WMSLayerReader lr = new WMSLayerReader(layer);
- lr.setUtil(util);
- Element layerElement = lr.read();
- if(layerElement == null) {
- throw new IOException ("Error reading WMSlayer.");
- }
- }
- else if(layer instanceof RasterLayer) {
- RasterLayerReader lr =
- new RasterLayerReader(layer);
- lr.setUtil(util);
- Element layerElement = lr.read();
- if(layerElement == null) {
- throw new IOException ("Error reading RasterLayer.");
- }
-/* TODO implement support for classes in Raster Layers
- IRasterRenderer renderer =
- ((RasterLayer)layer).getRenderer();
- IRendererReader rreader;
- if(renderer instanceof SimpleRenderer) {
- rreader = new SimpleRendererReader(renderer);
- rreader.setParent(layerElement);
- rreader.setUtil(util);
- rreader.read();
- }
- else if(renderer instanceof ClassBreaksRenderer) {
- rreader = new ClassBreakRendererReader(renderer);
- rreader.setParent(layerElement);
- rreader.setUtil(util);
- rreader.read();
- }
- else if(renderer instanceof UniqueValueRenderer) {
- rreader = new UniqueValueRendererReader(renderer);
- rreader.setParent(layerElement);
- rreader.setUtil(util);
- rreader.read();
- }
- else {
- logger.debug("Not a known renderer type " +
- renderer.getClass().toString());
- }
-*/
- }
- else {
- logger.info(
- "Layertype not known: " +
- layer.getClass().toString());
- }
- }
- catch(Exception e) {
- invalidLayerCount++;
- if(i == 0 && (i + 1) == map.getLayerCount() ||
- invalidLayerCount == map.getLayerCount()) {
- throw new IOException(
- "No valid layer in MXD file." +
- " Aborting.");
- }
+ invalidLayerCount++;
+ if(i == 0 && (i + 1) == map.getLayerCount() ||
+ invalidLayerCount == map.getLayerCount()) {
+ throw new IOException(
+ "No valid layer in MXD file." +
+ " Aborting.");
}
}
}
More information about the MXD2map-commits
mailing list