annotate src/java/de/intevation/mxd/reader/GraphicsSubLayerReader.java @ 342:dd90ea1d0d30

Switched to ISO-8859-1 wms_encoding.
author Bjoern Schilberg <bjoern@intevation.de>
date Wed, 14 Nov 2012 13:10:55 +0100
parents b6c0fbae16dc
children
rev   line source
321
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
1 /*
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
2 * Copyright (c) 2012 by Intevation GmbH, Germany <info@intevation.de>
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
3 *
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
4 * This file is part of MXD2map.
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
5 *
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
6 * This program is free software under the LGPL (>=v2.1)
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
7 * Read the file LICENCE.txt coming with the software for details
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
8 * or visit http://www.gnu.org/licenses/ if it does not exist.
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
9 *
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
10 * MXD2map has been developed on behalf of the
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
11 * Bundesamt fuer Seeschifffahrt und Hydrographie (BSH) in Hamburg
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
12 * by Intevation GmbH.
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
13 *
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
14 * Authors:
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
15 * Raimund Renkert <raimund.renkert@intevation.de>
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
16 * Bjoern Schilberg <bjoern.schilberg@intevation.de>
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
17 * Stephan Holl <stephan.holl@intevation.de>
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
18 * Andre Heinecke <aheinecke@intevation.de>
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
19 */
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
20
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
21 package de.intevation.mxd.reader;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
22
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
23 import org.apache.log4j.Logger;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
24
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
25 import com.esri.arcgis.carto.IGraphicsLayer;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
26 import com.esri.arcgis.carto.ILayer;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
27 import com.esri.arcgis.carto.GraphicsSubLayer;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
28 import com.esri.arcgis.globecore.GlobeGraphicsLayer;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
29 import com.esri.arcgis.analyst3d.GraphicsLayer3D;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
30 import com.esri.arcgis.carto.GraphicsSubLayer;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
31 import com.esri.arcgis.carto.FDOGraphicsLayer;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
32
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
33 import com.esri.arcgis.carto.AnnotateLayerPropertiesCollection;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
34 import com.esri.arcgis.carto.IAnnotateLayerProperties;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
35 import com.esri.arcgis.carto.LabelEngineLayerProperties;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
36 import com.esri.arcgis.carto.IElement;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
37 import com.esri.arcgis.carto.TextElement;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
38 import com.esri.arcgis.system.IName;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
39 import com.esri.arcgis.system.IPropertySet;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
40 import com.esri.arcgis.geometry.Envelope;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
41 import com.esri.arcgis.geometry.ISpatialReference;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
42 import com.esri.arcgis.geometry.ProjectedCoordinateSystem;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
43 import com.esri.arcgis.geometry.GeographicCoordinateSystem;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
44 import com.esri.arcgis.geometry.UnknownCoordinateSystem;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
45 import com.esri.arcgis.geometry.Projection;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
46 import com.esri.arcgis.geometry.IPoint;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
47
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
48 import com.esri.arcgis.display.ITextSymbol;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
49 import com.esri.arcgis.display.TextSymbol;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
50
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
51 import org.w3c.dom.Element;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
52
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
53 import de.intevation.mxd.utils.MapToXMLUtils;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
54 import java.io.IOException;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
55 import com.esri.arcgis.interop.AutomationException;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
56 /**
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
57 * Reads Layer information.
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
58 *
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
59 * @author <a href="mailto:aheinecke@intevation.de">Andre Heinecke</a>
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
60 */
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
61 public class GraphicsSubLayerReader
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
62 implements ILayerReader {
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
63
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
64 /**
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
65 * The logger.
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
66 */
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
67 private static final Logger logger =
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
68 Logger.getLogger(GraphicsSubLayerReader.class);
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
69
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
70 /**
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
71 * Privte member.
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
72 */
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
73 private GraphicsSubLayer layer;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
74 private MapToXMLUtils util;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
75
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
76 /**
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
77 * Constructor with layer.
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
78 *
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
79 * @param layer The ArcGIS layer object.
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
80 */
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
81 public GraphicsSubLayerReader(GraphicsSubLayer layer) {
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
82 this.layer = layer;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
83 }
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
84
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
85 /**
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
86 * Setter for XML document helper.
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
87 *
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
88 * @param util The helper for storing map information.
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
89 */
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
90 public void setUtil(MapToXMLUtils util) {
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
91 this.util = util;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
92 }
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
93
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
94 /**
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
95 * Reads the Layer content.
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
96 *
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
97 * @return The layer XML element.
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
98 */
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
99 public Element read()
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
100 throws IOException{
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
101 logger.debug("read()");
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
102 Element layerElement = null;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
103 try {
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
104 layerElement = util.addLayer();
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
105 }
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
106 catch(Exception e) {
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
107 logger.error("Failed to create DOM-Element for Layer.");
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
108 return null;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
109 }
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
110
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
111 // Name
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
112 try {
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
113 layerElement.setAttribute("name", layer.getName());
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
114
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
115 }
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
116 catch(Exception e) {
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
117 logger.warn(
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
118 "Could not read layer name." +
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
119 " Stopped reading layer.");
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
120 throw new IOException("Error reading layer name.");
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
121 }
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
122
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
123 // Scale
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
124 try {
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
125 layerElement.setAttribute("min_scale",
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
126 String.valueOf(layer.getMinimumScale()));
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
127 }
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
128 catch(IOException ioe) {
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
129 logger.warn("Could not read minimum scale.");
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
130 }
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
131
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
132 try {
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
133 layerElement.setAttribute("max_scale",
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
134 String.valueOf(layer.getMaximumScale()));
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
135 }
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
136 catch(Exception e) {
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
137 logger.warn(
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
138 "Could not read maximum scale.");
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
139 }
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
140
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
141 // Status
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
142 try {
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
143 if(layer.isVisible()) {
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
144 layerElement.setAttribute("status", "on");
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
145 }
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
146 else {
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
147 layerElement.setAttribute("status", "off");
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
148 }
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
149 }
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
150 catch(Exception e) {
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
151 logger.warn(
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
152 "Could not read layer status." +
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
153 " Setting layer status to \"on\".");
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
154 layerElement.setAttribute("status", "on");
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
155 }
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
156
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
157 // Read the elements
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
158 try {
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
159 int count = 0;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
160 IElement actElement = null;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
161 IElement prevElement = null;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
162 layer.reset(); // Reset the element container
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
163 actElement = layer.next();
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
164 while (actElement != prevElement) {
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
165 prevElement = actElement;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
166 if (actElement instanceof TextElement) {
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
167 TextElement te = (TextElement)actElement;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
168 Element xmlTextElement = util.addFeature(layerElement);
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
169 xmlTextElement.setAttribute("text", te.getText());
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
170
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
171 IPoint poi = te.getGeometry().getEnvelope().getLowerLeft();
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
172 xmlTextElement.setAttribute("X", String.valueOf(poi.getX()));
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
173 xmlTextElement.setAttribute("Y", String.valueOf(poi.getY()));
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
174 xmlTextElement.setAttribute("classId", String.valueOf(count));
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
175
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
176 try {
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
177 ITextSymbol sym = te.getSymbol();
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
178 if(sym instanceof TextSymbol) {
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
179 TextSymbolReader tsr = new TextSymbolReader(sym);
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
180 tsr.setParent(xmlTextElement);
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
181 tsr.setUtil(util);
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
182 tsr.read();
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
183 } else {
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
184 logger.warn("Unknwon Symbol of class: " +
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
185 sym.getClass().toString());
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
186 }
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
187 }
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
188 catch(Exception e) {
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
189 logger.warn("Could not read element text symbol.");
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
190 }
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
191 } else {
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
192 logger.warn("Unhandled Element of class: " +
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
193 actElement.getClass().toString() +
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
194 " in conversion of layer: " +
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
195 layer.getName());
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
196 }
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
197 count++;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
198 actElement = layer.next();
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
199 }
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
200 }
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
201 catch(Exception e) {
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
202 logger.warn("Could not read layer elements.");
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
203 logger.debug(e);
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
204 }
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
205
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
206 // Static values for this layer
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
207 layerElement.setAttribute("type", "annotation");
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
208
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
209 return layerElement;
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
210 }
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
211 }
b6c0fbae16dc Expand Graphics Layer Support
Andre Heinecke <aheinecke@intevation.de>
parents:
diff changeset
212 // 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)