Mercurial > mxd2map
annotate src/java/de/intevation/mxd/reader/FeatureLayerReader.java @ 355:5fd9effbfe24
Remove more instances of outdated repository URL
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Mon, 04 Jan 2021 15:45:14 +0100 |
parents | 5e3a40a84539 |
children |
rev | line source |
---|---|
243
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
181
diff
changeset
|
1 /* |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
181
diff
changeset
|
2 * Copyright (c) 2011 by Intevation GmbH, Germany <info@intevation.de> |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
181
diff
changeset
|
3 * |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
181
diff
changeset
|
4 * This file is part of MXD2map. |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
181
diff
changeset
|
5 * |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
181
diff
changeset
|
6 * This program is free software under the LGPL (>=v2.1) |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
181
diff
changeset
|
7 * Read the file LICENCE.txt coming with the software for details |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
181
diff
changeset
|
8 * or visit http://www.gnu.org/licenses/ if it does not exist. |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
181
diff
changeset
|
9 * |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
181
diff
changeset
|
10 * MXD2map has been developed on behalf of the |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
181
diff
changeset
|
11 * Bundesamt fuer Seeschifffahrt und Hydrographie (BSH) in Hamburg |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
181
diff
changeset
|
12 * by Intevation GmbH. |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
181
diff
changeset
|
13 * |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
181
diff
changeset
|
14 * Authors: |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
181
diff
changeset
|
15 * Raimund Renkert <raimund.renkert@intevation.de> |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
181
diff
changeset
|
16 * Bjoern Schilberg <bjoern.schilberg@intevation.de> |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
181
diff
changeset
|
17 * Stephan Holl <stephan.holl@intevation.de> |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
181
diff
changeset
|
18 */ |
df4e0946ef02
Added LGPL header.
Raimund Renkert <rrenkert@intevation.de>
parents:
181
diff
changeset
|
19 |
33
c51376f8e24c
Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents:
31
diff
changeset
|
20 package de.intevation.mxd.reader; |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
21 |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
22 import org.apache.log4j.Logger; |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
23 |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
24 import com.esri.arcgis.carto.ILayer; |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
25 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
|
26 import com.esri.arcgis.carto.AnnotateLayerPropertiesCollection; |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
27 import com.esri.arcgis.carto.IAnnotateLayerProperties; |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
28 import com.esri.arcgis.carto.LabelEngineLayerProperties; |
42
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
29 import com.esri.arcgis.geodatabase.FeatureClassName; |
309
e8021f3e411a
Add support for FgdbFeatureClass
Andre Heinecke <aheinecke@intevation.de>
parents:
307
diff
changeset
|
30 import com.esri.arcgis.datasourcesGDB.FgdbFeatureClassName; |
42
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
31 import com.esri.arcgis.system.IName; |
113
0db6eacad0e6
Read SDE connection settings.
vc11884admin@VC11884.win.bsh.de
parents:
100
diff
changeset
|
32 import com.esri.arcgis.system.IPropertySet; |
246
87e92debc53f
Added extent and projection as ows metadata to the mapfile.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
33 import com.esri.arcgis.geometry.Envelope; |
307
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
34 import com.esri.arcgis.geometry.ISpatialReference; |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
35 import com.esri.arcgis.geometry.ProjectedCoordinateSystem; |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
36 import com.esri.arcgis.geometry.GeographicCoordinateSystem; |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
37 import com.esri.arcgis.geometry.UnknownCoordinateSystem; |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
38 import com.esri.arcgis.geometry.Projection; |
246
87e92debc53f
Added extent and projection as ows metadata to the mapfile.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
39 |
29
77cfa8092611
Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
40 import org.w3c.dom.Element; |
77cfa8092611
Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
41 |
33
c51376f8e24c
Separated converter components into packages.
Raimund Renkert <rrenkert@intevation.de>
parents:
31
diff
changeset
|
42 import de.intevation.mxd.utils.MapToXMLUtils; |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
43 import java.io.IOException; |
133
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
44 import com.esri.arcgis.interop.AutomationException; |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
45 /** |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
46 * Reads Layer information. |
25
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 * @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
|
49 */ |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
50 public class FeatureLayerReader |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
51 implements ILayerReader { |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
52 |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
53 /** |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
54 * The logger. |
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 private static final Logger logger = |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
57 Logger.getLogger(FeatureLayerReader.class); |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
58 |
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 * Privte member. |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
61 */ |
29
77cfa8092611
Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
62 private FeatureLayer layer; |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
63 private MapToXMLUtils util; |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
64 |
181 | 65 /** |
66 * Constructor with layer. | |
67 * | |
68 * @param layer The ArcGIS layer object. | |
69 */ | |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
70 public FeatureLayerReader(ILayer layer) |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
71 throws Exception { |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
72 if(layer instanceof FeatureLayer) { |
29
77cfa8092611
Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
73 this.layer = (FeatureLayer)layer; |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
74 } |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
75 else { |
29
77cfa8092611
Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
76 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
|
77 layer.getClass().toString()); |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
78 } |
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 |
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 * Setter for XML document helper. |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
83 * |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
84 * @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
|
85 */ |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
86 public void setUtil(MapToXMLUtils util) { |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
87 this.util = util; |
29
77cfa8092611
Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
88 } |
77cfa8092611
Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
89 |
77cfa8092611
Write FeatureLayer attributes to XML document.
Raimund Renkert <rrenkert@intevation.de>
parents:
26
diff
changeset
|
90 /** |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
91 * Reads the Layer content. |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
92 * |
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
93 * @return The layer XML element. |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
94 */ |
118
39957898c694
Improved top level exception handling and logging.
Raimund Renkert <rrenkert@intevation.de>
parents:
117
diff
changeset
|
95 public Element read() |
39957898c694
Improved top level exception handling and logging.
Raimund Renkert <rrenkert@intevation.de>
parents:
117
diff
changeset
|
96 throws IOException{ |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
97 logger.debug("read()"); |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
98 Element layerElement; |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
99 try { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
100 layerElement = util.addLayer(); |
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 catch(Exception e) { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
103 logger.error("Failed to create DOM-Element for Layer."); |
133
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
104 return null; |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
105 } |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
106 |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
107 try { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
108 layerElement.setAttribute("name", layer.getName()); |
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 catch(IOException ioe) { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
111 logger.warn( |
135
a4ab239509f1
Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents:
133
diff
changeset
|
112 "Could not read layer name." + |
a4ab239509f1
Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents:
133
diff
changeset
|
113 " Stopped reading layer."); |
a4ab239509f1
Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents:
133
diff
changeset
|
114 throw new IOException("Error reading layer name."); |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
115 } |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
116 |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
117 try { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
118 layerElement.setAttribute("min_scale", |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
119 String.valueOf(layer.getMinimumScale())); |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
120 } |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
121 catch(IOException ioe) { |
135
a4ab239509f1
Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents:
133
diff
changeset
|
122 logger.warn("Could not read minimum scale."); |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
123 } |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
124 |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
125 try { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
126 layerElement.setAttribute("max_scale", |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
127 String.valueOf(layer.getMaximumScale())); |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
128 } |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
129 catch(IOException ioe) { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
130 logger.warn( |
135
a4ab239509f1
Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents:
133
diff
changeset
|
131 "Could not read maximum scale."); |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
132 } |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
133 |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
134 try { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
135 if(layer.isVisible()) { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
136 layerElement.setAttribute("status", "on"); |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
137 } |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
138 else { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
139 layerElement.setAttribute("status", "off"); |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
140 } |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
141 } |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
142 catch(IOException ioe) { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
143 logger.warn( |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
144 "Could not read layer status." + |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
145 " Setting layer status to \"on\"."); |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
146 layerElement.setAttribute("status", "on"); |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
147 } |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
148 |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
149 int type = 0; |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
150 try { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
151 type = layer.getShapeType(); |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
152 } |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
153 catch(IOException ioe) { |
135
a4ab239509f1
Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents:
133
diff
changeset
|
154 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
|
155 throw new IOException("Error reading shape type."); |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
156 } |
40
a1bc7220efe7
Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
157 switch (type) { |
62
e468cf8701ea
Prepared the converter to handle and write line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
58
diff
changeset
|
158 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
|
159 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
|
160 case 3: layerElement.setAttribute("type", "line"); break; |
97
18e4f143896b
Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
83
diff
changeset
|
161 case 4: layerElement.setAttribute("type", "polygon"); break; |
40
a1bc7220efe7
Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
162 } |
a1bc7220efe7
Updated the mxd reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
34
diff
changeset
|
163 |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
164 try { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
165 layerElement.setAttribute("definition_query", |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
166 layer.getDefinitionExpression()); |
42
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
40
diff
changeset
|
167 } |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
168 catch(IOException ioe) { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
169 logger.warn( |
135
a4ab239509f1
Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents:
133
diff
changeset
|
170 "Could not read definition query."); |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
171 } |
179
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
172 |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
173 try { |
180
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
174 AnnotateLayerPropertiesCollection annotation = |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
175 (AnnotateLayerPropertiesCollection) |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
176 layer.getAnnotationProperties(); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
177 |
179
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
178 if (layer.isDisplayAnnotation() && annotation.getCount() > 0){ |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
179 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
|
180 IAnnotateLayerProperties prop = annotation.getProperties(0); |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
181 if(prop instanceof LabelEngineLayerProperties) { |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
182 try { |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
183 LabelEngineReader lr = new LabelEngineReader(prop); |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
184 lr.setParent(layerElement); |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
185 lr.setUtil(util); |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
186 lr.read(); |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
187 } |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
188 catch(Exception e) { |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
189 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
|
190 } |
316
5e3a40a84539
Some minor cleanups
Andre Heinecke <aheinecke@intevation.de>
parents:
309
diff
changeset
|
191 } else { |
5e3a40a84539
Some minor cleanups
Andre Heinecke <aheinecke@intevation.de>
parents:
309
diff
changeset
|
192 logger.debug("Unknown Layer class: " + prop.getClass().toString()); |
179
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
193 } |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
194 } |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
195 } |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
196 } |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
197 catch(IOException ioe) { |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
198 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
|
199 } |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
135
diff
changeset
|
200 |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
201 try { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
202 IName fcn = layer.getDataSourceName(); |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
203 if(fcn instanceof FeatureClassName) { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
204 FeatureClassName name = (FeatureClassName)fcn; |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
205 layerElement.setAttribute("data_source", name.getName()); |
309
e8021f3e411a
Add support for FgdbFeatureClass
Andre Heinecke <aheinecke@intevation.de>
parents:
307
diff
changeset
|
206 } else if (fcn instanceof FgdbFeatureClassName) { |
e8021f3e411a
Add support for FgdbFeatureClass
Andre Heinecke <aheinecke@intevation.de>
parents:
307
diff
changeset
|
207 FgdbFeatureClassName name = (FgdbFeatureClassName)fcn; |
e8021f3e411a
Add support for FgdbFeatureClass
Andre Heinecke <aheinecke@intevation.de>
parents:
307
diff
changeset
|
208 layerElement.setAttribute("data_source", name.getName()); |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
209 } |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
210 else { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
211 logger.debug ( |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
212 "Unknown FeatureClass name:" + |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
213 fcn.getClass().toString()); |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
214 } |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
215 } |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
216 catch(IOException ioe) { |
133
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
217 logger.warn( |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
218 "Could not read datasource." + |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
219 " Stopped reading layer " + layer.getName() + "."); |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
220 util.removeLayer(layerElement); |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
221 return null; |
100
bab3946a8bdc
Read the connection settings for file geodatabase.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
222 } |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
223 |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
224 try { |
246
87e92debc53f
Added extent and projection as ows metadata to the mapfile.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
225 Envelope rect = (Envelope)layer.getExtent(); |
87e92debc53f
Added extent and projection as ows metadata to the mapfile.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
226 layerElement.setAttribute( |
87e92debc53f
Added extent and projection as ows metadata to the mapfile.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
227 "extent_min_x", |
87e92debc53f
Added extent and projection as ows metadata to the mapfile.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
228 String.valueOf(rect.getXMin ())); |
87e92debc53f
Added extent and projection as ows metadata to the mapfile.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
229 layerElement.setAttribute( |
87e92debc53f
Added extent and projection as ows metadata to the mapfile.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
230 "extent_max_x", |
87e92debc53f
Added extent and projection as ows metadata to the mapfile.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
231 String.valueOf(rect.getXMax())); |
87e92debc53f
Added extent and projection as ows metadata to the mapfile.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
232 layerElement.setAttribute( |
248
191b7d18c79e
Minor fixes for metadata information.
raimund renkert <raimund.renkert@intevation.de>
parents:
246
diff
changeset
|
233 "extent_min_y", |
246
87e92debc53f
Added extent and projection as ows metadata to the mapfile.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
234 String.valueOf(rect.getYMin())); |
87e92debc53f
Added extent and projection as ows metadata to the mapfile.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
235 layerElement.setAttribute( |
248
191b7d18c79e
Minor fixes for metadata information.
raimund renkert <raimund.renkert@intevation.de>
parents:
246
diff
changeset
|
236 "extent_max_y", |
246
87e92debc53f
Added extent and projection as ows metadata to the mapfile.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
237 String.valueOf(rect.getYMax())); |
87e92debc53f
Added extent and projection as ows metadata to the mapfile.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
238 } |
87e92debc53f
Added extent and projection as ows metadata to the mapfile.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
239 catch(IOException ioe) { |
87e92debc53f
Added extent and projection as ows metadata to the mapfile.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
240 logger.warn( |
87e92debc53f
Added extent and projection as ows metadata to the mapfile.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
241 "Could not read extent from layer " |
87e92debc53f
Added extent and projection as ows metadata to the mapfile.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
242 + layer.getName() + "."); |
87e92debc53f
Added extent and projection as ows metadata to the mapfile.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
243 } |
307
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
244 //Read the projection. |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
245 try { |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
246 ISpatialReference sr = layer.getSpatialReference(); |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
247 int projection = 0; |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
248 if(sr instanceof ProjectedCoordinateSystem) { |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
249 ProjectedCoordinateSystem pcs = (ProjectedCoordinateSystem)sr; |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
250 projection = pcs.getFactoryCode(); |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
251 } |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
252 else if(sr instanceof GeographicCoordinateSystem) { |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
253 GeographicCoordinateSystem gcs = (GeographicCoordinateSystem)sr; |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
254 projection = gcs.getFactoryCode(); |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
255 } |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
256 else if(sr instanceof UnknownCoordinateSystem) { |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
257 UnknownCoordinateSystem ucs = (UnknownCoordinateSystem)sr; |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
258 projection = 0; |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
259 } |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
260 else{ |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
261 logger.debug( |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
262 "Unknown SpatialReference: " + |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
263 sr.getClass().toString()); |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
264 } |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
265 |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
266 if(projection == 0) { |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
267 logger.warn( |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
268 "Unknown projection for Layer:" + layer.getName() + |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
269 " Please edit projection in resulting mapfile."); |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
270 } |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
271 layerElement.setAttribute("projection", String.valueOf(projection)); |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
272 } |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
273 catch(IOException ioe) { |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
274 logger.warn("Could not read layer projection."); |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
275 } |
f9e53dcc7424
Add Read/Write Support for Projections on a per Layer basis
Andre Heinecke <aheinecke@intevation.de>
parents:
248
diff
changeset
|
276 |
246
87e92debc53f
Added extent and projection as ows metadata to the mapfile.
raimund renkert <raimund.renkert@intevation.de>
parents:
243
diff
changeset
|
277 try { |
309
e8021f3e411a
Add support for FgdbFeatureClass
Andre Heinecke <aheinecke@intevation.de>
parents:
307
diff
changeset
|
278 if (layer.getDataSourceName() instanceof FgdbFeatureClassName) { |
e8021f3e411a
Add support for FgdbFeatureClass
Andre Heinecke <aheinecke@intevation.de>
parents:
307
diff
changeset
|
279 FgdbFeatureClassName name = (FgdbFeatureClassName)layer.getDataSourceName(); |
e8021f3e411a
Add support for FgdbFeatureClass
Andre Heinecke <aheinecke@intevation.de>
parents:
307
diff
changeset
|
280 layerElement.setAttribute("connection_type", "ogr"); |
e8021f3e411a
Add support for FgdbFeatureClass
Andre Heinecke <aheinecke@intevation.de>
parents:
307
diff
changeset
|
281 layerElement.setAttribute("data", name.getName()); |
e8021f3e411a
Add support for FgdbFeatureClass
Andre Heinecke <aheinecke@intevation.de>
parents:
307
diff
changeset
|
282 layerElement.setAttribute("connection", name.getWorkspaceName().getPathName()); |
e8021f3e411a
Add support for FgdbFeatureClass
Andre Heinecke <aheinecke@intevation.de>
parents:
307
diff
changeset
|
283 } |
e8021f3e411a
Add support for FgdbFeatureClass
Andre Heinecke <aheinecke@intevation.de>
parents:
307
diff
changeset
|
284 else if(layer.getWorkspace().getType() == 0) { |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
285 layerElement.setAttribute("connection_type", "local"); |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
286 layerElement.setAttribute( |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
287 "workspace", |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
288 layer.getWorkspace().getPathName()); |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
289 } |
133
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
290 else if(layer.getWorkspace().getType() == 1){ |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
291 layerElement.setAttribute("connection_type", "ogr"); |
133
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
292 layerElement.setAttribute( |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
293 "data", |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
294 layer.getFeatureClass().getFeatureDataset().getName()); |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
295 layerElement.setAttribute( |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
296 "workspace", |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
297 layer.getWorkspace().getPathName()); |
100
bab3946a8bdc
Read the connection settings for file geodatabase.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
298 |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
299 } |
133
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
300 else if(layer.getWorkspace().getType() == 2) { |
180
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
301 IPropertySet set = |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
302 layer.getWorkspace().getConnectionProperties(); |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
303 Object names[] = new Object[set.getCount()]; |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
304 Object prop[] = new Object[set.getCount()]; |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
305 set.getAllProperties(names, prop); |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
306 layerElement.setAttribute("connection_type", "SDE"); |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
307 for(int i = 0; i < names.length; i++) { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
308 if(names[i] != null) { |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
309 String[] prop_names = (String[])names[i]; |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
310 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
|
311 layerElement.setAttribute( |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
312 prop_names[j].toLowerCase(), |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
313 set.getProperty(prop_names[j]).toString()); |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
314 } |
113
0db6eacad0e6
Read SDE connection settings.
vc11884admin@VC11884.win.bsh.de
parents:
100
diff
changeset
|
315 } |
0db6eacad0e6
Read SDE connection settings.
vc11884admin@VC11884.win.bsh.de
parents:
100
diff
changeset
|
316 } |
133
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
317 try { |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
318 layerElement.setAttribute( |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
319 "join_table", |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
320 layer.getRelationshipClass() |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
321 .getOriginClass().getAliasName()); |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
322 layerElement.setAttribute( |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
323 "join_field", |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
324 layer.getRelationshipClass().getOriginPrimaryKey()); |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
325 layerElement.setAttribute( |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
326 "join_table_target", |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
327 layer.getRelationshipClass() |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
328 .getDestinationClass().getAliasName()); |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
329 layerElement.setAttribute( |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
330 "join_field_target", |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
331 layer.getRelationshipClass().getOriginForeignKey()); |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
332 } |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
333 catch(AutomationException ioe) { |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
334 //Do nothing, cause no jointable defined. |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
335 } |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
336 catch(IOException ae) { |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
337 //Do nothing, cause no jointable defined. |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
338 } |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
339 catch(NullPointerException npe) { |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
340 //Do nothing, cause no jointable defined. |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
341 } |
113
0db6eacad0e6
Read SDE connection settings.
vc11884admin@VC11884.win.bsh.de
parents:
100
diff
changeset
|
342 } |
100
bab3946a8bdc
Read the connection settings for file geodatabase.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
343 } |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
344 catch(Exception e) { |
309
e8021f3e411a
Add support for FgdbFeatureClass
Andre Heinecke <aheinecke@intevation.de>
parents:
307
diff
changeset
|
345 logger.debug(e); |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
346 logger.error( |
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
347 "Could not read layer datasource." + |
133
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
348 " Stopped reading layer " + layer.getName() + "."); |
6b80d2c7536e
Improved broken layer handling.
vc11884admin@VC11884.win.bsh.de
parents:
130
diff
changeset
|
349 util.removeLayer(layerElement); |
135
a4ab239509f1
Updated the default values and reader error handling.
Raimund Renkert <rrenkert@intevation.de>
parents:
133
diff
changeset
|
350 return null; |
117
6c3d880db7c5
Improved exception handling for layer reader.
Raimund Renkert <rrenkert@intevation.de>
parents:
113
diff
changeset
|
351 } |
31
40c0b4e5f91a
Added utility class to store map attributes.
Raimund Renkert <rrenkert@intevation.de>
parents:
29
diff
changeset
|
352 return layerElement; |
25
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
353 } |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
354 } |
cbd67b1100d8
Initial commit of the first prototype.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
355 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |