comparison src/java/de/intevation/mxd/reader/MXDReader.java @ 26:3e24fffdf2bb

Moved reader components to reader folder.
author Raimund Renkert <rrenkert@intevation.de>
date Fri, 08 Apr 2011 12:26:17 +0200
parents src/java/de/intevation/mxd/MXDReader.java@cbd67b1100d8
children e5fdc37f8f94
comparison
equal deleted inserted replaced
25:cbd67b1100d8 26:3e24fffdf2bb
1 //package de.intevation.mxd.reader;
2
3 import java.io.IOException;
4
5 import org.apache.log4j.Logger;
6
7 import com.esri.arcgis.geodatabase.IClass;
8 import com.esri.arcgis.carto.ILayer;
9 import com.esri.arcgis.carto.IMap;
10 import com.esri.arcgis.carto.MapDocument;
11 import com.esri.arcgis.carto.FeatureLayer;
12 import com.esri.arcgis.carto.IFeatureRenderer;
13 import com.esri.arcgis.carto.SimpleRenderer;
14 import com.esri.arcgis.carto.ClassBreaksRenderer;
15 import com.esri.arcgis.carto.UniqueValueRenderer;
16
17 import com.esri.arcgis.geodatabase.IFeatureClass;
18 import com.esri.arcgis.geodatabase.FeatureClass;
19 import com.esri.arcgis.geometry.ISpatialReference;
20 import com.esri.arcgis.geometry.ProjectedCoordinateSystem;
21 import com.esri.arcgis.geometry.IProjection;
22 import com.esri.arcgis.geometry.Projection;
23
24 /**
25 * The MXD file reader.
26 *
27 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
28 */
29 public class MXDReader implements IReader {
30
31 //Member
32 private String filename = "";
33 private ArcGISInitializer initializer = null;
34 private IMap map;
35
36 private static final Logger logger = Logger.getLogger(MXDReader.class);
37
38 //Constructor
39 public MXDReader() throws IOException{
40 logger.debug("constructor()");
41 initializer = new ArcGISInitializer();
42 }
43
44
45 //Methods
46
47 /**
48 * Initialize the ArcGIS Objects.
49 */
50 public boolean init() throws IOException{
51 logger.debug("init()");
52 initializer.initArcGIS();
53 initializer.initArcGISLicenses();
54 return true;
55 }
56
57 /**
58 * Shutdown the ArcGIS Objects.
59 */
60 public boolean shutdown() throws IOException{
61 logger.debug("shutdown()");
62 if(initializer == null){
63 throw new IOException("Faild to shutdown!");
64 }
65 else{
66 initializer.shutdownArcGIS();
67 return true;
68 }
69 }
70
71 /**
72 * Set the path and filename to the MXD-File.
73 */
74 public void setFilename(String name){
75 logger.debug("setFilename()");
76 filename = name;
77 }
78
79 /**
80 * Read the MXD file content.
81 */
82 public boolean read() throws IOException{
83 logger.debug("read()");
84 if(filename == ""){
85 throw new IOException("Please set filename!");
86 }
87 else{
88 MapDocument m = new MapDocument();
89 if(!m.isMapDocument(filename)){
90 throw new IOException(filename + " is not a map!");
91 }
92 m.open(filename, null);
93 map = m.getMap(0);
94 MapReader mreader = new MapReader (map);
95 mreader.read();
96 for(int i = 0; i < map.getLayerCount();i++){
97 ILayer layer = map.getLayer(0);
98 ILayerReader lr = new FeatureLayerReader(layer);
99 lr.read();
100 if (layer instanceof FeatureLayer){
101 IFeatureRenderer renderer = ((FeatureLayer)layer).getRenderer();
102 IRendererReader rreader;
103 try{
104 if(renderer instanceof SimpleRenderer){
105 rreader = new SimpleRendererReader(renderer);
106 rreader.read();
107 }
108 else if(renderer instanceof ClassBreaksRenderer){
109 rreader = new ClassBreakRendererReader(renderer);
110 rreader.read();
111 }
112 else if(renderer instanceof UniqueValueRenderer){
113 rreader = new UniqueValueRendererReader(renderer);
114 rreader.read();
115 }
116 else{
117 System.out.println("No known renderer!");
118 System.out.println("Implement new renderer for " +
119 renderer.getClass().toString());
120 }
121 }
122 catch(Exception e){
123 e.printStackTrace();
124 }
125 }
126 }
127 }
128 return true;
129 }
130
131 /**
132 * Get the mapinformation as DOM document. TODO: implement me!
133 */
134 public void getMapDocument(){
135 logger.debug("getMapDocument() -> not implemented jet.");
136 }
137 }
138 // 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)