Mercurial > mxd2map
annotate src/java/de/intevation/mxd/reader/FeatureLayerReader.java @ 76:3087c89a5bb8
Added line fill symbol reader.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Fri, 27 May 2011 12:32:08 +0200 |
parents | 7eba97e8201b |
children | 59e06c405a9a |
rev | line source |
---|---|
33
c51376f8e24c
Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents:
31
diff
changeset
|
1 package de.intevation.mxd.reader; |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
2 |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
3 import java.io.IOException; |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
4 |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
5 import org.apache.log4j.Logger; |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
6 |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
7 import com.esri.arcgis.carto.ILayer; |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
8 import com.esri.arcgis.carto.FeatureLayer; |
42
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
9 import com.esri.arcgis.geodatabase.FeatureClassName; |
58
4e0464c620f0
Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
10 import com.esri.arcgis.geodatabase.IDataset; |
4e0464c620f0
Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
11 import com.esri.arcgis.geodatabase.IFeatureClass; |
42
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
12 import com.esri.arcgis.system.IName; |
29
77cfa8092611
Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
13 |
77cfa8092611
Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
14 import org.w3c.dom.Element; |
77cfa8092611
Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
15 |
33
c51376f8e24c
Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents:
31
diff
changeset
|
16 import de.intevation.mxd.utils.MapToXMLUtils; |
c51376f8e24c
Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents:
31
diff
changeset
|
17 |
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 */ |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
64 public Element read() |
74
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
62
diff
changeset
|
65 throws Exception { |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
66 logger.debug("read()"); |
74
7eba97e8201b
Catch all exceptions in the MXDReader.
Raimund Renkert <rrenkert@intevation.de>
parents:
62
diff
changeset
|
67 Element layerElement = util.addLayer(); |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
68 |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
69 layerElement.setAttribute("name", layer.getName()); |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
70 layerElement.setAttribute("min_scale", |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
71 String.valueOf(layer.getMinimumScale())); |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
72 layerElement.setAttribute("max_scale", |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
73 String.valueOf(layer.getMaximumScale())); |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
74 if(layer.isVisible()) { |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
75 layerElement.setAttribute("status", "on"); |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
76 } |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
77 else { |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
78 layerElement.setAttribute("status", "off"); |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
79 } |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
80 |
40
a1bc7220efe7
Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
81 int type = layer.getShapeType(); |
a1bc7220efe7
Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
82 switch (type) { |
62
e468cf8701ea
Prepared the converter to handle and write line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
58
diff
changeset
|
83 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
|
84 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
|
85 case 3: layerElement.setAttribute("type", "line"); break; |
40
a1bc7220efe7
Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
86 } |
a1bc7220efe7
Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
87 |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
88 layerElement.setAttribute("definition_query", |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
89 layer.getDefinitionExpression()); |
42
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
90 IName fcn = layer.getDataSourceName(); |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
91 if(fcn instanceof FeatureClassName) { |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
92 FeatureClassName name = (FeatureClassName)fcn; |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
93 layerElement.setAttribute("data_source", name.getName()); |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
94 } |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
95 |
58
4e0464c620f0
Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
96 layerElement.setAttribute( |
4e0464c620f0
Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
97 "workspace", |
4e0464c620f0
Introduced the picture symbol reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
98 layer.getWorkspace().getPathName()); |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
99 return layerElement; |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
100 } |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
101 } |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
102 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |