Mercurial > mxd2map
annotate src/java/de/intevation/mxd/reader/MapReader.java @ 196:5350621a0294
Verify the SDE databse jointable attribute.
author | raimund renkert <raimund.renkert@intevation.de> |
---|---|
date | Wed, 20 Jul 2011 17:51:38 +0200 |
parents | 0bde090506f9 |
children | df4e0946ef02 |
rev | line source |
---|---|
33
c51376f8e24c
Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents:
31
diff
changeset
|
1 package de.intevation.mxd.reader; |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
2 |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
3 import java.io.IOException; |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
4 |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
5 import org.apache.log4j.Logger; |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
6 |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
7 import com.esri.arcgis.carto.IMap; |
39
f807c9c81019
Read further map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
8 import com.esri.arcgis.carto.Map; |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
9 import com.esri.arcgis.geometry.ISpatialReference; |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
10 import com.esri.arcgis.geometry.ProjectedCoordinateSystem; |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
11 import com.esri.arcgis.geometry.GeographicCoordinateSystem; |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
27
diff
changeset
|
12 import com.esri.arcgis.geometry.UnknownCoordinateSystem; |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
13 import com.esri.arcgis.geometry.Projection; |
39
f807c9c81019
Read further map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
14 import com.esri.arcgis.geometry.IEnvelope; |
27
e5fdc37f8f94
Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
15 |
e5fdc37f8f94
Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
16 import org.w3c.dom.Element; |
e5fdc37f8f94
Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
17 |
33
c51376f8e24c
Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents:
31
diff
changeset
|
18 import de.intevation.mxd.utils.MapToXMLUtils; |
c51376f8e24c
Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents:
31
diff
changeset
|
19 |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
20 /** |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
21 * Reads map information. |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
22 * |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
23 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
24 */ |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
39
diff
changeset
|
25 public class MapReader { |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
39
diff
changeset
|
26 /** |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
39
diff
changeset
|
27 * The Logger. |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
39
diff
changeset
|
28 */ |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
39
diff
changeset
|
29 private static final Logger logger = Logger.getLogger(MapReader.class); |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
30 |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
39
diff
changeset
|
31 /** |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
39
diff
changeset
|
32 * Private member. |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
39
diff
changeset
|
33 */ |
39
f807c9c81019
Read further map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
34 private Map map; |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
27
diff
changeset
|
35 private MapToXMLUtils util; |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
36 |
181 | 37 /** |
38 * Constructor with ArcGIS map. | |
39 * | |
40 * @param map The ArcGIS map object. | |
41 */ | |
39
f807c9c81019
Read further map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
42 public MapReader(IMap map) |
f807c9c81019
Read further map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
43 throws Exception { |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
44 logger.debug("constructor()"); |
39
f807c9c81019
Read further map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
45 if(map instanceof Map) { |
f807c9c81019
Read further map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
46 this.map = (Map)map; |
f807c9c81019
Read further map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
47 } |
f807c9c81019
Read further map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
48 else { |
f807c9c81019
Read further map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
49 throw new Exception("Not an instance of \"Map\"!"); |
f807c9c81019
Read further map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
50 } |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
51 } |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
52 |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
53 /** |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
54 * Reads the Map attributes. |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
55 */ |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
39
diff
changeset
|
56 public void read() |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
39
diff
changeset
|
57 throws IOException { |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
58 logger.debug("read()"); |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
39
diff
changeset
|
59 if(util == null) { |
27
e5fdc37f8f94
Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
60 throw new IOException("Can not write to document."); |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
39
diff
changeset
|
61 } |
27
e5fdc37f8f94
Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
62 |
39
f807c9c81019
Read further map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
63 //Create XML Element for map. |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
27
diff
changeset
|
64 Element mapElement; |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
27
diff
changeset
|
65 try{ |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
27
diff
changeset
|
66 mapElement = util.createMap(); |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
27
diff
changeset
|
67 } |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
27
diff
changeset
|
68 catch(Exception e){ |
121
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
69 logger.error("Could not create DOM element. Aborting."); |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
70 throw new IOException("Error creating DOM element."); |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
27
diff
changeset
|
71 } |
39
f807c9c81019
Read further map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
72 |
f807c9c81019
Read further map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
73 //Read map name. |
121
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
74 try { |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
75 mapElement.setAttribute("name", map.getName()); |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
76 } |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
77 catch(IOException ioe) { |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
78 logger.warn( |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
79 "Could not read map name." + |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
80 " Setting map name to \"default-map\""); |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
81 mapElement.setAttribute("name", "default-map"); |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
82 } |
39
f807c9c81019
Read further map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
83 |
f807c9c81019
Read further map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
84 //Read map extent. |
121
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
85 try { |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
86 IEnvelope ext = map.getExtent(); |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
87 mapElement.setAttribute( |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
88 "extent_max_x", |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
89 String.valueOf(ext.getXMax())); |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
90 mapElement.setAttribute( |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
91 "extent_max_y", |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
92 String.valueOf(ext.getYMax())); |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
93 mapElement.setAttribute( |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
94 "extent_min_x", |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
95 String.valueOf(ext.getXMin())); |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
96 mapElement.setAttribute( |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
97 "extent_min_y", |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
98 String.valueOf(ext.getYMin())); |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
99 } |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
100 catch(IOException ioe) { |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
101 logger.warn("Could not read map extend. Setting to 0, 0, 0, 0."); |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
102 mapElement.setAttribute("extend_max_x", "0"); |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
103 mapElement.setAttribute("extend_min_x", "0"); |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
104 mapElement.setAttribute("extend_max_y", "0"); |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
105 mapElement.setAttribute("extend_min_y", "0"); |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
106 } |
39
f807c9c81019
Read further map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
107 |
f807c9c81019
Read further map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
108 //Read map units. |
121
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
109 int units = 0; |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
110 try { |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
111 units = map.getMapUnits(); |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
112 } |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
113 catch(IOException ioe) { |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
114 logger.warn( |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
115 "Could not read map units." + |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
116 " Setting map units to unknown."); |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
117 units = 0; |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
118 } |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
119 |
39
f807c9c81019
Read further map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
120 String s_units; |
f807c9c81019
Read further map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
121 switch(units) { |
f807c9c81019
Read further map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
122 case 1: s_units = "inches"; break; |
121
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
123 case 2: s_units = "points"; break; |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
124 case 3: s_units = "feet"; break; |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
125 case 4: s_units = "yards"; break; |
39
f807c9c81019
Read further map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
126 case 5: s_units = "miles"; break; |
f807c9c81019
Read further map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
127 case 6: s_units = "nauticalmiles"; break; |
121
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
128 case 7: s_units = "millimeters"; break; |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
129 case 8: s_units = "centimeters"; break; |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
130 case 9: s_units = "meters"; break; |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
131 case 10: s_units = "kilometers"; break; |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
132 case 11: s_units = "degree"; break; |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
133 case 12: s_units = "decimeters"; break; |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
134 case 13: s_units = "units_last"; break; |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
135 default : s_units = "unknown"; break; |
39
f807c9c81019
Read further map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
136 } |
f807c9c81019
Read further map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
137 mapElement.setAttribute("units", s_units); |
f807c9c81019
Read further map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
138 |
121
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
139 if(units == 0) { |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
140 logger.warn( |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
141 "Unknown units." + |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
142 " Please edit units in resulting mapfile."); |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
143 } |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
144 |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
145 try { |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
146 mapElement.setAttribute( |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
147 "scale", |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
148 String.valueOf(map.getMaxScale())); |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
149 } |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
150 catch(IOException ioe) { |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
151 logger.warn("Could not read map scale. Setting map scale to 1000"); |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
152 mapElement.setAttribute("scale", "1000"); |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
153 } |
39
f807c9c81019
Read further map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
154 |
f807c9c81019
Read further map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
155 //Read the projection. |
121
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
156 try { |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
157 ISpatialReference sr = map.getSpatialReference(); |
170
b9ee44070056
Manage projections and units.
vc11884admin@VC11884.win.bsh.de
parents:
121
diff
changeset
|
158 int projection = 0; |
121
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
159 if(sr instanceof ProjectedCoordinateSystem) { |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
160 ProjectedCoordinateSystem pcs = (ProjectedCoordinateSystem)sr; |
170
b9ee44070056
Manage projections and units.
vc11884admin@VC11884.win.bsh.de
parents:
121
diff
changeset
|
161 projection = pcs.getFactoryCode(); |
121
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
162 } |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
163 else if(sr instanceof GeographicCoordinateSystem) { |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
164 GeographicCoordinateSystem gcs = (GeographicCoordinateSystem)sr; |
170
b9ee44070056
Manage projections and units.
vc11884admin@VC11884.win.bsh.de
parents:
121
diff
changeset
|
165 projection = gcs.getFactoryCode(); |
121
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
166 } |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
167 else if(sr instanceof UnknownCoordinateSystem) { |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
168 UnknownCoordinateSystem ucs = (UnknownCoordinateSystem)sr; |
170
b9ee44070056
Manage projections and units.
vc11884admin@VC11884.win.bsh.de
parents:
121
diff
changeset
|
169 projection = 0; |
121
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
170 } |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
171 else{ |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
172 logger.debug( |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
173 "Unknown SpatialReference: " + |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
174 sr.getClass().toString()); |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
175 } |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
176 |
170
b9ee44070056
Manage projections and units.
vc11884admin@VC11884.win.bsh.de
parents:
121
diff
changeset
|
177 if(projection == 0) { |
121
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
178 logger.warn( |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
179 "Unknown projection." + |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
180 " Please edit projection in resulting mapfile."); |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
181 } |
170
b9ee44070056
Manage projections and units.
vc11884admin@VC11884.win.bsh.de
parents:
121
diff
changeset
|
182 mapElement.setAttribute("projection", String.valueOf(projection)); |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
27
diff
changeset
|
183 } |
121
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
184 catch(IOException ioe) { |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
185 logger.warn( |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
186 "Could not read map projection." + |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
187 " Setting map projection to unknown."); |
9f74f4d36822
Set default values and improved logging and exception handling for map reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
57
diff
changeset
|
188 mapElement.setAttribute("projection", "Unknown"); |
27
e5fdc37f8f94
Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
189 } |
e5fdc37f8f94
Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
190 } |
e5fdc37f8f94
Added XMLUtils to store map information.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
191 |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
39
diff
changeset
|
192 /** |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
39
diff
changeset
|
193 * Set the utilities. |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
39
diff
changeset
|
194 */ |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
39
diff
changeset
|
195 public void setUtil(MapToXMLUtils util) { |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
27
diff
changeset
|
196 this.util = util; |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
197 } |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
198 } |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
199 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |