Revision 29013

View differences:

trunk/extensions/extSymbology/src/org/gvsig/remoteClient/sld/SLDTags.java
41 41
package org.gvsig.remoteClient.sld;
42 42
/**
43 43
 * Tags for SLD
44
 * 
44
 *
45 45
 * @see http://portal.opengeospatial.org/files/?artifact_id=1188
46
 * 
46
 *
47 47
 * @author pepe vidal salvador - jose.vidal.salvador@iver.es
48 48
 */
49 49
public class SLDTags
50 50
{
51 51
	public final static String SLD_ROOT="StyledLayerDescriptor";
52 52
	public final static String VERSION_ATTR="version";
53
	
53

  
54 54
	public final static String NAMEDLAYER="NamedLayer";
55 55
	public final static String USERDEFINEDLAYER="UserLayer";
56 56
	public final static String NAME="Name";
......
78 78
	public static final String CSSPARAMETER = "CssParameter";
79 79
	public static final String NAME_ATTR = "name";
80 80

  
81
	public static final String NAME_ATTR_VERSAL = "Name";//Ppara compatibilizar leyendas generadas con la 1.1.2
82

  
81 83
	public static final String FILL = "Fill";
82 84
	public static final String FILL_ATTR = "fill";
83 85
	public static final String FILLOPACITY_ATTR = "fill-opacity";
trunk/extensions/extSymbology/src/org/gvsig/remoteClient/sld/filterEncoding/FExpression.java
52 52

  
53 53

  
54 54
/**
55
 * Implements the main functionalities to parse an Filter Encoding 
55
 * Implements the main functionalities to parse an Filter Encoding
56 56
 * expression<br>
57
 * The expression element is an abstrac element which means that it 
57
 * The expression element is an abstrac element which means that it
58 58
 * does not really exist and its only purpose is to act as a placeholder
59 59
 * for the elements and combinations of elements that can be used o form
60
 * expressions. 
61
 * 
62
 * @see http://www.opengeospatial.org/standards/filter 
60
 * expressions.
61
 *
62
 * @see http://www.opengeospatial.org/standards/filter
63 63
 * @author pepe vidal salvador - jose.vidal.salvador@iver.es
64 64
 */
65 65
public class FExpression  {
66
	
66

  
67 67
	protected String literal;
68 68
	protected String propertyName;
69 69
	protected String function;
......
71 71
	protected FExpression insideExpression;
72 72
	protected FExpression insideExpression2;
73 73
	boolean isPropertyName = false;
74
	
74

  
75 75
	String expressionStr = "";
76
	
76

  
77 77
	Set <String> fieldNames = new HashSet <String>();
78
	
78

  
79 79
	double value;
80
	
81
	
80

  
81

  
82 82
	public void parse(XMLSchemaParser parser, int Tag2, String expressionType) throws XmlPullParserException, IOException, LegendDriverException {
83 83

  
84 84
		int currentTag;
......
91 91
			switch(currentTag)
92 92
			{
93 93
			case XMLSchemaParser.START_TAG:
94
				
94

  
95 95
				if (parser.getName().compareTo(FilterUtils.remNameSpace(FilterTags.PROPERTYNAME))==0) {
96 96
					this.propertyName = parser.nextText();
97
					fieldNames.add(this.propertyName);	
97
					fieldNames.add(this.propertyName);
98 98
					isPropertyName = true;
99 99
					end = true;
100 100
					expressionStr +="["+this.propertyName +"] ";
101 101
				}
102 102
				else if (parser.getName().compareTo(FilterUtils.remNameSpace(FilterTags.LITERAL))==0) {
103 103
					this.literal = parser.nextText();
104
					if (!this.literal.startsWith("#")) 
105
						if (SLDUtils.isANumber(this.literal))
104
					String myLiteral = this.literal;
105
					if (!this.literal.startsWith("#"))
106
						if (SLDUtils.isANumber(this.literal)) {
106 107
							setValue(Double.valueOf(this.literal));
108
						} else {
109
							/*
110
							 * Parche para leer las leyendas generadas con versiones anteriores que
111
							 * no pon?an comillas para identificar los literales
112
							 */
113
							if (!(this.literal.startsWith("\"") && this.literal.endsWith("\""))){
114
								myLiteral = "\""+this.literal +"\"";
115
							}
116
							/* Fin del parche */
117
						}
107 118
					end = true;
108
					expressionStr += this.literal +" ";
119
					expressionStr += myLiteral +" ";
109 120
				}
110 121
				else if (parser.getName().compareTo(FilterUtils.remNameSpace(FilterTags.FUNCTION))==0) {
111 122
					this.function = parser.nextText();
......
115 126
				(parser.getName().compareTo(FilterUtils.remNameSpace(FilterTags.DIV))==0) ||
116 127
				(parser.getName().compareTo(FilterUtils.remNameSpace(FilterTags.MULT))==0) ||
117 128
				(parser.getName().compareTo(FilterUtils.remNameSpace(FilterTags.SUB))==0) ){
118
					
129

  
119 130
					String operation = parser.getName();
120 131
					currentTag = parser.nextTag();
121 132
					this.insideExpression = new FExpression();
122 133
					expressionStr += "( ";
123
					
134

  
124 135
					this.insideExpression.parse(parser,currentTag,parser.getName());
125 136
					expressionStr += insideExpression.getExpressionStr();
126
					
137

  
127 138
					expressionStr += FilterUtils.getSymbol4Expression("ogc:"+operation)+" ";
128
					
139

  
129 140
					fieldNames.addAll(insideExpression.getFieldNames());
130 141
					currentTag = parser.nextTag();
131 142
					this.insideExpression2 = new FExpression();
132
					
143

  
133 144
					this.insideExpression2.parse(parser,currentTag,parser.getName());
134 145
					expressionStr += insideExpression2.getExpressionStr();
135
					
146

  
136 147
					expressionStr += ") ";
137
					
148

  
138 149
					fieldNames.addAll(insideExpression2.getFieldNames());
139 150
					parser.nextTag();
140 151
					if (insideExpression == null && insideExpression2 == null)
141 152
						throw new LegendDriverException (LegendDriverException.PARSE_LEGEND_FILE_ERROR);
142 153
					end = true;
143
					
144
					
154

  
155

  
145 156
				}
146
			
147
				break;	
157

  
158
				break;
148 159
			case XMLSchemaParser.END_TAG:
149 160
				if (parser.getName().compareTo(FilterUtils.remNameSpace(FilterTags.PROPERTYNAME))!=0 &&
150 161
						parser.getName().compareTo(FilterUtils.remNameSpace(FilterTags.LITERAL))!=0 &&
151
						parser.getName().compareTo(FilterUtils.remNameSpace(FilterTags.FUNCTION))!=0 && 
162
						parser.getName().compareTo(FilterUtils.remNameSpace(FilterTags.FUNCTION))!=0 &&
152 163
						parser.getName().compareTo(FilterUtils.remNameSpace(FilterTags.ADD))!=0 &&
153 164
						parser.getName().compareTo(FilterUtils.remNameSpace(FilterTags.DIV))!=0 &&
154 165
						parser.getName().compareTo(FilterUtils.remNameSpace(FilterTags.MULT))!=0 &&
......
167 178

  
168 179

  
169 180
	public String getLiteral() { return literal; }
170
	public void setLiteral(String literal) { 
181
	public void setLiteral(String literal) {
171 182
		this.literal = literal; }
172 183
	public String getPropertyName() { return propertyName; }
173 184
	public void setPropertyName(String propertyName) { this.propertyName = propertyName; }
trunk/extensions/extSymbology/src/org/gvsig/remoteClient/sld/sld1_0_0/SLDStroke1_0_0.java
58 58
 * Implements the Stroke element of an SLD specification which
59 59
 * encapsulates the graphical-symbolization parameters for linear
60 60
 * geometries
61
 * 
61
 *
62 62
 * @see http://portal.opengeospatial.org/files/?artifact_id=1188
63
 * 
63
 *
64 64
 * @author pepe vidal salvador - jose.vidal.salvador@iver.es
65 65
 */
66 66
public class SLDStroke1_0_0 extends SLDStroke {
......
92 92
						setHasGraphicStroke(true);
93 93
				}
94 94
				else if (parser.getName().compareTo(SLDTags.CSSPARAMETER)==0) {
95
					if(parser.getAttributeValue("", SLDTags.NAME_ATTR).compareTo(SLDTags.STROKE_WIDTH_ATTR)==0) {
95
					String attributeName = parser.getAttributeValue("", SLDTags.NAME_ATTR);
96
					/*
97
					 * Parche para compatibilizar leyendas generadas con la 1.1.2
98
					 * donde el atributo "name" se pone con la primera letra mayuscula "Name"
99
					 */
100
					if (attributeName == null){
101
						attributeName = parser.getAttributeValue("", SLDTags.NAME_ATTR_VERSAL);
102
					}
103
					/* Fin del parche */
104
					if(attributeName.compareTo(SLDTags.STROKE_WIDTH_ATTR)==0) {
96 105
						FExpression expressionWidth = new FExpression();
97 106

  
98 107
						try {
......
108 117

  
109 118
						setExpressionWidth(expressionWidth);
110 119
					}
111
					else if(parser.getAttributeValue("", SLDTags.NAME_ATTR).compareTo(SLDTags.STROKE_ATTR)==0) {
120
					else if(attributeName.compareTo(SLDTags.STROKE_ATTR)==0) {
112 121
						FExpression expressionColor = new FExpression();
113 122

  
114 123

  
......
125 134

  
126 135
						setExpressionColor(expressionColor);
127 136
					}
128
					else if(parser.getAttributeValue("", SLDTags.NAME_ATTR).compareTo(SLDTags.STROKE_OPACITY_ATTR)==0) {
137
					else if(attributeName.compareTo(SLDTags.STROKE_OPACITY_ATTR)==0) {
129 138
						FExpression expressionOpacity = new FExpression();
130 139

  
131 140

  
......
143 152

  
144 153
						setExpressionOpacity(expressionOpacity);
145 154
					}
146
					else if(parser.getAttributeValue("", SLDTags.NAME_ATTR).compareTo(SLDTags.STROKE_LINEJOIN_ATTR)==0) {
155
					else if(attributeName.compareTo(SLDTags.STROKE_LINEJOIN_ATTR)==0) {
147 156

  
148 157
						FExpression expressionLineJoin = new FExpression();
149 158

  
......
160 169

  
161 170
						setExpressionLineJoin(expressionLineJoin);
162 171
					}
163
					else if(parser.getAttributeValue("", SLDTags.NAME_ATTR).compareTo(SLDTags.STROKE_LINECAP_ATTR)==0) {
172
					else if(attributeName.compareTo(SLDTags.STROKE_LINECAP_ATTR)==0) {
164 173

  
165 174
						FExpression expressionLineCap = new FExpression();
166 175

  
......
177 186

  
178 187
						setExpressionLineCap(expressionLineCap);
179 188
					}
180
					else if(parser.getAttributeValue("", SLDTags.NAME_ATTR).compareTo(SLDTags.STROKE_DASHARRAY_ATTR)==0) {
181
						
182
						
189
					else if(attributeName.compareTo(SLDTags.STROKE_DASHARRAY_ATTR)==0) {
190

  
191

  
183 192
						FExpression expressionDashArray =  new FExpression();
184 193
						try {
185 194
							expressionDashArray.parse(parser,parser.nextTag(), parser.getName());
......
190 199
						catch(XmlPullParserException e) {
191 200
							cad = parser.getText().trim();
192 201
						}
193
						
202

  
194 203
						if (cad==null /*|| "".equals(cad)*/) {
195 204
							throw new LegendDriverException (LegendDriverException.PARSE_LEGEND_FILE_ERROR);
196 205
						} else {
......
205 214
										y = "";
206 215
										cont++;
207 216
									}
208
									else 
217
									else
209 218
										throw new LegendDriverException(LegendDriverException.PARSE_LEGEND_FILE_ERROR);
210 219
								}
211 220
								else {
......
216 225
											dashArray.add(Float.valueOf(y));
217 226
											cont++;
218 227
										}
219
										else 
228
										else
220 229
											throw new LegendDriverException(LegendDriverException.PARSE_LEGEND_FILE_ERROR);
221 230
									}
222 231

  
223 232
								}
224
							}	
233
							}
225 234
						}
226 235
					}
227 236

  
228
					else if(parser.getAttributeValue("", SLDTags.NAME_ATTR).compareTo(SLDTags.STROKE_DASHOFFSET_ATTR)==0) {
237
					else if(attributeName.compareTo(SLDTags.STROKE_DASHOFFSET_ATTR)==0) {
229 238
						FExpression expressionDashOffset = new FExpression();
230 239

  
231 240

  
......
240 249
						if (!SLDUtils.isANumber(expressionDashOffset.getLiteral()))
241 250
							throw new LegendDriverException(LegendDriverException.PARSE_LEGEND_FILE_ERROR);
242 251

  
243
						setExpressionDashOffset(expressionDashOffset);	
252
						setExpressionDashOffset(expressionDashOffset);
244 253
					}
245 254
				}
246 255

  
......
278 287
					end = true;
279 288

  
280 289
				}
281
			case XMLSchemaParser.END_TAG:	
290
			case XMLSchemaParser.END_TAG:
282 291
				if (parser.getName().compareTo(FilterUtils.remNameSpace(SLDTags.CSSPARAMETER)) == 0) {
283 292
					parser.next();
284 293
				}
285 294
			}
286
			break;	
295
			break;
287 296
		}
288 297
		if (!end)
289 298
			currentTag = parser.next();

Also available in: Unified diff