Mercurial > mxd2map
diff src/java/de/intevation/mxd/reader/MXDReader.java @ 27:e5fdc37f8f94
Added XMLUtils to store map information.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Fri, 08 Apr 2011 14:21:45 +0200 |
parents | 3e24fffdf2bb |
children | 77cfa8092611 |
line wrap: on
line diff
--- a/src/java/de/intevation/mxd/reader/MXDReader.java Fri Apr 08 12:26:17 2011 +0200 +++ b/src/java/de/intevation/mxd/reader/MXDReader.java Fri Apr 08 14:21:45 2011 +0200 @@ -21,6 +21,9 @@ import com.esri.arcgis.geometry.IProjection; import com.esri.arcgis.geometry.Projection; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + /** * The MXD file reader. * @@ -32,6 +35,7 @@ private String filename = ""; private ArcGISInitializer initializer = null; private IMap map; + private Document mapInfo; private static final Logger logger = Logger.getLogger(MXDReader.class); @@ -39,6 +43,7 @@ public MXDReader() throws IOException{ logger.debug("constructor()"); initializer = new ArcGISInitializer(); + mapInfo = XMLUtils.newDocument(); } @@ -76,6 +81,15 @@ filename = name; } + + private void openMapDocument() throws IOException{ + MapDocument m = new MapDocument(); + if(!m.isMapDocument(filename)){ + throw new IOException(filename + " is not a map!"); + } + m.open(filename, null); + map = m.getMap(0); + } /** * Read the MXD file content. */ @@ -85,22 +99,19 @@ throw new IOException("Please set filename!"); } else{ - MapDocument m = new MapDocument(); - if(!m.isMapDocument(filename)){ - throw new IOException(filename + " is not a map!"); - } - m.open(filename, null); - map = m.getMap(0); + openMapDocument(); MapReader mreader = new MapReader (map); + mreader.setDocument(mapInfo); mreader.read(); + for(int i = 0; i < map.getLayerCount();i++){ - ILayer layer = map.getLayer(0); - ILayerReader lr = new FeatureLayerReader(layer); - lr.read(); - if (layer instanceof FeatureLayer){ - IFeatureRenderer renderer = ((FeatureLayer)layer).getRenderer(); - IRendererReader rreader; - try{ + ILayer layer = map.getLayer(i); + try{ + ILayerReader lr = new FeatureLayerReader(layer); + lr.read(); + if (layer instanceof FeatureLayer){ + IFeatureRenderer renderer = ((FeatureLayer)layer).getRenderer(); + IRendererReader rreader; if(renderer instanceof SimpleRenderer){ rreader = new SimpleRendererReader(renderer); rreader.read(); @@ -119,20 +130,22 @@ renderer.getClass().toString()); } } - catch(Exception e){ - e.printStackTrace(); - } + } + catch(Exception e){ + e.printStackTrace(); } } } return true; } + /** * Get the mapinformation as DOM document. TODO: implement me! */ - public void getMapDocument(){ - logger.debug("getMapDocument() -> not implemented jet."); + public Document getMapDocument(){ + logger.debug("getMapDocument()"); + return mapInfo; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :