annotate src/java/de/intevation/mxd/reader/FeatureLayerReader.java @ 131:cd18c61cbcf6

Do not write lines or outlines if their width is smaller than 1.0.
author vc11884admin@VC11884.win.bsh.de
date Mon, 20 Jun 2011 17:41:55 +0200
parents 5991c1f90f91
children 6b80d2c7536e
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;
113
0db6eacad0e6 Read SDE connection settings.
vc11884admin@VC11884.win.bsh.de
parents: 100
diff changeset
9 import com.esri.arcgis.system.IPropertySet;
29
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;
117
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
13 import java.io.IOException;
33
c51376f8e24c Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents: 31
diff changeset
14
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
15 /**
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 42
diff changeset
16 * Reads Layer information.
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
17 *
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
18 * @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
19 */
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 42
diff changeset
20 public class FeatureLayerReader
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 42
diff changeset
21 implements ILayerReader {
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
22
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
23 /**
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
24 * The logger.
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
25 */
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
26 private static final Logger logger =
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
27 Logger.getLogger(FeatureLayerReader.class);
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
28
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
29 /**
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
30 * Privte member.
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
31 */
29
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
32 private FeatureLayer layer;
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
33 private MapToXMLUtils util;
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
34
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
35
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
36 public FeatureLayerReader(ILayer layer)
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
37 throws Exception {
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 42
diff changeset
38 if(layer instanceof FeatureLayer) {
29
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
39 this.layer = (FeatureLayer)layer;
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 42
diff changeset
40 }
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 42
diff changeset
41 else {
29
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
42 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
43 layer.getClass().toString());
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 42
diff changeset
44 }
25
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
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
47 /**
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
48 * Setter for XML document helper.
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
49 *
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
50 * @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
51 */
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 42
diff changeset
52 public void setUtil(MapToXMLUtils util) {
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
53 this.util = util;
29
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
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
56 /**
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
57 * Reads the Layer content.
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
58 *
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
59 * @return The layer XML element.
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
60 */
118
39957898c694 Improved top level exception handling and logging.
Raimund Renkert <rrenkert@intevation.de>
parents: 117
diff changeset
61 public Element read()
39957898c694 Improved top level exception handling and logging.
Raimund Renkert <rrenkert@intevation.de>
parents: 117
diff changeset
62 throws IOException{
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
63 logger.debug("read()");
117
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
64 Element layerElement;
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
65 try {
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
66 layerElement = util.addLayer();
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
67 }
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
68 catch(Exception e) {
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
69 logger.error("Failed to create DOM-Element for Layer.");
118
39957898c694 Improved top level exception handling and logging.
Raimund Renkert <rrenkert@intevation.de>
parents: 117
diff changeset
70 throw new IOException(
39957898c694 Improved top level exception handling and logging.
Raimund Renkert <rrenkert@intevation.de>
parents: 117
diff changeset
71 this.getClass()+toString() +
39957898c694 Improved top level exception handling and logging.
Raimund Renkert <rrenkert@intevation.de>
parents: 117
diff changeset
72 "Error creating dom element");
117
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
73 }
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
74
117
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
75 try {
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
76 layerElement.setAttribute("name", layer.getName());
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
77 }
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
78 catch(IOException ioe) {
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
79 logger.warn(
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
80 "Could not read name." +
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
81 " Setting name to \"default-layer\"");
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
82 layerElement.setAttribute("name", "default-layer");
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
83 }
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
84
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
85 try {
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
86 layerElement.setAttribute("min_scale",
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
87 String.valueOf(layer.getMinimumScale()));
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
88 }
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
89 catch(IOException ioe) {
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
90 logger.warn(
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
91 "Could not read minimum scale." +
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
92 " Setting minimum scale to 0.");
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
93 layerElement.setAttribute("min_scale", "0");
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
94 }
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
95
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
96 try {
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
97 layerElement.setAttribute("max_scale",
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
98 String.valueOf(layer.getMaximumScale()));
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
99 }
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
100 catch(IOException ioe) {
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
101 logger.warn(
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
102 "Could not read maximum scale." +
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
103 " Setting maximum scale to 0.");
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
104 layerElement.setAttribute("max_scale", "0");
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
105 }
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
106
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
107 try {
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
108 if(layer.isVisible()) {
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
109 layerElement.setAttribute("status", "on");
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
110 }
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
111 else {
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
112 layerElement.setAttribute("status", "off");
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
113 }
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
114 }
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
115 catch(IOException ioe) {
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
116 logger.warn(
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
117 "Could not read layer status." +
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
118 " Setting layer status to \"on\".");
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
119 layerElement.setAttribute("status", "on");
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
120 }
117
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
121
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
122 int type = 0;
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
123 try {
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
124 type = layer.getShapeType();
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
125 }
117
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
126 catch(IOException ioe) {
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
127 logger.warn(
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
128 "Could not read shape type." +
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
129 " Setting shape type to \"none\".");
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
130 type = 0;
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
131 }
40
a1bc7220efe7 Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
132 switch (type) {
62
e468cf8701ea Prepared the converter to handle and write line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents: 58
diff changeset
133 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
134 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
135 case 3: layerElement.setAttribute("type", "line"); break;
97
18e4f143896b Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents: 83
diff changeset
136 case 4: layerElement.setAttribute("type", "polygon"); break;
40
a1bc7220efe7 Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
137 }
a1bc7220efe7 Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
138
117
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
139 try {
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
140 layerElement.setAttribute("definition_query",
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
141 layer.getDefinitionExpression());
42
395307e8b7ee First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
142 }
117
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
143 catch(IOException ioe) {
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
144 logger.warn(
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
145 "Could not read definition query." +
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
146 " Setting empty definition query.");
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
147 layerElement.setAttribute("definition_query", "");
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
148 }
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
149 try {
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
150 IName fcn = layer.getDataSourceName();
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
151 if(fcn instanceof FeatureClassName) {
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
152 FeatureClassName name = (FeatureClassName)fcn;
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
153 layerElement.setAttribute("data_source", name.getName());
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
154 }
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
155 else {
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
156 logger.debug (
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
157 "Unknown FeatureClass name:" +
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
158 fcn.getClass().toString());
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
159 }
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
160 }
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
161 catch(IOException ioe) {
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
162 logger.warn("Could not read datasource. Stopped reading layer.");
118
39957898c694 Improved top level exception handling and logging.
Raimund Renkert <rrenkert@intevation.de>
parents: 117
diff changeset
163 throw new IOException(
39957898c694 Improved top level exception handling and logging.
Raimund Renkert <rrenkert@intevation.de>
parents: 117
diff changeset
164 this.getClass().toString() +
39957898c694 Improved top level exception handling and logging.
Raimund Renkert <rrenkert@intevation.de>
parents: 117
diff changeset
165 "Error reading datasource.");
100
bab3946a8bdc Read the connection settings for file geodatabase.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
166 }
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
167
117
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
168 try {
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
169 String datatype = layer.getDataSourceType();
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
170 if(datatype.equals("Shapefile Feature Class")) {
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
171 layerElement.setAttribute("connection_type", "local");
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
172 layerElement.setAttribute(
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
173 "workspace",
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
174 layer.getWorkspace().getPathName());
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
175 }
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
176 else if(datatype.equals("File Geodatabase Feature Class")){
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
177 layerElement.setAttribute("connection_type", "ogr");
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
178 layerElement.setAttribute("data", layer.getFeatureClass().getFeatureDataset().getName());
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
179 layerElement.setAttribute(
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
180 "workspace",
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
181 layer.getWorkspace().getPathName());
100
bab3946a8bdc Read the connection settings for file geodatabase.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
182
117
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
183 }
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
184 else if(datatype.equals("SDE Feature Class")) {
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
185 IPropertySet set = layer.getWorkspace().getConnectionProperties();
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
186 Object names[] = new Object[set.getCount()];
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
187 Object prop[] = new Object[set.getCount()];
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
188 set.getAllProperties(names, prop);
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
189 layerElement.setAttribute("connection_type", "SDE");
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
190 for(int i = 0; i < names.length; i++) {
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
191 if(names[i] != null) {
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
192 String[] prop_names = (String[])names[i];
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
193 for(int j = 0; j < prop_names.length; j++) {
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
194 layerElement.setAttribute(
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
195 prop_names[j].toLowerCase(),
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
196 set.getProperty(prop_names[j]).toString());
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
197 }
113
0db6eacad0e6 Read SDE connection settings.
vc11884admin@VC11884.win.bsh.de
parents: 100
diff changeset
198 }
0db6eacad0e6 Read SDE connection settings.
vc11884admin@VC11884.win.bsh.de
parents: 100
diff changeset
199 }
130
5991c1f90f91 Added data source "SDE" to writer.
vc11884admin@VC11884.win.bsh.de
parents: 118
diff changeset
200 layerElement.setAttribute(
5991c1f90f91 Added data source "SDE" to writer.
vc11884admin@VC11884.win.bsh.de
parents: 118
diff changeset
201 "join_table",
5991c1f90f91 Added data source "SDE" to writer.
vc11884admin@VC11884.win.bsh.de
parents: 118
diff changeset
202 layer.getRelationshipClass()
5991c1f90f91 Added data source "SDE" to writer.
vc11884admin@VC11884.win.bsh.de
parents: 118
diff changeset
203 .getOriginClass().getAliasName());
5991c1f90f91 Added data source "SDE" to writer.
vc11884admin@VC11884.win.bsh.de
parents: 118
diff changeset
204 layerElement.setAttribute(
5991c1f90f91 Added data source "SDE" to writer.
vc11884admin@VC11884.win.bsh.de
parents: 118
diff changeset
205 "join_field",
5991c1f90f91 Added data source "SDE" to writer.
vc11884admin@VC11884.win.bsh.de
parents: 118
diff changeset
206 layer.getRelationshipClass().getOriginPrimaryKey());
5991c1f90f91 Added data source "SDE" to writer.
vc11884admin@VC11884.win.bsh.de
parents: 118
diff changeset
207 layerElement.setAttribute(
5991c1f90f91 Added data source "SDE" to writer.
vc11884admin@VC11884.win.bsh.de
parents: 118
diff changeset
208 "join_table_target",
5991c1f90f91 Added data source "SDE" to writer.
vc11884admin@VC11884.win.bsh.de
parents: 118
diff changeset
209 layer.getRelationshipClass()
5991c1f90f91 Added data source "SDE" to writer.
vc11884admin@VC11884.win.bsh.de
parents: 118
diff changeset
210 .getDestinationClass().getAliasName());
5991c1f90f91 Added data source "SDE" to writer.
vc11884admin@VC11884.win.bsh.de
parents: 118
diff changeset
211 layerElement.setAttribute(
5991c1f90f91 Added data source "SDE" to writer.
vc11884admin@VC11884.win.bsh.de
parents: 118
diff changeset
212 "join_field_target",
5991c1f90f91 Added data source "SDE" to writer.
vc11884admin@VC11884.win.bsh.de
parents: 118
diff changeset
213 layer.getRelationshipClass().getOriginForeignKey());
113
0db6eacad0e6 Read SDE connection settings.
vc11884admin@VC11884.win.bsh.de
parents: 100
diff changeset
214 }
100
bab3946a8bdc Read the connection settings for file geodatabase.
Raimund Renkert <rrenkert@intevation.de>
parents: 97
diff changeset
215 }
117
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
216 catch(Exception e) {
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
217 logger.error(
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
218 "Could not read layer datasource." +
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
219 " Stopped reading layer.");
118
39957898c694 Improved top level exception handling and logging.
Raimund Renkert <rrenkert@intevation.de>
parents: 117
diff changeset
220 throw new IOException(
39957898c694 Improved top level exception handling and logging.
Raimund Renkert <rrenkert@intevation.de>
parents: 117
diff changeset
221 this.getClass().toString() +
39957898c694 Improved top level exception handling and logging.
Raimund Renkert <rrenkert@intevation.de>
parents: 117
diff changeset
222 " Error reading data source.");
117
6c3d880db7c5 Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 113
diff changeset
223 }
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
224 return layerElement;
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
225 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
226 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
227 // 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)