annotate src/java/de/intevation/mxd/reader/FeatureLayerReader.java @ 55:f0c02ff120d6

Read filenames from properties file or commandline arguments.
author Raimund Renkert <rrenkert@intevation.de>
date Mon, 16 May 2011 18:21:27 +0200
parents ef7ca23c4233
children 4e0464c620f0
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;
395307e8b7ee First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
10 import com.esri.arcgis.system.IName;
29
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
11
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
12 import org.w3c.dom.Element;
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
13
33
c51376f8e24c Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents: 31
diff changeset
14 import de.intevation.mxd.utils.MapToXMLUtils;
c51376f8e24c Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents: 31
diff changeset
15
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
16 /**
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 42
diff changeset
17 * Reads Layer information.
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
18 *
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
19 * @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
20 */
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 42
diff changeset
21 public class FeatureLayerReader
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 42
diff changeset
22 implements ILayerReader {
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
23
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
24 /**
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
25 * The logger.
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 private static final Logger logger =
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
28 Logger.getLogger(FeatureLayerReader.class);
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
29
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
30 /**
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
31 * Privte member.
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
32 */
29
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
33 private FeatureLayer layer;
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
34 private MapToXMLUtils util;
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
35
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
36
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
37 public FeatureLayerReader(ILayer layer)
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
38 throws Exception {
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 42
diff changeset
39 if(layer instanceof FeatureLayer) {
29
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
40 this.layer = (FeatureLayer)layer;
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 42
diff changeset
41 }
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 42
diff changeset
42 else {
29
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
43 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
44 layer.getClass().toString());
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 42
diff changeset
45 }
25
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
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
48 /**
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
49 * Setter for XML document helper.
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
50 *
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
51 * @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
52 */
43
ef7ca23c4233 Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents: 42
diff changeset
53 public void setUtil(MapToXMLUtils util) {
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
54 this.util = util;
29
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
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
57 /**
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
58 * Reads the Layer content.
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
59 *
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
60 * @return The layer XML element.
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
61 */
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
62 public Element read()
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
63 throws IOException {
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
64 logger.debug("read()");
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
65 Element layerElement;
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
66 try {
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
67 layerElement = util.addLayer();
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
68 }
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
69 catch(Exception e) {
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
70 e.printStackTrace();
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
71 return null;
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
72 }
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
73
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
74 layerElement.setAttribute("name", layer.getName());
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
75 layerElement.setAttribute("min_scale",
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
76 String.valueOf(layer.getMinimumScale()));
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
77 layerElement.setAttribute("max_scale",
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
78 String.valueOf(layer.getMaximumScale()));
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
79 if(layer.isVisible()) {
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
80 layerElement.setAttribute("status", "on");
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
81 }
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
82 else {
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
83 layerElement.setAttribute("status", "off");
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
84 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
85
40
a1bc7220efe7 Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
86 int type = layer.getShapeType();
a1bc7220efe7 Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
87 switch (type) {
a1bc7220efe7 Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
88 case 0: layerElement.setAttribute("type", "none");
a1bc7220efe7 Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
89 case 1: layerElement.setAttribute("type", "point");
a1bc7220efe7 Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
90 }
a1bc7220efe7 Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents: 34
diff changeset
91
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
92 layerElement.setAttribute("definition_query",
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
93 layer.getDefinitionExpression());
42
395307e8b7ee First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
94 IName fcn = layer.getDataSourceName();
395307e8b7ee First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
95 if(fcn instanceof FeatureClassName) {
395307e8b7ee First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
96 FeatureClassName name = (FeatureClassName)fcn;
395307e8b7ee First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
97 layerElement.setAttribute("data_source", name.getName());
395307e8b7ee First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents: 40
diff changeset
98 }
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
99
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
100 return layerElement;
25
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 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
103 // 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)