Mercurial > mxd2map
annotate src/java/de/intevation/mxd/writer/MapScriptWriter.java @ 197:cdbf2f2dca35
Check for database connectio user parameter for SDE connections.
author | raimund renkert <raimund.renkert@intevation.de> |
---|---|
date | Wed, 20 Jul 2011 17:56:29 +0200 |
parents | 5350621a0294 |
children | c56547b228f9 |
rev | line source |
---|---|
41
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.mxd.writer; |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
2 |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
3 import org.apache.log4j.Logger; |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
4 |
179
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
175
diff
changeset
|
5 import java.awt.Color; |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
175
diff
changeset
|
6 |
41
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
7 import org.w3c.dom.Document; |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
8 import org.w3c.dom.Element; |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
9 import org.w3c.dom.NodeList; |
42
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
10 |
98
4696d0769f9c
Write the absolute path to the data source of the layer.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
11 import java.io.File; |
4696d0769f9c
Write the absolute path to the data source of the layer.
Raimund Renkert <rrenkert@intevation.de>
parents:
97
diff
changeset
|
12 |
41
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
13 import javax.xml.xpath.XPathConstants; |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
14 |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
15 import edu.umn.gis.mapscript.mapObj; |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
16 import edu.umn.gis.mapscript.layerObj; |
42
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
17 import edu.umn.gis.mapscript.classObj; |
179
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
175
diff
changeset
|
18 import edu.umn.gis.mapscript.labelObj; |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
175
diff
changeset
|
19 import edu.umn.gis.mapscript.colorObj; |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
175
diff
changeset
|
20 import edu.umn.gis.mapscript.fontSetObj; |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
175
diff
changeset
|
21 import edu.umn.gis.mapscript.hashTableObj; |
42
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
22 |
41
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
23 import edu.umn.gis.mapscript.MS_UNITS; |
42
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
24 import edu.umn.gis.mapscript.MS_LAYER_TYPE; |
130
5991c1f90f91
Added data source "SDE" to writer.
vc11884admin@VC11884.win.bsh.de
parents:
129
diff
changeset
|
25 import edu.umn.gis.mapscript.MS_CONNECTION_TYPE; |
179
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
175
diff
changeset
|
26 import edu.umn.gis.mapscript.MS_FONT_TYPE; |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
175
diff
changeset
|
27 import edu.umn.gis.mapscript.MS_POSITIONS_ENUM; |
41
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
28 |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
29 import de.intevation.mxd.utils.XMLUtils; |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
30 |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
31 /** |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
32 * The Mapfile Writer. |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
33 * This Writer uses the MapScript Java API to create Mapfiles from a DOM. |
41
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
34 * |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
35 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
36 */ |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
37 public class MapScriptWriter |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
38 implements IWriter |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
39 { |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
40 /** |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
41 * The Logger. |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
42 */ |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
43 private static final Logger logger = Logger.getLogger(MapScriptWriter.class); |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
44 |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
45 /** |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
46 * Private member. |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
47 */ |
41
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
48 private Document root; |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
49 private mapObj map; |
55
f0c02ff120d6
Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents:
53
diff
changeset
|
50 private String mapFilename; |
130
5991c1f90f91
Added data source "SDE" to writer.
vc11884admin@VC11884.win.bsh.de
parents:
129
diff
changeset
|
51 private String MS_BINDIR = "c:/ms_6.1-dev/bin"; |
134
acc9e5430177
Handle SDE connection attributes and expressions.
vc11884admin@VC11884.win.bsh.de
parents:
132
diff
changeset
|
52 private String prefix = ""; |
170
b9ee44070056
Manage projections and units.
vc11884admin@VC11884.win.bsh.de
parents:
169
diff
changeset
|
53 private MS_UNITS units = MS_UNITS.MS_METERS; |
41
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
54 |
181 | 55 /** |
56 * Default constructor. | |
57 * Creates a mapscript writer object with an empty map. | |
58 */ | |
41
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
59 public MapScriptWriter() { |
55
f0c02ff120d6
Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents:
53
diff
changeset
|
60 map = new mapObj(""); |
f0c02ff120d6
Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents:
53
diff
changeset
|
61 mapFilename = ""; |
41
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
62 } |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
63 |
181 | 64 /** |
65 * Contructor with template and output filename. | |
66 * Creates a mapscript writer object with the given template that saves the | |
67 * map to the filename. | |
68 * | |
69 * @param templ Mapfile template. | |
70 * @param filename Output file name. | |
71 */ | |
55
f0c02ff120d6
Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents:
53
diff
changeset
|
72 public MapScriptWriter(String templ, String filename) { |
180
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
73 String path = System.getProperty("user.dir"); |
55
f0c02ff120d6
Read filenames from properties file or commandline arguments.
Raimund Renkert <rrenkert@intevation.de>
parents:
53
diff
changeset
|
74 map = new mapObj(templ); |
180
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
75 File f = new File(filename); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
76 mapFilename = filename; |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
77 if(f.isAbsolute()) { |
174
707f13cfba74
Improved the commandline arguments and save the mapfile in the correct directory.
raimund.renkert@intevation.de
parents:
172
diff
changeset
|
78 map.setMappath(mapFilename); |
180
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
79 } |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
80 else { |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
81 map.setMappath( |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
82 System.getProperty("user.dir") + |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
83 File.separator + |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
84 mapFilename); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
85 mapFilename = System.getProperty("user.dir") + |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
86 File.separator + |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
87 mapFilename; |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
88 } |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
89 String fontSetPath = map.getFontset().getFilename(); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
90 File fonts = new File(fontSetPath); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
91 String fontSet = fonts.getAbsolutePath(); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
92 fontSet = fontSet.replaceAll("\\\\", "/"); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
93 map.setFontSet(fontSet); |
41
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
94 } |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
95 |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
96 /** |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
97 * Write the mapfile. |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
98 * @param doc The root document containin the map attributes. |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
99 * |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
100 * @return Currently always true. |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
101 */ |
120
11d63bf00326
Changed exception handling and logging in writer classes.
Raimund Renkert <rrenkert@intevation.de>
parents:
102
diff
changeset
|
102 public boolean write(Document doc) { |
41
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
103 logger.debug("write()"); |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
104 this.root = doc; |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
105 |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
106 //Get the filename. |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
107 Element fileNode = (Element)XMLUtils.xpath( |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
108 root, |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
109 "/mxd/file", |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
110 XPathConstants.NODE); |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
111 //Write the map attributes. |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
112 writeMap(); |
42
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
113 //Write the layers. |
196
5350621a0294
Verify the SDE databse jointable attribute.
raimund renkert <raimund.renkert@intevation.de>
parents:
190
diff
changeset
|
114 boolean ret = writeLayer(); |
41
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
115 //Save the map. |
196
5350621a0294
Verify the SDE databse jointable attribute.
raimund renkert <raimund.renkert@intevation.de>
parents:
190
diff
changeset
|
116 if (ret) { |
5350621a0294
Verify the SDE databse jointable attribute.
raimund renkert <raimund.renkert@intevation.de>
parents:
190
diff
changeset
|
117 mapObj cloneMap = map.cloneMap(); |
5350621a0294
Verify the SDE databse jointable attribute.
raimund renkert <raimund.renkert@intevation.de>
parents:
190
diff
changeset
|
118 cloneMap.save(mapFilename); |
5350621a0294
Verify the SDE databse jointable attribute.
raimund renkert <raimund.renkert@intevation.de>
parents:
190
diff
changeset
|
119 logger.info("Mapfile created: " + mapFilename); |
5350621a0294
Verify the SDE databse jointable attribute.
raimund renkert <raimund.renkert@intevation.de>
parents:
190
diff
changeset
|
120 return true; |
5350621a0294
Verify the SDE databse jointable attribute.
raimund renkert <raimund.renkert@intevation.de>
parents:
190
diff
changeset
|
121 } |
5350621a0294
Verify the SDE databse jointable attribute.
raimund renkert <raimund.renkert@intevation.de>
parents:
190
diff
changeset
|
122 return false; |
41
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
123 } |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
124 |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
125 /** |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
126 * Create the map object and set the attributes. |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
127 */ |
41
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
128 private void writeMap() { |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
129 logger.debug("writeMap()"); |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
130 //Get the map. |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
131 Element mapNode = (Element)XMLUtils.xpath( |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
132 root, |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
133 "/mxd/map", |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
134 XPathConstants.NODE); |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
135 |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
136 //Set the name. |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
137 map.setName(mapNode.getAttribute("name")); |
42
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
138 map.setMetaData("wms_title", mapNode.getAttribute("name")); |
41
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
139 //Set the extent. |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
140 map.setExtent( |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
141 Double.parseDouble(mapNode.getAttribute("extent_min_x")), |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
142 Double.parseDouble(mapNode.getAttribute("extent_min_y")), |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
143 Double.parseDouble(mapNode.getAttribute("extent_max_x")), |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
144 Double.parseDouble(mapNode.getAttribute("extent_max_y"))); |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
145 |
172
929e09649b08
Handle unknown projections.
vc11884admin@VC11884.win.bsh.de
parents:
170
diff
changeset
|
146 //Set the units and projection. |
180
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
147 int proj = Integer.parseInt(mapNode.getAttribute("projection")); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
148 if(proj != 0) { |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
149 map.setProjection("epsg:" + mapNode.getAttribute("projection")); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
150 } |
170
b9ee44070056
Manage projections and units.
vc11884admin@VC11884.win.bsh.de
parents:
169
diff
changeset
|
151 String u = mapNode.getAttribute("units"); |
b9ee44070056
Manage projections and units.
vc11884admin@VC11884.win.bsh.de
parents:
169
diff
changeset
|
152 if(u.equals("feet")) { |
b9ee44070056
Manage projections and units.
vc11884admin@VC11884.win.bsh.de
parents:
169
diff
changeset
|
153 units = MS_UNITS.MS_FEET; |
41
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
154 } |
170
b9ee44070056
Manage projections and units.
vc11884admin@VC11884.win.bsh.de
parents:
169
diff
changeset
|
155 else if(u.equals("inches")) { |
b9ee44070056
Manage projections and units.
vc11884admin@VC11884.win.bsh.de
parents:
169
diff
changeset
|
156 units = MS_UNITS.MS_INCHES; |
41
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
157 } |
170
b9ee44070056
Manage projections and units.
vc11884admin@VC11884.win.bsh.de
parents:
169
diff
changeset
|
158 else if(u.equals("kilometers")) { |
b9ee44070056
Manage projections and units.
vc11884admin@VC11884.win.bsh.de
parents:
169
diff
changeset
|
159 units = MS_UNITS.MS_KILOMETERS; |
41
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
160 } |
170
b9ee44070056
Manage projections and units.
vc11884admin@VC11884.win.bsh.de
parents:
169
diff
changeset
|
161 else if(u.equals("meters")) { |
b9ee44070056
Manage projections and units.
vc11884admin@VC11884.win.bsh.de
parents:
169
diff
changeset
|
162 units = MS_UNITS.MS_METERS; |
41
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
163 } |
170
b9ee44070056
Manage projections and units.
vc11884admin@VC11884.win.bsh.de
parents:
169
diff
changeset
|
164 else if(u.equals("miles")) { |
b9ee44070056
Manage projections and units.
vc11884admin@VC11884.win.bsh.de
parents:
169
diff
changeset
|
165 units = MS_UNITS.MS_MILES; |
b9ee44070056
Manage projections and units.
vc11884admin@VC11884.win.bsh.de
parents:
169
diff
changeset
|
166 } |
b9ee44070056
Manage projections and units.
vc11884admin@VC11884.win.bsh.de
parents:
169
diff
changeset
|
167 else if(u.equals("nauticalmiles")) { |
b9ee44070056
Manage projections and units.
vc11884admin@VC11884.win.bsh.de
parents:
169
diff
changeset
|
168 units = MS_UNITS.MS_NAUTICALMILES; |
b9ee44070056
Manage projections and units.
vc11884admin@VC11884.win.bsh.de
parents:
169
diff
changeset
|
169 } |
b9ee44070056
Manage projections and units.
vc11884admin@VC11884.win.bsh.de
parents:
169
diff
changeset
|
170 else if(u.equals("points")) { |
b9ee44070056
Manage projections and units.
vc11884admin@VC11884.win.bsh.de
parents:
169
diff
changeset
|
171 units = MS_UNITS.MS_PIXELS; |
b9ee44070056
Manage projections and units.
vc11884admin@VC11884.win.bsh.de
parents:
169
diff
changeset
|
172 } |
180
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
173 else if(u.equals("degree")) { |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
174 units = MS_UNITS.MS_DD; |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
175 } |
41
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
176 else { |
170
b9ee44070056
Manage projections and units.
vc11884admin@VC11884.win.bsh.de
parents:
169
diff
changeset
|
177 units = MS_UNITS.MS_METERS; |
41
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
178 } |
170
b9ee44070056
Manage projections and units.
vc11884admin@VC11884.win.bsh.de
parents:
169
diff
changeset
|
179 map.setUnits(units); |
41
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
180 } |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
181 |
43
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
182 /** |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
183 * Create layer objects and set the attributes. |
ef7ca23c4233
Added comments, done some code styling and removed typos.
Raimund Renkert <rrenkert@intevation.de>
parents:
42
diff
changeset
|
184 */ |
196
5350621a0294
Verify the SDE databse jointable attribute.
raimund renkert <raimund.renkert@intevation.de>
parents:
190
diff
changeset
|
185 private boolean writeLayer() { |
42
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
186 logger.debug("writeLayer()"); |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
187 Element mapNode = (Element)XMLUtils.xpath( |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
188 root, |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
189 "/mxd/map", |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
190 XPathConstants.NODE); |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
191 NodeList list = mapNode.getElementsByTagName("layer"); |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
192 for(int i = 0; i < list.getLength(); i++) { |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
193 Element layerElement = (Element)list.item(i); |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
194 layerObj layer = new layerObj(map); |
190
c640fb351f66
Do not write layer with empty CLASS objects.
raimund renkert <raimund.renkert@intevation.de>
parents:
189
diff
changeset
|
195 NodeList renderer = layerElement.getElementsByTagName("renderer"); |
c640fb351f66
Do not write layer with empty CLASS objects.
raimund renkert <raimund.renkert@intevation.de>
parents:
189
diff
changeset
|
196 if (renderer.getLength() == 0) { |
c640fb351f66
Do not write layer with empty CLASS objects.
raimund renkert <raimund.renkert@intevation.de>
parents:
189
diff
changeset
|
197 continue; |
c640fb351f66
Do not write layer with empty CLASS objects.
raimund renkert <raimund.renkert@intevation.de>
parents:
189
diff
changeset
|
198 } |
42
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
199 |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
200 //The layer name. |
137
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
201 String lname = layerElement.getAttribute("name"); |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
202 lname = lname.replaceAll(" ", ""); |
189
0965f8af70fa
Replace german umlauts and trim strings.
raimund renkert <raimund.renkert@intevation.de>
parents:
186
diff
changeset
|
203 layer.setName(validateString(lname)); |
180
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
204 layer.setUnits(units.swigValue()); |
189
0965f8af70fa
Replace german umlauts and trim strings.
raimund renkert <raimund.renkert@intevation.de>
parents:
186
diff
changeset
|
205 layer.setMetaData("wms_title", validateString(lname)); |
148
2bf35f0babd0
Implemented new group layer functionality.
vc11884admin@VC11884.win.bsh.de
parents:
145
diff
changeset
|
206 if(layerElement.hasAttribute("group")) { |
189
0965f8af70fa
Replace german umlauts and trim strings.
raimund renkert <raimund.renkert@intevation.de>
parents:
186
diff
changeset
|
207 String group = layerElement.getAttribute("group"); |
0965f8af70fa
Replace german umlauts and trim strings.
raimund renkert <raimund.renkert@intevation.de>
parents:
186
diff
changeset
|
208 layer.setGroup(validateString(group)); |
180
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
209 } |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
210 |
42
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
211 //The layer status. |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
212 String stat = layerElement.getAttribute("status"); |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
213 if (stat.equals("on")) { |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
214 layer.setStatus(1); |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
215 } |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
216 else { |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
217 layer.setStatus(0); |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
218 } |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
219 |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
220 //The scale. |
145
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
221 double maxScale = 0; |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
222 double minScale = 0; |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
223 try { |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
224 maxScale = |
153
7ed49420ee5a
Changed min scale and max scale in writer.
vc11884admin@VC11884.win.bsh.de
parents:
152
diff
changeset
|
225 Double.parseDouble(layerElement.getAttribute("min_scale")); |
7ed49420ee5a
Changed min scale and max scale in writer.
vc11884admin@VC11884.win.bsh.de
parents:
152
diff
changeset
|
226 minScale = |
145
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
227 Double.parseDouble(layerElement.getAttribute("max_scale")); |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
228 } |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
229 catch(NumberFormatException nfe) { |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
230 logger.warn("Error setting scale."); |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
231 maxScale = 0; |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
232 minScale = 0; |
b2c5a66022f1
Exception handling for number conversions in writer modules.
Raimund Renkert <rrenkert@intevation.de>
parents:
141
diff
changeset
|
233 } |
42
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
234 layer.setMaxscaledenom(maxScale); |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
235 layer.setMinscaledenom(minScale); |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
236 |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
237 //The layer type. |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
238 String type = layerElement.getAttribute("type"); |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
239 if(type.equals("point")) { |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
240 layer.setType(MS_LAYER_TYPE.MS_LAYER_POINT); |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
241 } |
62
e468cf8701ea
Prepared the converter to handle and write line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
59
diff
changeset
|
242 else if (type.equals("line")) { |
e468cf8701ea
Prepared the converter to handle and write line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
59
diff
changeset
|
243 layer.setType(MS_LAYER_TYPE.MS_LAYER_LINE); |
e468cf8701ea
Prepared the converter to handle and write line symbols.
Raimund Renkert <rrenkert@intevation.de>
parents:
59
diff
changeset
|
244 } |
97
18e4f143896b
Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
96
diff
changeset
|
245 else if (type.equals("polygon")) { |
18e4f143896b
Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
96
diff
changeset
|
246 layer.setType(MS_LAYER_TYPE.MS_LAYER_POLYGON); |
18e4f143896b
Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
96
diff
changeset
|
247 } |
102
3ca2ec55fb3b
Set TILEITEM to an empty string.
Raimund Renkert <rrenkert@intevation.de>
parents:
99
diff
changeset
|
248 layer.setTileitem(""); |
42
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
249 |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
250 //The layer datasource. |
137
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
251 String con_type = layerElement.getAttribute("connection_type"); |
134
acc9e5430177
Handle SDE connection attributes and expressions.
vc11884admin@VC11884.win.bsh.de
parents:
132
diff
changeset
|
252 if(con_type.equals("local")) { |
181 | 253 // The data source is a local file. (.shp) |
130
5991c1f90f91
Added data source "SDE" to writer.
vc11884admin@VC11884.win.bsh.de
parents:
129
diff
changeset
|
254 String datasource = ""; |
5991c1f90f91
Added data source "SDE" to writer.
vc11884admin@VC11884.win.bsh.de
parents:
129
diff
changeset
|
255 if(layerElement.hasAttribute("workspace")) { |
5991c1f90f91
Added data source "SDE" to writer.
vc11884admin@VC11884.win.bsh.de
parents:
129
diff
changeset
|
256 datasource = layerElement.getAttribute("workspace"); |
5991c1f90f91
Added data source "SDE" to writer.
vc11884admin@VC11884.win.bsh.de
parents:
129
diff
changeset
|
257 datasource += File.separator; |
5991c1f90f91
Added data source "SDE" to writer.
vc11884admin@VC11884.win.bsh.de
parents:
129
diff
changeset
|
258 } |
5991c1f90f91
Added data source "SDE" to writer.
vc11884admin@VC11884.win.bsh.de
parents:
129
diff
changeset
|
259 datasource += layerElement.getAttribute("data_source"); |
180
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
260 datasource = datasource.replaceAll("\\\\", "/"); |
130
5991c1f90f91
Added data source "SDE" to writer.
vc11884admin@VC11884.win.bsh.de
parents:
129
diff
changeset
|
261 layer.setData(datasource); |
137
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
262 } |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
263 else if(con_type.equals("SDE")) { |
181 | 264 // The data source is a sde database. |
137
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
265 logger.info( |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
266 "SDE datasource found." + |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
267 " Please edit password in mapfile."); |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
268 layer.setConnectionType( |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
269 MS_CONNECTION_TYPE.MS_PLUGIN.swigValue(), |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
270 MS_BINDIR + "/ms/plugins/msplugin_sde_93.dll"); |
197
cdbf2f2dca35
Check for database connectio user parameter for SDE connections.
raimund renkert <raimund.renkert@intevation.de>
parents:
196
diff
changeset
|
271 String database_auth = layerElement.getAttribute("database"); |
cdbf2f2dca35
Check for database connectio user parameter for SDE connections.
raimund renkert <raimund.renkert@intevation.de>
parents:
196
diff
changeset
|
272 if (database_auth.equals("") || database_auth == null) { |
cdbf2f2dca35
Check for database connectio user parameter for SDE connections.
raimund renkert <raimund.renkert@intevation.de>
parents:
196
diff
changeset
|
273 logger.warn("Could not set the database connection user." + |
cdbf2f2dca35
Check for database connectio user parameter for SDE connections.
raimund renkert <raimund.renkert@intevation.de>
parents:
196
diff
changeset
|
274 " Setting to \"sde\" as default."); |
cdbf2f2dca35
Check for database connectio user parameter for SDE connections.
raimund renkert <raimund.renkert@intevation.de>
parents:
196
diff
changeset
|
275 database_auth = "sde"; |
cdbf2f2dca35
Check for database connectio user parameter for SDE connections.
raimund renkert <raimund.renkert@intevation.de>
parents:
196
diff
changeset
|
276 } |
130
5991c1f90f91
Added data source "SDE" to writer.
vc11884admin@VC11884.win.bsh.de
parents:
129
diff
changeset
|
277 layer.setConnection( |
137
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
278 layerElement.getAttribute("server") + "," + |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
279 "port:" + layerElement.getAttribute("instance") + "," + |
197
cdbf2f2dca35
Check for database connectio user parameter for SDE connections.
raimund renkert <raimund.renkert@intevation.de>
parents:
196
diff
changeset
|
280 database_auth + "," + |
137
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
281 layerElement.getAttribute("user") + ",<PASSWORD>"); |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
282 layer.setData( |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
283 layerElement.getAttribute("data_source") + |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
284 ",SHAPE," + |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
285 layerElement.getAttribute("version")); |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
286 layer.setProcessing("CLOSE_CONNECTION=defer"); |
134
acc9e5430177
Handle SDE connection attributes and expressions.
vc11884admin@VC11884.win.bsh.de
parents:
132
diff
changeset
|
287 layer.setProcessing("ATTRIBUTE_QUALIFIED=TRUE"); |
137
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
288 if(layerElement.hasAttribute("join_table")) { |
196
5350621a0294
Verify the SDE databse jointable attribute.
raimund renkert <raimund.renkert@intevation.de>
parents:
190
diff
changeset
|
289 String join = layerElement.getAttribute("join_table"); |
5350621a0294
Verify the SDE databse jointable attribute.
raimund renkert <raimund.renkert@intevation.de>
parents:
190
diff
changeset
|
290 if (join.indexOf(".") <= 0) { |
5350621a0294
Verify the SDE databse jointable attribute.
raimund renkert <raimund.renkert@intevation.de>
parents:
190
diff
changeset
|
291 logger.warn ("Incomplete join table in layer " + |
5350621a0294
Verify the SDE databse jointable attribute.
raimund renkert <raimund.renkert@intevation.de>
parents:
190
diff
changeset
|
292 layerElement.getAttribute("name") + |
5350621a0294
Verify the SDE databse jointable attribute.
raimund renkert <raimund.renkert@intevation.de>
parents:
190
diff
changeset
|
293 ". Aborting."); |
5350621a0294
Verify the SDE databse jointable attribute.
raimund renkert <raimund.renkert@intevation.de>
parents:
190
diff
changeset
|
294 return false; |
5350621a0294
Verify the SDE databse jointable attribute.
raimund renkert <raimund.renkert@intevation.de>
parents:
190
diff
changeset
|
295 } |
134
acc9e5430177
Handle SDE connection attributes and expressions.
vc11884admin@VC11884.win.bsh.de
parents:
132
diff
changeset
|
296 layer.setProcessing( |
137
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
297 "JOINTABLE=" + |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
298 layerElement.getAttribute("join_table")); |
134
acc9e5430177
Handle SDE connection attributes and expressions.
vc11884admin@VC11884.win.bsh.de
parents:
132
diff
changeset
|
299 layer.setFilter( |
acc9e5430177
Handle SDE connection attributes and expressions.
vc11884admin@VC11884.win.bsh.de
parents:
132
diff
changeset
|
300 "where " + |
acc9e5430177
Handle SDE connection attributes and expressions.
vc11884admin@VC11884.win.bsh.de
parents:
132
diff
changeset
|
301 layerElement.getAttribute("definition_query") + |
acc9e5430177
Handle SDE connection attributes and expressions.
vc11884admin@VC11884.win.bsh.de
parents:
132
diff
changeset
|
302 " AND " + |
acc9e5430177
Handle SDE connection attributes and expressions.
vc11884admin@VC11884.win.bsh.de
parents:
132
diff
changeset
|
303 layerElement.getAttribute("join_table_target") + "." + |
acc9e5430177
Handle SDE connection attributes and expressions.
vc11884admin@VC11884.win.bsh.de
parents:
132
diff
changeset
|
304 layerElement.getAttribute("join_field_target") + "=" + |
acc9e5430177
Handle SDE connection attributes and expressions.
vc11884admin@VC11884.win.bsh.de
parents:
132
diff
changeset
|
305 layerElement.getAttribute("join_table") + "." + |
acc9e5430177
Handle SDE connection attributes and expressions.
vc11884admin@VC11884.win.bsh.de
parents:
132
diff
changeset
|
306 layerElement.getAttribute("join_field")); |
137
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
307 } |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
308 else { |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
309 prefix = layerElement.getAttribute("data_source"); |
180
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
310 if(layerElement.hasAttribute("definition_query") && |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
311 !layerElement.getAttribute("definition_query") |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
312 .equals("")) { |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
313 layer.setFilter("where " + |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
314 layerElement.getAttribute("definition_query")); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
315 } |
137
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
316 } |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
317 } |
129
0b119169618f
Insert TEMPLATE entry for GFI request.
Raimund Renkert <rrenkert@intevation.de>
parents:
128
diff
changeset
|
318 layer.setTemplate("PleaseInsertAValidTemplateForGFI"); |
179
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
175
diff
changeset
|
319 |
181 | 320 // Create labelitem |
180
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
321 NodeList labels = layerElement.getElementsByTagName("label"); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
322 if(labels.getLength() > 0) { |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
323 Element label = (Element)labels.item(0); |
179
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
175
diff
changeset
|
324 String expr = label.getAttribute("expression"); |
180
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
325 expr = expr.replaceAll("\\[", ""); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
326 expr = expr.replaceAll("\\]", ""); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
327 if(!prefix.equals("")) { |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
328 expr = prefix + "." + expr; |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
329 } |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
330 layer.setLabelitem(expr); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
331 } |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
332 |
42
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
333 //Write classes. |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
334 writeClass(layer, layerElement); |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
335 } |
196
5350621a0294
Verify the SDE databse jointable attribute.
raimund renkert <raimund.renkert@intevation.de>
parents:
190
diff
changeset
|
336 return true; |
41
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
337 } |
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
338 |
42
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
339 /** |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
340 * Adds the classes to the layer. |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
341 * @param layer Mapscript layer object. |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
342 * @param layerElement Dom element containing the class attributes. |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
343 */ |
120
11d63bf00326
Changed exception handling and logging in writer classes.
Raimund Renkert <rrenkert@intevation.de>
parents:
102
diff
changeset
|
344 private void writeClass(layerObj layer, Element layerElement) { |
87
7d4cf2db43f1
Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
62
diff
changeset
|
345 logger.debug("writeClass(layerObj, Element)"); |
42
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
346 //Get all renderer elements (renderer in arcgis equals class in the |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
347 //mapfile.) |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
348 NodeList list = layerElement.getElementsByTagName("renderer"); |
41
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
349 |
42
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
350 //Create all found class objects and write the symbols and styles for |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
351 //each class. |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
352 for(int i = 0; i < list.getLength(); i++) { |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
353 Element classElement = (Element)list.item(i); |
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
354 classObj co = new classObj(layer); |
124
0f5819732288
Set label text as class name in mapfile.
Raimund Renkert <rrenkert@intevation.de>
parents:
120
diff
changeset
|
355 String name = classElement.getAttribute("label"); |
189
0965f8af70fa
Replace german umlauts and trim strings.
raimund renkert <raimund.renkert@intevation.de>
parents:
186
diff
changeset
|
356 name = validateString(name); |
99
d6d2a4058ebf
Set the class name to the layer name if it is empty.
Raimund Renkert <rrenkert@intevation.de>
parents:
98
diff
changeset
|
357 if (name.equals("")) { |
d6d2a4058ebf
Set the class name to the layer name if it is empty.
Raimund Renkert <rrenkert@intevation.de>
parents:
98
diff
changeset
|
358 name = layerElement.getAttribute("name"); |
189
0965f8af70fa
Replace german umlauts and trim strings.
raimund renkert <raimund.renkert@intevation.de>
parents:
186
diff
changeset
|
359 name = validateString(name); |
99
d6d2a4058ebf
Set the class name to the layer name if it is empty.
Raimund Renkert <rrenkert@intevation.de>
parents:
98
diff
changeset
|
360 if (list.getLength() > 1) { |
d6d2a4058ebf
Set the class name to the layer name if it is empty.
Raimund Renkert <rrenkert@intevation.de>
parents:
98
diff
changeset
|
361 name += "-" + i; |
d6d2a4058ebf
Set the class name to the layer name if it is empty.
Raimund Renkert <rrenkert@intevation.de>
parents:
98
diff
changeset
|
362 } |
d6d2a4058ebf
Set the class name to the layer name if it is empty.
Raimund Renkert <rrenkert@intevation.de>
parents:
98
diff
changeset
|
363 } |
d6d2a4058ebf
Set the class name to the layer name if it is empty.
Raimund Renkert <rrenkert@intevation.de>
parents:
98
diff
changeset
|
364 co.setName (name); |
179
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
175
diff
changeset
|
365 |
181 | 366 //Create label object. |
180
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
367 NodeList labels = layerElement.getElementsByTagName("label"); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
368 if(labels.getLength() > 0) { |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
369 Element labelElement = (Element)labels.item(0); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
370 String layerType = layerElement.getAttribute("type"); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
371 writeLabel(co, labelElement, layerType); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
372 } |
181 | 373 |
374 //Create definition expression. | |
44
9b5fb5e5914d
Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
375 if(classElement.hasAttribute("field_count")) { |
152
8a87c796bf47
Fixed expression for the first min value.
vc11884admin@VC11884.win.bsh.de
parents:
148
diff
changeset
|
376 co.setExpression(createExpression(classElement, i)); |
44
9b5fb5e5914d
Added expressions for mapserver classes.
Raimund Renkert <rrenkert@intevation.de>
parents:
43
diff
changeset
|
377 } |
181 | 378 |
42
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
379 //Write symbols and styles. |
97
18e4f143896b
Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
96
diff
changeset
|
380 NodeList l = classElement.getChildNodes(); |
141
8f30f7e802d6
Manage symbol names and symbol comparison.
vc11884admin@VC11884.win.bsh.de
parents:
137
diff
changeset
|
381 for (int j = l.getLength() - 1; j >= 0; j--) { |
97
18e4f143896b
Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
96
diff
changeset
|
382 Element elem = (Element)l.item(j); |
18e4f143896b
Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
96
diff
changeset
|
383 |
18e4f143896b
Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
96
diff
changeset
|
384 String type = layerElement.getAttribute("type"); |
180
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
385 if(type.equals("point") && |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
386 elem.getTagName().equals("symbol")) { |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
387 MarkerStyleWriter swriter = |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
388 new MarkerStyleWriter (this.map, co); |
97
18e4f143896b
Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
96
diff
changeset
|
389 swriter.write (elem); |
87
7d4cf2db43f1
Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
62
diff
changeset
|
390 } |
180
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
391 else if(type.equals("line") && |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
392 elem.getTagName().equals("symbol")) { |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
393 LineStyleWriter swriter = |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
394 new LineStyleWriter (this.map, co); |
97
18e4f143896b
Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
96
diff
changeset
|
395 swriter.write (elem); |
18e4f143896b
Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
96
diff
changeset
|
396 } |
180
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
397 else if(type.equals("polygon") && |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
398 elem.getTagName().equals("symbol")) { |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
399 FillStyleWriter swriter = |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
400 new FillStyleWriter (this.map, co); |
97
18e4f143896b
Added polygon writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
96
diff
changeset
|
401 swriter.write (elem); |
87
7d4cf2db43f1
Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
62
diff
changeset
|
402 } |
7d4cf2db43f1
Added new writer classes to be flexible in creating mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
62
diff
changeset
|
403 } |
42
395307e8b7ee
First MapScript Writer that generates valid mapfiles.
Raimund Renkert <rrenkert@intevation.de>
parents:
41
diff
changeset
|
404 } |
41
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
405 } |
126
ff0354265a7d
Write the correct expression for double values.
Raimund Renkert <rrenkert@intevation.de>
parents:
124
diff
changeset
|
406 |
181 | 407 /** |
408 * Create a label object in a class object. | |
409 * | |
410 * @param co Class object. | |
411 * @param labelElement DOM element containing label attributes. | |
412 * @param layertype The layer type. Used to define the label position. | |
413 */ | |
179
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
175
diff
changeset
|
414 private void writeLabel( |
180
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
415 classObj co, |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
416 Element labelElement, |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
417 String layerType) { |
179
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
175
diff
changeset
|
418 |
181 | 419 //Get the label object. Each class has a predefined labelobject. |
179
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
175
diff
changeset
|
420 labelObj label = co.getLabel(); |
181 | 421 |
422 //Get the label text symbol attributes from DOM. | |
180
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
423 Element symbol = (Element)labelElement.getFirstChild(); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
424 if(symbol != null && symbol.getTagName().equals("symbol")) { |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
425 String type = symbol.getAttribute("type"); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
426 if(type.equals("text")) { |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
427 label.setType(MS_FONT_TYPE.MS_TRUETYPE); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
428 } |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
429 label.setSize(Double.parseDouble(symbol.getAttribute("size"))); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
430 |
179
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
175
diff
changeset
|
431 if(symbol.hasAttribute("color")) { |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
175
diff
changeset
|
432 String c = symbol.getAttribute("color"); |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
175
diff
changeset
|
433 Color col = Color.decode(c); |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
175
diff
changeset
|
434 colorObj color = new colorObj( |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
175
diff
changeset
|
435 col.getRed(), |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
175
diff
changeset
|
436 col.getGreen(), |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
175
diff
changeset
|
437 col.getBlue(), |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
175
diff
changeset
|
438 -4); |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
175
diff
changeset
|
439 label.setColor(color); |
180
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
440 } |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
441 if(symbol.hasAttribute("font")) { |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
442 String font = symbol.getAttribute("font"); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
443 fontSetObj fso = this.map.getFontset(); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
444 hashTableObj fonts = fso.getFonts(); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
445 String mapFont = fonts.get(font,""); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
446 if(mapFont != null && !mapFont.equals("")) { |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
447 label.setFont(font); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
448 } |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
449 else { |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
450 logger.info( |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
451 "Could not find font " + font + " in font set. " + |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
452 "Using FreeSans for labels."); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
453 label.setFont("FreeSans"); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
454 } |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
455 } |
179
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
175
diff
changeset
|
456 |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
175
diff
changeset
|
457 if(labelElement.hasAttribute("max_scale")) { |
180
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
458 double min = |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
459 Double.parseDouble(labelElement.getAttribute("max_scale")); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
460 if(min > 0) { |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
461 label.setMinscaledenom(min); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
462 } |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
463 } |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
464 if(labelElement.hasAttribute("min_scale")) { |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
465 double max = |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
466 Double.parseDouble(labelElement.getAttribute("min_scale")); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
467 if(max > 0) { |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
468 label.setMaxscaledenom(max); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
469 } |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
470 } |
179
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
175
diff
changeset
|
471 |
181 | 472 //Set the label position. |
180
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
473 if(layerType.equals("point")) { |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
474 label.setPosition(MS_POSITIONS_ENUM.MS_UC.swigValue()); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
475 } |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
476 } |
179
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
175
diff
changeset
|
477 } |
f3a91cd7440b
Added a first version of feature labeling.
raimund renkert <raimund.renkert@intevation.de>
parents:
175
diff
changeset
|
478 |
181 | 479 /** |
480 * Create definition expression. | |
481 * | |
482 * @param ce DOM elementcontaining the class expression information. | |
483 * @param index Index to determine the correct expression operator. | |
484 */ | |
152
8a87c796bf47
Fixed expression for the first min value.
vc11884admin@VC11884.win.bsh.de
parents:
148
diff
changeset
|
485 private String createExpression(Element ce, int index) { |
137
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
486 String expression = "("; |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
487 int count = 0; |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
488 try { |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
489 count = Integer.parseInt(ce.getAttribute("field_count")); |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
490 } |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
491 catch(NumberFormatException nfe) { |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
492 return ""; |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
493 } |
181 | 494 |
137
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
495 if(count == 1) { |
181 | 496 //Create single field expression. |
497 try { | |
498 //If no exception is thrown, the expression value is a number. | |
134
acc9e5430177
Handle SDE connection attributes and expressions.
vc11884admin@VC11884.win.bsh.de
parents:
132
diff
changeset
|
499 Double.parseDouble(ce.getAttribute("value")); |
137
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
500 String exp = ce.getAttribute("expression_field_0"); |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
501 String pre = ""; |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
502 if (!prefix.equals("") && !exp.startsWith(prefix)) { |
134
acc9e5430177
Handle SDE connection attributes and expressions.
vc11884admin@VC11884.win.bsh.de
parents:
132
diff
changeset
|
503 pre = prefix + "."; |
137
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
504 } |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
505 expression += "[" + pre; |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
506 expression += ce.getAttribute("expression_field_0") + "]"; |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
507 if(ce.hasAttribute("min_value")) { |
180
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
508 if(index == 0) { |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
509 expression += " >= " + ce.getAttribute("min_value"); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
510 } |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
511 else { |
152
8a87c796bf47
Fixed expression for the first min value.
vc11884admin@VC11884.win.bsh.de
parents:
148
diff
changeset
|
512 expression += " > " + ce.getAttribute("min_value"); |
180
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
513 } |
181 | 514 expression += " AND [" + pre; |
515 expression += ce.getAttribute("expression_field_0"); | |
516 expression += "]"; | |
137
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
517 } |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
518 expression += " " + ce.getAttribute("expression_operator"); |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
519 expression += " " + ce.getAttribute("value") + ")"; |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
520 } |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
521 catch(NumberFormatException nfe) { |
181 | 522 //The expression value is a strings. |
137
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
523 String exp = ce.getAttribute("expression_field_0"); |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
524 String pre = ""; |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
525 if (!prefix.equals("") && !exp.startsWith(prefix)) { |
134
acc9e5430177
Handle SDE connection attributes and expressions.
vc11884admin@VC11884.win.bsh.de
parents:
132
diff
changeset
|
526 pre = prefix + "."; |
137
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
527 } |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
528 expression += "\"[" + pre; |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
529 expression += ce.getAttribute("expression_field_0") + "]\""; |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
530 expression += " " + ce.getAttribute("expression_operator"); |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
531 expression += " \"" + ce.getAttribute("value") + "\")"; |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
532 } |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
533 catch(Exception e) { |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
534 e.printStackTrace(); |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
535 } |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
536 } |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
537 else { |
181 | 538 //Create a multi field expression. |
134
acc9e5430177
Handle SDE connection attributes and expressions.
vc11884admin@VC11884.win.bsh.de
parents:
132
diff
changeset
|
539 for (int i = 0; i < count; i++) { |
acc9e5430177
Handle SDE connection attributes and expressions.
vc11884admin@VC11884.win.bsh.de
parents:
132
diff
changeset
|
540 try { |
181 | 541 //If no exception is thrown, the expression values are |
542 //numbers. | |
134
acc9e5430177
Handle SDE connection attributes and expressions.
vc11884admin@VC11884.win.bsh.de
parents:
132
diff
changeset
|
543 Double.parseDouble(ce.getAttribute("value_" + i)); |
acc9e5430177
Handle SDE connection attributes and expressions.
vc11884admin@VC11884.win.bsh.de
parents:
132
diff
changeset
|
544 String exp = ce.getAttribute("expression_field_" + i); |
acc9e5430177
Handle SDE connection attributes and expressions.
vc11884admin@VC11884.win.bsh.de
parents:
132
diff
changeset
|
545 String pre = ""; |
acc9e5430177
Handle SDE connection attributes and expressions.
vc11884admin@VC11884.win.bsh.de
parents:
132
diff
changeset
|
546 if (!prefix.equals("") && !exp.startsWith(prefix)) { |
acc9e5430177
Handle SDE connection attributes and expressions.
vc11884admin@VC11884.win.bsh.de
parents:
132
diff
changeset
|
547 pre = prefix + "."; |
acc9e5430177
Handle SDE connection attributes and expressions.
vc11884admin@VC11884.win.bsh.de
parents:
132
diff
changeset
|
548 } |
acc9e5430177
Handle SDE connection attributes and expressions.
vc11884admin@VC11884.win.bsh.de
parents:
132
diff
changeset
|
549 expression += "[" + pre; |
180
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
550 expression += ce.getAttribute("expression_field_" + i); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
551 expression += "]"; |
134
acc9e5430177
Handle SDE connection attributes and expressions.
vc11884admin@VC11884.win.bsh.de
parents:
132
diff
changeset
|
552 expression += " " + ce.getAttribute("expression_operator"); |
acc9e5430177
Handle SDE connection attributes and expressions.
vc11884admin@VC11884.win.bsh.de
parents:
132
diff
changeset
|
553 expression += " " + ce.getAttribute("value_" + i); |
137
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
554 if (i < count - 1) { |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
555 expression += " AND "; |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
556 } |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
557 else { |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
558 expression += ")"; |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
559 } |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
560 } |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
561 catch (NumberFormatException nfe) { |
181 | 562 //The expression values are strings. |
137
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
563 String exp = ce.getAttribute("expression_field_" + i); |
134
acc9e5430177
Handle SDE connection attributes and expressions.
vc11884admin@VC11884.win.bsh.de
parents:
132
diff
changeset
|
564 String pre = ""; |
acc9e5430177
Handle SDE connection attributes and expressions.
vc11884admin@VC11884.win.bsh.de
parents:
132
diff
changeset
|
565 if (!prefix.equals("") && !exp.startsWith(prefix)) { |
acc9e5430177
Handle SDE connection attributes and expressions.
vc11884admin@VC11884.win.bsh.de
parents:
132
diff
changeset
|
566 pre = prefix + "."; |
acc9e5430177
Handle SDE connection attributes and expressions.
vc11884admin@VC11884.win.bsh.de
parents:
132
diff
changeset
|
567 } |
acc9e5430177
Handle SDE connection attributes and expressions.
vc11884admin@VC11884.win.bsh.de
parents:
132
diff
changeset
|
568 expression += "\"[" + pre; |
180
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
569 expression += ce.getAttribute("expression_field_" + i); |
f4eb506499f5
Done some code styling and removed TODOs.
Raimund Renkert <rrenkert@intevation.de>
parents:
179
diff
changeset
|
570 expression += "]\""; |
134
acc9e5430177
Handle SDE connection attributes and expressions.
vc11884admin@VC11884.win.bsh.de
parents:
132
diff
changeset
|
571 expression += " " + ce.getAttribute("expression_operator"); |
186
1391f911ee39
Add quotes to an expression if the value is a string.
raimund renkert <raimund.renkert@intevation.de>
parents:
181
diff
changeset
|
572 expression += " \"" + ce.getAttribute("value_" + i); |
137
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
573 if (i < count - 1) { |
186
1391f911ee39
Add quotes to an expression if the value is a string.
raimund renkert <raimund.renkert@intevation.de>
parents:
181
diff
changeset
|
574 expression += "\" AND "; |
137
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
575 } |
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
576 else { |
186
1391f911ee39
Add quotes to an expression if the value is a string.
raimund renkert <raimund.renkert@intevation.de>
parents:
181
diff
changeset
|
577 expression += "\")"; |
137
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
578 } |
126
ff0354265a7d
Write the correct expression for double values.
Raimund Renkert <rrenkert@intevation.de>
parents:
124
diff
changeset
|
579 } |
ff0354265a7d
Write the correct expression for double values.
Raimund Renkert <rrenkert@intevation.de>
parents:
124
diff
changeset
|
580 } |
ff0354265a7d
Write the correct expression for double values.
Raimund Renkert <rrenkert@intevation.de>
parents:
124
diff
changeset
|
581 } |
137
cd55975ba0c4
Done some minor reformatings.
Raimund Renkert <rrenkert@intevation.de>
parents:
134
diff
changeset
|
582 return expression; |
127
5ba8bf865dc7
Write expressions for string values to the mapfile.
Raimund Renkert <rrenkert@intevation.de>
parents:
126
diff
changeset
|
583 } |
189
0965f8af70fa
Replace german umlauts and trim strings.
raimund renkert <raimund.renkert@intevation.de>
parents:
186
diff
changeset
|
584 |
0965f8af70fa
Replace german umlauts and trim strings.
raimund renkert <raimund.renkert@intevation.de>
parents:
186
diff
changeset
|
585 /** |
0965f8af70fa
Replace german umlauts and trim strings.
raimund renkert <raimund.renkert@intevation.de>
parents:
186
diff
changeset
|
586 * Replaces german umlauts and removes leading and trailing whitespaces. |
0965f8af70fa
Replace german umlauts and trim strings.
raimund renkert <raimund.renkert@intevation.de>
parents:
186
diff
changeset
|
587 * |
0965f8af70fa
Replace german umlauts and trim strings.
raimund renkert <raimund.renkert@intevation.de>
parents:
186
diff
changeset
|
588 * @param s String |
0965f8af70fa
Replace german umlauts and trim strings.
raimund renkert <raimund.renkert@intevation.de>
parents:
186
diff
changeset
|
589 */ |
0965f8af70fa
Replace german umlauts and trim strings.
raimund renkert <raimund.renkert@intevation.de>
parents:
186
diff
changeset
|
590 private String validateString (String s) { |
0965f8af70fa
Replace german umlauts and trim strings.
raimund renkert <raimund.renkert@intevation.de>
parents:
186
diff
changeset
|
591 if (s.equals("")) { |
0965f8af70fa
Replace german umlauts and trim strings.
raimund renkert <raimund.renkert@intevation.de>
parents:
186
diff
changeset
|
592 return ""; |
0965f8af70fa
Replace german umlauts and trim strings.
raimund renkert <raimund.renkert@intevation.de>
parents:
186
diff
changeset
|
593 } |
0965f8af70fa
Replace german umlauts and trim strings.
raimund renkert <raimund.renkert@intevation.de>
parents:
186
diff
changeset
|
594 String tmp = s.trim(); |
0965f8af70fa
Replace german umlauts and trim strings.
raimund renkert <raimund.renkert@intevation.de>
parents:
186
diff
changeset
|
595 tmp = tmp.replace ("�", "oe"); |
0965f8af70fa
Replace german umlauts and trim strings.
raimund renkert <raimund.renkert@intevation.de>
parents:
186
diff
changeset
|
596 tmp = tmp.replace ("�", "ae"); |
0965f8af70fa
Replace german umlauts and trim strings.
raimund renkert <raimund.renkert@intevation.de>
parents:
186
diff
changeset
|
597 tmp = tmp.replace ("�", "ue"); |
0965f8af70fa
Replace german umlauts and trim strings.
raimund renkert <raimund.renkert@intevation.de>
parents:
186
diff
changeset
|
598 tmp = tmp.replace ("�", "ss"); |
0965f8af70fa
Replace german umlauts and trim strings.
raimund renkert <raimund.renkert@intevation.de>
parents:
186
diff
changeset
|
599 return tmp; |
0965f8af70fa
Replace german umlauts and trim strings.
raimund renkert <raimund.renkert@intevation.de>
parents:
186
diff
changeset
|
600 } |
41
60ed2164035a
Introduced MapScript writer.
Raimund Renkert <rrenkert@intevation.de>
parents:
diff
changeset
|
601 } |