annotate src/java/de/intevation/mxd/reader/FeatureLayerReader.java @ 33:c51376f8e24c

Separated converter components into packages.
author Raimund Renkert <rrenkert@intevation.de>
date Tue, 12 Apr 2011 13:20:49 +0200
parents 40c0b4e5f91a
children 7a927921eb6c
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;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
9 import com.esri.arcgis.geometry.ISpatialReference;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
10 import com.esri.arcgis.geometry.ProjectedCoordinateSystem;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
11 import com.esri.arcgis.geometry.IProjection;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
12 import com.esri.arcgis.geometry.Projection;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
13 import com.esri.arcgis.display.ISymbol;
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
14 import com.esri.arcgis.display.SimpleMarkerSymbol;
29
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
15
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
16 import org.w3c.dom.Attr;
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
17 import org.w3c.dom.Document;
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
18 import org.w3c.dom.Element;
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
19 import org.w3c.dom.Node;
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
20 import org.w3c.dom.NodeList;
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
21
33
c51376f8e24c Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents: 31
diff changeset
22 import de.intevation.mxd.utils.MapToXMLUtils;
c51376f8e24c Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents: 31
diff changeset
23
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
24 /**
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
25 * Reads Layer information..
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
26 *
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
27 * @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
28 */
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
29 public class FeatureLayerReader implements ILayerReader{
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
30
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
31 /**
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
32 * The logger.
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
33 */
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
34 private static final Logger logger =
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
35 Logger.getLogger(FeatureLayerReader.class);
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
36
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
37 /**
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
38 * Privte member.
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
39 */
29
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
40 private FeatureLayer layer;
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
41 private MapToXMLUtils util;
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
42
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
43
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
44 public FeatureLayerReader(ILayer layer)
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
45 throws Exception {
29
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
46 if(layer instanceof FeatureLayer)
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
47 this.layer = (FeatureLayer)layer;
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
48 else
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
49 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
50 layer.getClass().toString());
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
51 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
52
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
53 /**
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
54 * Setter for XML document helper.
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
55 *
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
56 * @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
57 */
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
58 public void setUtil(MapToXMLUtils util){
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
59 this.util = util;
29
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
60 }
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
61
77cfa8092611 Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents: 26
diff changeset
62 /**
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
63 * Reads the Layer content.
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
64 *
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
65 * @return The layer XML element.
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
66 */
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
67 public Element read()
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
68 throws IOException {
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
69 logger.debug("read()");
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
70 Element layerElement;
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
71 try {
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
72 layerElement = util.addLayer();
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
73 }
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
74 catch(Exception e) {
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
75 e.printStackTrace();
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
76 return null;
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
77 }
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
78
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
79 layerElement.setAttribute("name", layer.getName());
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
80 layerElement.setAttribute("min_scale",
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
81 String.valueOf(layer.getMinimumScale()));
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
82 layerElement.setAttribute("max_scale",
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
83 String.valueOf(layer.getMaximumScale()));
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
84 if(layer.isVisible()) {
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
85 layerElement.setAttribute("status", "on");
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
86 }
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
87 else {
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
88 layerElement.setAttribute("status", "off");
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
89 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
90
31
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
91 layerElement.setAttribute("definition_query",
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
92 layer.getDefinitionExpression());
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
93
40c0b4e5f91a Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents: 29
diff changeset
94 return layerElement;
25
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
95 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
96 }
cbd67b1100d8 Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff changeset
97 // 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)