Mercurial > mxd2map
changeset 313:9bb629743d2c
Remove uneccessary else and indention
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Fri, 14 Sep 2012 17:03:54 +0200 |
parents | 503d3a453a04 |
children | cd3cb1a7f35a |
files | src/java/de/intevation/mxd/reader/MXDReader.java |
diffstat | 1 files changed, 158 insertions(+), 160 deletions(-) [+] |
line wrap: on
line diff
--- 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."); } } }