Mercurial > mxd2map
annotate src/java/de/intevation/mxd/reader/FeatureLayerReader.java @ 100:bab3946a8bdc
Read the connection settings for file geodatabase.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Wed, 08 Jun 2011 11:28:36 +0200 |
parents | 18e4f143896b |
children | 0db6eacad0e6 |
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 org.apache.log4j.Logger; |
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 com.esri.arcgis.carto.ILayer; |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
6 import com.esri.arcgis.carto.FeatureLayer; |
42
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
7 import com.esri.arcgis.geodatabase.FeatureClassName; |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
8 import com.esri.arcgis.system.IName; |
29
77cfa8092611
Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
9 |
77cfa8092611
Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
10 import org.w3c.dom.Element; |
77cfa8092611
Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
11 |
33
c51376f8e24c
Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents:
31
diff
changeset
|
12 import de.intevation.mxd.utils.MapToXMLUtils; |
c51376f8e24c
Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents:
31
diff
changeset
|
13 |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
14 /** |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
15 * Reads Layer information. |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
16 * |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
17 * @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
|
18 */ |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
19 public class FeatureLayerReader |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
20 implements ILayerReader { |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
21 |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
22 /** |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
23 * The logger. |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
24 */ |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
25 private static final Logger logger = |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
26 Logger.getLogger(FeatureLayerReader.class); |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
27 |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
28 /** |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
29 * Privte member. |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
30 */ |
29
77cfa8092611
Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
31 private FeatureLayer layer; |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
32 private MapToXMLUtils util; |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
33 |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
34 |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
35 public FeatureLayerReader(ILayer layer) |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
36 throws Exception { |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
37 if(layer instanceof FeatureLayer) { |
29
77cfa8092611
Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
38 this.layer = (FeatureLayer)layer; |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
39 } |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
40 else { |
29
77cfa8092611
Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
41 throw new Exception("Not an instance of FeatureLayer: " + |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
42 layer.getClass().toString()); |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
43 } |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
44 } |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
45 |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
46 /** |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
47 * Setter for XML document helper. |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
48 * |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
49 * @param util The helper for storing map information. |
29
77cfa8092611
Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
50 */ |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
51 public void setUtil(MapToXMLUtils util) { |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
52 this.util = util; |
29
77cfa8092611
Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
53 } |
77cfa8092611
Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
54 |
77cfa8092611
Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
55 /** |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
56 * Reads the Layer content. |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
57 * |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
58 * @return The layer XML element. |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
59 */ |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
60 public Element read() |
74
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
62
diff
changeset
|
61 throws Exception { |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
62 logger.debug("read()"); |
74
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
62
diff
changeset
|
63 Element layerElement = util.addLayer(); |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
64 |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
65 layerElement.setAttribute("name", layer.getName()); |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
66 layerElement.setAttribute("min_scale", |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
67 String.valueOf(layer.getMinimumScale())); |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
68 layerElement.setAttribute("max_scale", |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
69 String.valueOf(layer.getMaximumScale())); |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
70 if(layer.isVisible()) { |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
71 layerElement.setAttribute("status", "on"); |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
72 } |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
73 else { |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
74 layerElement.setAttribute("status", "off"); |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
75 } |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
76 |
40
a1bc7220efe7
Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
77 int type = layer.getShapeType(); |
a1bc7220efe7
Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
78 switch (type) { |
62
e468cf8701ea
Prepared the converter to handle and write line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
58
diff
changeset
|
79 case 0: layerElement.setAttribute("type", "none"); break; |
e468cf8701ea
Prepared the converter to handle and write line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
58
diff
changeset
|
80 case 1: layerElement.setAttribute("type", "point"); break; |
e468cf8701ea
Prepared the converter to handle and write line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
58
diff
changeset
|
81 case 3: layerElement.setAttribute("type", "line"); break; |
97
18e4f143896b
Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
82 case 4: layerElement.setAttribute("type", "polygon"); break; |
40
a1bc7220efe7
Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
83 } |
a1bc7220efe7
Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
84 |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
85 layerElement.setAttribute("definition_query", |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
86 layer.getDefinitionExpression()); |
42
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
87 IName fcn = layer.getDataSourceName(); |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
88 if(fcn instanceof FeatureClassName) { |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
89 FeatureClassName name = (FeatureClassName)fcn; |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
90 layerElement.setAttribute("data_source", name.getName()); |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
91 } |
100
bab3946a8bdc
Read the connection settings for file geodatabase.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
92 else { |
bab3946a8bdc
Read the connection settings for file geodatabase.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
93 logger.debug ("Unknown FeatureClass name:" + fcn.getClass().toString()); |
bab3946a8bdc
Read the connection settings for file geodatabase.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
94 } |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
95 |
100
bab3946a8bdc
Read the connection settings for file geodatabase.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
96 |
bab3946a8bdc
Read the connection settings for file geodatabase.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
97 String datatype = layer.getDataSourceType(); |
bab3946a8bdc
Read the connection settings for file geodatabase.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
98 if(datatype.equals("Shapefile Feature Class")) { |
bab3946a8bdc
Read the connection settings for file geodatabase.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
99 layerElement.setAttribute("connection_type", "local"); |
bab3946a8bdc
Read the connection settings for file geodatabase.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
100 layerElement.setAttribute( |
bab3946a8bdc
Read the connection settings for file geodatabase.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
101 "workspace", |
bab3946a8bdc
Read the connection settings for file geodatabase.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
102 layer.getWorkspace().getPathName()); |
bab3946a8bdc
Read the connection settings for file geodatabase.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
103 } |
bab3946a8bdc
Read the connection settings for file geodatabase.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
104 else if(datatype.equals("File Geodatabase Feature Class")){ |
bab3946a8bdc
Read the connection settings for file geodatabase.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
105 layerElement.setAttribute("connection_type", "ogr"); |
bab3946a8bdc
Read the connection settings for file geodatabase.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
106 layerElement.setAttribute("data", layer.getFeatureClass().getFeatureDataset().getName()); |
bab3946a8bdc
Read the connection settings for file geodatabase.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
107 layerElement.setAttribute( |
bab3946a8bdc
Read the connection settings for file geodatabase.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
108 "workspace", |
bab3946a8bdc
Read the connection settings for file geodatabase.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
109 layer.getWorkspace().getPathName()); |
bab3946a8bdc
Read the connection settings for file geodatabase.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
110 |
bab3946a8bdc
Read the connection settings for file geodatabase.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
111 } |
bab3946a8bdc
Read the connection settings for file geodatabase.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
112 else if(datatype.equals("SDE Feature Class")) { |
bab3946a8bdc
Read the connection settings for file geodatabase.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
113 //TODO Read SDE data settings |
bab3946a8bdc
Read the connection settings for file geodatabase.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
114 } |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
115 return layerElement; |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
116 } |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
117 } |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
118 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |