Mercurial > mxd2map
diff src/java/de/intevation/mxd/reader/MapReader.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 | 40c0b4e5f91a |
line wrap: on
line diff
--- a/src/java/de/intevation/mxd/reader/MapReader.java Fri Apr 08 12:26:17 2011 +0200 +++ b/src/java/de/intevation/mxd/reader/MapReader.java Fri Apr 08 14:21:45 2011 +0200 @@ -11,6 +11,10 @@ import com.esri.arcgis.geometry.GeographicCoordinateSystem; import com.esri.arcgis.geometry.IProjection; import com.esri.arcgis.geometry.Projection; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; + /** * Reads map information. * @@ -19,7 +23,8 @@ public class MapReader{ //Member - IMap map; + private IMap map; + private Document document; private static final Logger logger = Logger.getLogger(MapReader.class); @@ -37,17 +42,32 @@ */ public void read() throws IOException{ logger.debug("read()"); + if(document == null) + throw new IOException("Can not write to document."); + + XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator(document, + "", ""); + Element mapElement = creator.create("map"); ISpatialReference sr = map.getSpatialReference(); logger.debug("Instance: " + sr.getClass().toString()); if(sr instanceof ProjectedCoordinateSystem){ ProjectedCoordinateSystem pcs = (ProjectedCoordinateSystem)sr; Projection p = (Projection)pcs.getProjection(); - System.out.println("Projection = " + p.getName()); + creator.addAttr(mapElement, "projection", p.getName()); } else if(sr instanceof GeographicCoordinateSystem){ GeographicCoordinateSystem gcs = (GeographicCoordinateSystem)sr; - System.out.println("Name = " + gcs.getName()); + creator.addAttr(mapElement, "projection", gcs.getName()); } + else{ + throw new IOException("Unknown SpatialReference: " + + sr.getClass().toString()); + } + document.appendChild(mapElement); + } + + public void setDocument(Document doc){ + this.document = doc; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :