diff src/java/de/intevation/mxd/reader/MapReader.java @ 31:40c0b4e5f91a

Added utility class to store map attributes.
author Raimund Renkert <rrenkert@intevation.de>
date Mon, 11 Apr 2011 16:04:03 +0200
parents e5fdc37f8f94
children c51376f8e24c
line wrap: on
line diff
--- a/src/java/de/intevation/mxd/reader/MapReader.java	Fri Apr 08 17:58:37 2011 +0200
+++ b/src/java/de/intevation/mxd/reader/MapReader.java	Mon Apr 11 16:04:03 2011 +0200
@@ -9,6 +9,7 @@
 import com.esri.arcgis.geometry.ISpatialReference;
 import com.esri.arcgis.geometry.ProjectedCoordinateSystem;
 import com.esri.arcgis.geometry.GeographicCoordinateSystem;
+import com.esri.arcgis.geometry.UnknownCoordinateSystem;
 import com.esri.arcgis.geometry.IProjection;
 import com.esri.arcgis.geometry.Projection;
 
@@ -24,7 +25,7 @@
 
     //Member
     private IMap map;
-    private Document document;
+    private MapToXMLUtils util;
 
     private static final Logger logger = Logger.getLogger(MapReader.class);
 
@@ -42,32 +43,42 @@
      */
     public void read() throws IOException{
         logger.debug("read()");
-        if(document == null)
+        if(util == null)
             throw new IOException("Can not write to document.");
 
-        XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator(document,
-                                                                      "", "");
-        Element mapElement = creator.create("map");
+//        XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator(document,
+//                                                                      "", "");
+        Element mapElement;
+        try{
+            mapElement = util.createMap();
+        }
+        catch(Exception e){
+            e.printStackTrace();
+            return;
+        }
         ISpatialReference sr = map.getSpatialReference();
         logger.debug("Instance: " + sr.getClass().toString());
         if(sr instanceof ProjectedCoordinateSystem){
             ProjectedCoordinateSystem pcs = (ProjectedCoordinateSystem)sr;
             Projection p = (Projection)pcs.getProjection();
-            creator.addAttr(mapElement, "projection", p.getName());
+            mapElement.setAttribute("projection", p.getName());
         }
         else if(sr instanceof GeographicCoordinateSystem){
             GeographicCoordinateSystem gcs = (GeographicCoordinateSystem)sr;
-            creator.addAttr(mapElement, "projection", gcs.getName());
+            mapElement.setAttribute("projection", gcs.getName());
+        }
+        else if(sr instanceof UnknownCoordinateSystem) {
+            UnknownCoordinateSystem ucs = (UnknownCoordinateSystem)sr;
+            mapElement.setAttribute("projection", sr.getName());
         }
         else{
             throw new IOException("Unknown SpatialReference: " +
                                   sr.getClass().toString());
         }
-        document.appendChild(mapElement);
     }
 
-    public void setDocument(Document doc){
-        this.document = doc;
+    public void setUtil(MapToXMLUtils util){
+        this.util = util;
     }
 }
 // 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)