comparison 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
comparison
equal deleted inserted replaced
26:3e24fffdf2bb 27:e5fdc37f8f94
9 import com.esri.arcgis.geometry.ISpatialReference; 9 import com.esri.arcgis.geometry.ISpatialReference;
10 import com.esri.arcgis.geometry.ProjectedCoordinateSystem; 10 import com.esri.arcgis.geometry.ProjectedCoordinateSystem;
11 import com.esri.arcgis.geometry.GeographicCoordinateSystem; 11 import com.esri.arcgis.geometry.GeographicCoordinateSystem;
12 import com.esri.arcgis.geometry.IProjection; 12 import com.esri.arcgis.geometry.IProjection;
13 import com.esri.arcgis.geometry.Projection; 13 import com.esri.arcgis.geometry.Projection;
14
15 import org.w3c.dom.Document;
16 import org.w3c.dom.Element;
17
14 /** 18 /**
15 * Reads map information. 19 * Reads map information.
16 * 20 *
17 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> 21 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
18 */ 22 */
19 public class MapReader{ 23 public class MapReader{
20 24
21 //Member 25 //Member
22 IMap map; 26 private IMap map;
27 private Document document;
23 28
24 private static final Logger logger = Logger.getLogger(MapReader.class); 29 private static final Logger logger = Logger.getLogger(MapReader.class);
25 30
26 //Constructor 31 //Constructor
27 public MapReader(IMap map){ 32 public MapReader(IMap map){
35 /** 40 /**
36 * Reads the Map attributes. 41 * Reads the Map attributes.
37 */ 42 */
38 public void read() throws IOException{ 43 public void read() throws IOException{
39 logger.debug("read()"); 44 logger.debug("read()");
45 if(document == null)
46 throw new IOException("Can not write to document.");
47
48 XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator(document,
49 "", "");
50 Element mapElement = creator.create("map");
40 ISpatialReference sr = map.getSpatialReference(); 51 ISpatialReference sr = map.getSpatialReference();
41 logger.debug("Instance: " + sr.getClass().toString()); 52 logger.debug("Instance: " + sr.getClass().toString());
42 if(sr instanceof ProjectedCoordinateSystem){ 53 if(sr instanceof ProjectedCoordinateSystem){
43 ProjectedCoordinateSystem pcs = (ProjectedCoordinateSystem)sr; 54 ProjectedCoordinateSystem pcs = (ProjectedCoordinateSystem)sr;
44 Projection p = (Projection)pcs.getProjection(); 55 Projection p = (Projection)pcs.getProjection();
45 System.out.println("Projection = " + p.getName()); 56 creator.addAttr(mapElement, "projection", p.getName());
46 } 57 }
47 else if(sr instanceof GeographicCoordinateSystem){ 58 else if(sr instanceof GeographicCoordinateSystem){
48 GeographicCoordinateSystem gcs = (GeographicCoordinateSystem)sr; 59 GeographicCoordinateSystem gcs = (GeographicCoordinateSystem)sr;
49 System.out.println("Name = " + gcs.getName()); 60 creator.addAttr(mapElement, "projection", gcs.getName());
50 } 61 }
62 else{
63 throw new IOException("Unknown SpatialReference: " +
64 sr.getClass().toString());
65 }
66 document.appendChild(mapElement);
67 }
68
69 public void setDocument(Document doc){
70 this.document = doc;
51 } 71 }
52 } 72 }
53 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 73 // 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)