Mercurial > mxd2map
annotate src/java/de/intevation/mxd/reader/FeatureLayerReader.java @ 180:f4eb506499f5
Done some code styling and removed TODOs.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Mon, 11 Jul 2011 12:11:08 +0200 |
parents | f3a91cd7440b |
children | 0bde090506f9 |
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; |
179
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
7 import com.esri.arcgis.carto.AnnotateLayerPropertiesCollection; |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
8 import com.esri.arcgis.carto.IAnnotateLayerProperties; |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
9 import com.esri.arcgis.carto.LabelEngineLayerProperties; |
42
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
10 import com.esri.arcgis.geodatabase.FeatureClassName; |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
11 import com.esri.arcgis.system.IName; |
113
0db6eacad0e6
Read SDE connection settings.
vc11884admin@VC11884.win.bsh.de
parents:
100
diff
changeset
|
12 import com.esri.arcgis.system.IPropertySet; |
29
77cfa8092611
Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
13 import org.w3c.dom.Element; |
77cfa8092611
Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
14 |
33
c51376f8e24c
Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents:
31
diff
changeset
|
15 import de.intevation.mxd.utils.MapToXMLUtils; |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
16 import java.io.IOException; |
133
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
17 import com.esri.arcgis.interop.AutomationException; |
25
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 * Reads Layer information. |
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 * @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
|
22 */ |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
23 public class FeatureLayerReader |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
24 implements ILayerReader { |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
25 |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
26 /** |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
27 * The logger. |
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 private static final Logger logger = |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
30 Logger.getLogger(FeatureLayerReader.class); |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
31 |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
32 /** |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
33 * Privte member. |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
34 */ |
29
77cfa8092611
Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
35 private FeatureLayer layer; |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
36 private MapToXMLUtils util; |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
37 |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
38 |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
39 public FeatureLayerReader(ILayer layer) |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
40 throws Exception { |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
41 if(layer instanceof FeatureLayer) { |
29
77cfa8092611
Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
42 this.layer = (FeatureLayer)layer; |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
43 } |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
44 else { |
29
77cfa8092611
Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
45 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
|
46 layer.getClass().toString()); |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
47 } |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
48 } |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
49 |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
50 /** |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
51 * Setter for XML document helper. |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
52 * |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
53 * @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
|
54 */ |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
55 public void setUtil(MapToXMLUtils util) { |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
56 this.util = util; |
29
77cfa8092611
Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
57 } |
77cfa8092611
Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
58 |
77cfa8092611
Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
59 /** |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
60 * Reads the Layer content. |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
61 * |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
62 * @return The layer XML element. |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
63 */ |
118
39957898c694
Improved top level exception handling and logging.
Raimund Renkert <rrenkert@intevation.de>
parents:
117
diff
changeset
|
64 public Element read() |
39957898c694
Improved top level exception handling and logging.
Raimund Renkert <rrenkert@intevation.de>
parents:
117
diff
changeset
|
65 throws IOException{ |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
66 logger.debug("read()"); |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
67 Element layerElement; |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
68 try { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
69 layerElement = util.addLayer(); |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
70 } |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
71 catch(Exception e) { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
72 logger.error("Failed to create DOM-Element for Layer."); |
133
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
73 return null; |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
74 } |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
75 |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
76 try { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
77 layerElement.setAttribute("name", layer.getName()); |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
78 } |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
79 catch(IOException ioe) { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
80 logger.warn( |
135
a4ab239509f1
Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents:
133
diff
changeset
|
81 "Could not read layer name." + |
a4ab239509f1
Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents:
133
diff
changeset
|
82 " Stopped reading layer."); |
a4ab239509f1
Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents:
133
diff
changeset
|
83 throw new IOException("Error reading layer name."); |
117
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 |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
86 try { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
87 layerElement.setAttribute("min_scale", |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
88 String.valueOf(layer.getMinimumScale())); |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
89 } |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
90 catch(IOException ioe) { |
135
a4ab239509f1
Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents:
133
diff
changeset
|
91 logger.warn("Could not read minimum scale."); |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
92 } |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
93 |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
94 try { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
95 layerElement.setAttribute("max_scale", |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
96 String.valueOf(layer.getMaximumScale())); |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
97 } |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
98 catch(IOException ioe) { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
99 logger.warn( |
135
a4ab239509f1
Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents:
133
diff
changeset
|
100 "Could not read maximum scale."); |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
101 } |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
102 |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
103 try { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
104 if(layer.isVisible()) { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
105 layerElement.setAttribute("status", "on"); |
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 else { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
108 layerElement.setAttribute("status", "off"); |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
109 } |
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 catch(IOException ioe) { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
112 logger.warn( |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
113 "Could not read layer status." + |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
114 " Setting layer status to \"on\"."); |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
115 layerElement.setAttribute("status", "on"); |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
116 } |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
117 |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
118 int type = 0; |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
119 try { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
120 type = layer.getShapeType(); |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
121 } |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
122 catch(IOException ioe) { |
135
a4ab239509f1
Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents:
133
diff
changeset
|
123 logger.warn("Could not read shape type."); |
a4ab239509f1
Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents:
133
diff
changeset
|
124 throw new IOException("Error reading shape type."); |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
125 } |
40
a1bc7220efe7
Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
126 switch (type) { |
62
e468cf8701ea
Prepared the converter to handle and write line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
58
diff
changeset
|
127 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
|
128 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
|
129 case 3: layerElement.setAttribute("type", "line"); break; |
97
18e4f143896b
Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
130 case 4: layerElement.setAttribute("type", "polygon"); break; |
40
a1bc7220efe7
Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
131 } |
a1bc7220efe7
Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
132 |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
133 try { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
134 layerElement.setAttribute("definition_query", |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
135 layer.getDefinitionExpression()); |
42
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
136 } |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
137 catch(IOException ioe) { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
138 logger.warn( |
135
a4ab239509f1
Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents:
133
diff
changeset
|
139 "Could not read definition query."); |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
140 } |
179
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
141 |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
142 try { |
180
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
143 AnnotateLayerPropertiesCollection annotation = |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
144 (AnnotateLayerPropertiesCollection) |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
145 layer.getAnnotationProperties(); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
146 |
179
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
147 if (layer.isDisplayAnnotation() && annotation.getCount() > 0){ |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
148 for(int i = 0; i < annotation.getCount(); i++) { |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
149 IAnnotateLayerProperties prop = annotation.getProperties(0); |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
150 if(prop instanceof LabelEngineLayerProperties) { |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
151 try { |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
152 LabelEngineReader lr = new LabelEngineReader(prop); |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
153 lr.setParent(layerElement); |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
154 lr.setUtil(util); |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
155 lr.read(); |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
156 } |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
157 catch(Exception e) { |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
158 logger.warn("Could not read label properties."); |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
159 } |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
160 } |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
161 } |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
162 } |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
163 } |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
164 catch(IOException ioe) { |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
165 logger.warn("Could not read Annotation properties."); |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
166 } |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
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 IName fcn = layer.getDataSourceName(); |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
170 if(fcn instanceof FeatureClassName) { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
171 FeatureClassName name = (FeatureClassName)fcn; |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
172 layerElement.setAttribute("data_source", name.getName()); |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
173 } |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
174 else { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
175 logger.debug ( |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
176 "Unknown FeatureClass name:" + |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
177 fcn.getClass().toString()); |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
178 } |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
179 } |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
180 catch(IOException ioe) { |
133
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
181 logger.warn( |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
182 "Could not read datasource." + |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
183 " Stopped reading layer " + layer.getName() + "."); |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
184 util.removeLayer(layerElement); |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
185 return null; |
100
bab3946a8bdc
Read the connection settings for file geodatabase.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
186 } |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
187 |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
188 try { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
189 String datatype = layer.getDataSourceType(); |
133
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
190 if(layer.getWorkspace().getType() == 0) { |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
191 layerElement.setAttribute("connection_type", "local"); |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
192 layerElement.setAttribute( |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
193 "workspace", |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
194 layer.getWorkspace().getPathName()); |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
195 } |
133
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
196 else if(layer.getWorkspace().getType() == 1){ |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
197 layerElement.setAttribute("connection_type", "ogr"); |
133
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
198 layerElement.setAttribute( |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
199 "data", |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
200 layer.getFeatureClass().getFeatureDataset().getName()); |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
201 layerElement.setAttribute( |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
202 "workspace", |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
203 layer.getWorkspace().getPathName()); |
100
bab3946a8bdc
Read the connection settings for file geodatabase.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
204 |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
205 } |
133
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
206 else if(layer.getWorkspace().getType() == 2) { |
180
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
207 IPropertySet set = |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
208 layer.getWorkspace().getConnectionProperties(); |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
209 Object names[] = new Object[set.getCount()]; |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
210 Object prop[] = new Object[set.getCount()]; |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
211 set.getAllProperties(names, prop); |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
212 layerElement.setAttribute("connection_type", "SDE"); |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
213 for(int i = 0; i < names.length; i++) { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
214 if(names[i] != null) { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
215 String[] prop_names = (String[])names[i]; |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
216 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
|
217 layerElement.setAttribute( |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
218 prop_names[j].toLowerCase(), |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
219 set.getProperty(prop_names[j]).toString()); |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
220 } |
113
0db6eacad0e6
Read SDE connection settings.
vc11884admin@VC11884.win.bsh.de
parents:
100
diff
changeset
|
221 } |
0db6eacad0e6
Read SDE connection settings.
vc11884admin@VC11884.win.bsh.de
parents:
100
diff
changeset
|
222 } |
133
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
223 try { |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
224 layerElement.setAttribute( |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
225 "join_table", |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
226 layer.getRelationshipClass() |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
227 .getOriginClass().getAliasName()); |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
228 layerElement.setAttribute( |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
229 "join_field", |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
230 layer.getRelationshipClass().getOriginPrimaryKey()); |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
231 layerElement.setAttribute( |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
232 "join_table_target", |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
233 layer.getRelationshipClass() |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
234 .getDestinationClass().getAliasName()); |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
235 layerElement.setAttribute( |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
236 "join_field_target", |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
237 layer.getRelationshipClass().getOriginForeignKey()); |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
238 } |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
239 catch(AutomationException ioe) { |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
240 //Do nothing, cause no jointable defined. |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
241 } |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
242 catch(IOException ae) { |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
243 //Do nothing, cause no jointable defined. |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
244 } |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
245 catch(NullPointerException npe) { |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
246 //Do nothing, cause no jointable defined. |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
247 } |
113
0db6eacad0e6
Read SDE connection settings.
vc11884admin@VC11884.win.bsh.de
parents:
100
diff
changeset
|
248 } |
100
bab3946a8bdc
Read the connection settings for file geodatabase.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
249 } |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
250 catch(Exception e) { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
251 logger.error( |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
252 "Could not read layer datasource." + |
133
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
253 " Stopped reading layer " + layer.getName() + "."); |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
254 util.removeLayer(layerElement); |
135
a4ab239509f1
Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents:
133
diff
changeset
|
255 return null; |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
256 } |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
257 return layerElement; |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
258 } |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
259 } |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
260 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |