comparison src/java/de/intevation/mxd/reader/MapReader.java @ 43:ef7ca23c4233

Added comments, done some code styling and removed typos.
author Raimund Renkert <rrenkert@intevation.de>
date Fri, 15 Apr 2011 15:44:54 +0200
parents f807c9c81019
children 8da6555f1c12
comparison
equal deleted inserted replaced
42:395307e8b7ee 43:ef7ca23c4233
20 /** 20 /**
21 * Reads map information. 21 * Reads map information.
22 * 22 *
23 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> 23 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
24 */ 24 */
25 public class MapReader{ 25 public class MapReader {
26 /**
27 * The Logger.
28 */
29 private static final Logger logger = Logger.getLogger(MapReader.class);
26 30
27 //Member 31 /**
32 * Private member.
33 */
28 private Map map; 34 private Map map;
29 private MapToXMLUtils util; 35 private MapToXMLUtils util;
30 36
31 private static final Logger logger = Logger.getLogger(MapReader.class);
32 37
33 //Constructor
34 public MapReader(IMap map) 38 public MapReader(IMap map)
35 throws Exception { 39 throws Exception {
36 logger.debug("constructor()"); 40 logger.debug("constructor()");
37 if(map instanceof Map) { 41 if(map instanceof Map) {
38 this.map = (Map)map; 42 this.map = (Map)map;
40 else { 44 else {
41 throw new Exception("Not an instance of \"Map\"!"); 45 throw new Exception("Not an instance of \"Map\"!");
42 } 46 }
43 } 47 }
44 48
45
46 //Methods
47
48 /** 49 /**
49 * Reads the Map attributes. 50 * Reads the Map attributes.
50 */ 51 */
51 public void read() throws IOException{ 52 public void read()
53 throws IOException {
52 logger.debug("read()"); 54 logger.debug("read()");
53 if(util == null) 55 if(util == null) {
54 throw new IOException("Can not write to document."); 56 throw new IOException("Can not write to document.");
57 }
55 58
56 //Create XML Element for map. 59 //Create XML Element for map.
57 Element mapElement; 60 Element mapElement;
58 try{ 61 try{
59 mapElement = util.createMap(); 62 mapElement = util.createMap();
101 "scale", 104 "scale",
102 String.valueOf(map.getMaxScale())); 105 String.valueOf(map.getMaxScale()));
103 106
104 //Read the projection. 107 //Read the projection.
105 ISpatialReference sr = map.getSpatialReference(); 108 ISpatialReference sr = map.getSpatialReference();
106 if(sr instanceof ProjectedCoordinateSystem){ 109 if(sr instanceof ProjectedCoordinateSystem) {
107 ProjectedCoordinateSystem pcs = (ProjectedCoordinateSystem)sr; 110 ProjectedCoordinateSystem pcs = (ProjectedCoordinateSystem)sr;
108 Projection p = (Projection)pcs.getProjection(); 111 Projection p = (Projection)pcs.getProjection();
109 mapElement.setAttribute("projection", p.getName()); 112 mapElement.setAttribute("projection", p.getName());
110 } 113 }
111 else if(sr instanceof GeographicCoordinateSystem){ 114 else if(sr instanceof GeographicCoordinateSystem) {
112 GeographicCoordinateSystem gcs = (GeographicCoordinateSystem)sr; 115 GeographicCoordinateSystem gcs = (GeographicCoordinateSystem)sr;
113 mapElement.setAttribute("projection", gcs.getName()); 116 mapElement.setAttribute("projection", gcs.getName());
114 } 117 }
115 else if(sr instanceof UnknownCoordinateSystem) { 118 else if(sr instanceof UnknownCoordinateSystem) {
116 UnknownCoordinateSystem ucs = (UnknownCoordinateSystem)sr; 119 UnknownCoordinateSystem ucs = (UnknownCoordinateSystem)sr;
120 throw new IOException("Unknown SpatialReference: " + 123 throw new IOException("Unknown SpatialReference: " +
121 sr.getClass().toString()); 124 sr.getClass().toString());
122 } 125 }
123 } 126 }
124 127
125 public void setUtil(MapToXMLUtils util){ 128 /**
129 * Set the utilities.
130 */
131 public void setUtil(MapToXMLUtils util) {
126 this.util = util; 132 this.util = util;
127 } 133 }
128 } 134 }
129 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : 135 // 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)