Revision 34132
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wcs/wcs_1_0_0/request/WCSGetCoverageRequest1_0_0.java | ||
---|---|---|
59 | 59 |
} else { |
60 | 60 |
req.append("&EXCEPTIONS=XML"); |
61 | 61 |
} |
62 |
return stringUtils.replaceAll(req.toString(), " ", "%20");
|
|
62 |
return req.toString();
|
|
63 | 63 |
} |
64 | 64 |
|
65 | 65 |
} |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wfs/filters/filterencoding/FilterEncoding.java | ||
---|---|---|
48 | 48 |
import org.gvsig.compat.CompatLocator; |
49 | 49 |
import org.gvsig.compat.lang.StringUtils; |
50 | 50 |
import org.gvsig.remoteclient.wfs.WFSStatus; |
51 |
import org.gvsig.remoteclient.wfs.edition.WFSTTags; |
|
51 | 52 |
import org.gvsig.remoteclient.wfs.filters.AbstractFilter; |
52 | 53 |
import org.gvsig.remoteclient.wfs.filters.BinaryTree; |
53 | 54 |
import org.gvsig.remoteclient.wfs.filters.BinaryTree.Node; |
... | ... | |
71 | 72 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
72 | 73 |
*/ |
73 | 74 |
public class FilterEncoding extends AbstractFilter { |
74 |
public static final int RELATIONSHIP_PROPERTY = 0;
|
|
75 |
public static final int RELATIONSHIP_VAUES = 1;
|
|
75 |
public static final int RELATIONSHIP_PROPERTY = 0;
|
|
76 |
public static final int RELATIONSHIP_VAUES = 1;
|
|
76 | 77 |
|
77 |
private StringBuffer currentQuery = null; |
|
78 |
//Operation types |
|
79 |
private static final int OPERATION_PROPERTYNAME = 0; |
|
80 |
private static final int OPERATION_LITERAL = 1; |
|
81 |
//Filter namespace. (typically "ogc") |
|
82 |
private String namepacePrefix = null; |
|
83 |
//If the Filter can have blanckSpaces |
|
84 |
private boolean hasBlankSpaces = true; |
|
85 |
private String defaultBlankSpace = "%20"; |
|
86 |
//This character must be replaced by any set of characters (typically "*") |
|
87 |
private String wildCardChar = null; |
|
88 |
//This character must be replaced by one character (typically "?") |
|
89 |
private String singleChar = null; |
|
90 |
//Escape character (typically "\") |
|
91 |
private String escapeChar = null; |
|
92 |
//Default values |
|
93 |
public static final String DEFAULT_NAMESPACE_PREFIX = "ogc"; |
|
94 |
public static final String DEFAULT_WILDCARD = "*"; |
|
95 |
public static final String DEFAULT_SINGLECHAR = "?"; |
|
96 |
public static final String DEFAULT_ESCAPE = "\\"; |
|
97 |
public static final String DEFAULT_NAMESPACE = "xmlns:ogc=\"http://www.opengis.net/ogc\""; |
|
78 |
private StringBuffer currentQuery = null; |
|
79 |
//Operation types |
|
80 |
private static final int OPERATION_PROPERTYNAME = 0; |
|
81 |
private static final int OPERATION_LITERAL = 1; |
|
82 |
|
|
83 |
//Filter namespace. |
|
84 |
private String nameSpacePrefix = null; |
|
85 |
private String nameSpaceLocation = null; |
|
98 | 86 |
|
99 |
private Hashtable filterAttributes = new Hashtable(); |
|
87 |
//If the Filter can have blanckSpaces |
|
88 |
private boolean hasBlankSpaces = true; |
|
89 |
private String defaultBlankSpace = "%20"; |
|
90 |
//This character must be replaced by any set of characters (typically "*") |
|
91 |
private String wildCardChar = null; |
|
92 |
//This character must be replaced by one character (typically "?") |
|
93 |
private String singleChar = null; |
|
94 |
//Escape character (typically "\") |
|
95 |
private String escapeChar = null; |
|
96 |
//Default values |
|
97 |
public static final String DEFAULT_NAMESPACE_PREFIX = "ogc"; |
|
98 |
public static final String DEFAULT_WILDCARD = "*"; |
|
99 |
public static final String DEFAULT_SINGLECHAR = "?"; |
|
100 |
public static final String DEFAULT_ESCAPE = "\\"; |
|
101 |
public static final String DEFAULT_NAMESPACE = "xmlns:ogc=\"http://www.opengis.net/ogc\""; |
|
100 | 102 |
|
101 |
/** |
|
102 |
* If the namespace XML is qualified |
|
103 |
*/ |
|
104 |
private boolean isQualified = false; |
|
103 |
private Hashtable filterAttributes = new Hashtable(); |
|
105 | 104 |
|
106 |
private static final StringUtils stringUtils = CompatLocator.getStringUtils(); |
|
107 |
|
|
108 |
/** |
|
109 |
* Create a new Filter Encoding Parser |
|
110 |
* |
|
111 |
* |
|
112 |
* @param namepacePrefix |
|
113 |
* Filter namespace. (typically "ogc") |
|
114 |
* @param wildCardChar |
|
115 |
* This character must be replaced by any set of characters (typically "*") |
|
116 |
* @param singleChar |
|
117 |
* This character must be replaced by one character (typically "?") |
|
118 |
* @param escape |
|
119 |
* Escape character |
|
120 |
* @param filterAttribute Sometimes, "Field" label needs an attribute. |
|
121 |
*/ |
|
122 |
public FilterEncoding(ISQLExpressionFormat formatter,String namesPacePrefix, String wildCard, String singleChar, String escape, Hashtable filterAttributes) { |
|
123 |
super(formatter); |
|
124 |
if (namesPacePrefix == null){ |
|
125 |
setQualified(false); |
|
126 |
}else{ |
|
127 |
setQualified(true); |
|
128 |
} |
|
129 |
this.wildCardChar = wildCard; |
|
130 |
this.singleChar = singleChar; |
|
131 |
this.escapeChar = escape; |
|
132 |
this.filterAttributes = filterAttributes; |
|
133 |
} |
|
105 |
/** |
|
106 |
* If the namespace XML is qualified |
|
107 |
*/ |
|
108 |
private boolean isQualified = false; |
|
134 | 109 |
|
110 |
private static final StringUtils stringUtils = CompatLocator.getStringUtils(); |
|
135 | 111 |
|
136 |
/** |
|
137 |
* Create a new Filter Encoding Parser |
|
138 |
* @param formatter |
|
139 |
*/ |
|
140 |
public FilterEncoding(ISQLExpressionFormat formatter) { |
|
141 |
this(formatter,null,DEFAULT_WILDCARD,DEFAULT_SINGLECHAR, |
|
142 |
DEFAULT_ESCAPE,new Hashtable()); |
|
143 |
} |
|
112 |
/** |
|
113 |
* Create a new Filter Encoding Parser |
|
114 |
* |
|
115 |
* |
|
116 |
* @param nameSpacePrefix |
|
117 |
* Filter namespace. (typically "ogc") |
|
118 |
* @param wildCardChar |
|
119 |
* This character must be replaced by any set of characters (typically "*") |
|
120 |
* @param singleChar |
|
121 |
* This character must be replaced by one character (typically "?") |
|
122 |
* @param escape |
|
123 |
* Escape character |
|
124 |
* @param filterAttribute Sometimes, "Field" label needs an attribute. |
|
125 |
*/ |
|
126 |
public FilterEncoding(ISQLExpressionFormat formatter,String namesPacePrefix, String wildCard, String singleChar, String escape, Hashtable filterAttributes) { |
|
127 |
super(formatter); |
|
128 |
if (namesPacePrefix == null){ |
|
129 |
setQualified(false); |
|
130 |
}else{ |
|
131 |
setQualified(true); |
|
132 |
} |
|
133 |
this.wildCardChar = wildCard; |
|
134 |
this.singleChar = singleChar; |
|
135 |
this.escapeChar = escape; |
|
136 |
this.filterAttributes = filterAttributes; |
|
137 |
} |
|
144 | 138 |
|
145 |
/** |
|
146 |
* Create a new Filter Encoding Parser |
|
147 |
*/ |
|
148 |
public FilterEncoding() { |
|
149 |
this(new DefaultSQLExpressionFormat()); |
|
150 |
} |
|
151 | 139 |
|
152 |
/** |
|
153 |
* Create a new Filter Encoding Parser |
|
154 |
*/ |
|
155 |
public FilterEncoding(WFSStatus status) { |
|
156 |
this(); |
|
157 |
setQueryByAttribute(status.getFilterByAttribute()); |
|
158 |
clearSpatialFilters(); |
|
159 |
addSpatialFilter(status.getFilterByArea()); |
|
160 |
} |
|
140 |
/** |
|
141 |
* Create a new Filter Encoding Parser |
|
142 |
* @param formatter |
|
143 |
*/ |
|
144 |
public FilterEncoding(ISQLExpressionFormat formatter) { |
|
145 |
this(formatter,null,DEFAULT_WILDCARD,DEFAULT_SINGLECHAR, |
|
146 |
DEFAULT_ESCAPE,new Hashtable()); |
|
147 |
} |
|
161 | 148 |
|
162 |
/* |
|
163 |
* (non-Javadoc) |
|
164 |
* @see org.gvsig.remoteClient.filterEncoding.QueryLanguage#toString(org.gvsig.remoteClient.filterEncoding.BinaryTree) |
|
165 |
*/ |
|
166 |
public String toString(BinaryTree tree, String version) { |
|
167 |
//If is a filter by ids... |
|
168 |
StringBuffer idQuery = null; |
|
169 |
if (getIds() != null){ |
|
170 |
idQuery = new StringBuffer(); |
|
171 |
ArrayList ids = getIds(); |
|
172 |
for (int i=0 ; i<ids.size() ; i++){ |
|
173 |
if (ids.get(i) != null){ |
|
174 |
Hashtable attributes = new Hashtable(); |
|
175 |
attributes.put("fid","\"" + ids.get(i).toString() + "\""); |
|
176 |
idQuery.append(setTag("FeatureId", attributes, null)); |
|
177 |
} |
|
178 |
} |
|
179 |
return enclosesWithFilterTag(idQuery.toString()); |
|
180 |
} |
|
181 |
//If is a filter by attributes... |
|
182 |
String filterQuery = null; |
|
183 |
if ((tree.getRoot() == null) && (getSpatialFiltersCount() == 0)){ |
|
184 |
return null; |
|
185 |
} |
|
186 |
if (tree.getRoot() != null){ |
|
187 |
currentQuery = new StringBuffer(); |
|
188 |
filterQuery = getFilterNode(tree.getRoot()); |
|
189 |
if (getSpatialFiltersCount() == 0){ |
|
190 |
return enclosesWithFilterTag(filterQuery); |
|
191 |
} |
|
192 |
} |
|
193 |
//If is a filter by area |
|
194 |
String bboxQuery = null; |
|
195 |
if (getSpatialFiltersCount() > 0){ |
|
196 |
for (int i=0 ; i<getSpatialFiltersCount() ; i++){ |
|
197 |
WFSSpatialFilterOperation spatialFilter = getSpatialFilterAt(i); |
|
198 |
SpatialFEQuery feQuery = null; |
|
199 |
if (spatialFilter instanceof WFSGeometryFilterOperation){ |
|
200 |
feQuery = new GeometryFEQuery((WFSGeometryFilterOperation)spatialFilter); |
|
201 |
}else if (spatialFilter instanceof WFSEnvelopeFilterOperation){ |
|
202 |
//TODO add this for a manager |
|
203 |
if (version.equals("1.0.0")){ |
|
204 |
feQuery = new EnvelopeFEQuery1_0_0((WFSEnvelopeFilterOperation)spatialFilter); |
|
205 |
}else{ |
|
206 |
feQuery = new EnvelopeFEQuery1_1_0((WFSEnvelopeFilterOperation)spatialFilter); |
|
207 |
} |
|
208 |
} |
|
209 |
//If there is a spatial query |
|
210 |
if (feQuery != null){ |
|
211 |
bboxQuery = feQuery.getFilterEncoding(); |
|
212 |
if (tree.getRoot() == null){ |
|
213 |
return bboxQuery; |
|
214 |
} |
|
215 |
} |
|
216 |
} |
|
217 |
} |
|
218 |
return enclosesWithFilterTag(filterQuery + bboxQuery); |
|
219 |
} |
|
149 |
/** |
|
150 |
* Create a new Filter Encoding Parser |
|
151 |
*/ |
|
152 |
FilterEncoding() { |
|
153 |
this(new DefaultSQLExpressionFormat()); |
|
154 |
} |
|
220 | 155 |
|
221 |
/** |
|
222 |
* Gets the filter code from a node |
|
223 |
* @param node |
|
224 |
*/ |
|
225 |
private String getFilterNode(Node node){ |
|
226 |
if (node.isField()){ |
|
227 |
return getExpression(node.getValue()); |
|
228 |
}else{ |
|
229 |
String left = ""; |
|
230 |
String rigth = ""; |
|
231 |
if (node.getLeftNode() != null){ |
|
232 |
left = getFilterNode(node.getLeftNode()); |
|
233 |
} |
|
234 |
if (node.getRigthNode() != null){ |
|
235 |
rigth = getFilterNode(node.getRigthNode()); |
|
236 |
} |
|
237 |
int operationCode = getLogicalOperator(node.getValue()); |
|
238 |
String operation = getLogicalOperator(operationCode); |
|
239 |
return enterLabel(left+rigth, operation); |
|
240 |
} |
|
241 |
} |
|
156 |
/** |
|
157 |
* Create a new Filter Encoding Parser |
|
158 |
*/ |
|
159 |
public FilterEncoding(WFSStatus status) { |
|
160 |
this(); |
|
161 |
this.nameSpacePrefix = status.getNamespacePrefix(); |
|
162 |
this.nameSpaceLocation = status.getNamespaceLocation(); |
|
163 |
setQueryByAttribute(status.getFilterByAttribute()); |
|
164 |
clearSpatialFilters(); |
|
165 |
addSpatialFilter(status.getFilterByArea()); |
|
166 |
} |
|
242 | 167 |
|
243 |
/** |
|
244 |
* Parses a expresion like 'A op B' and returns the |
|
245 |
* expresion using the filter encoding language |
|
246 |
* @param expression |
|
247 |
* @return |
|
248 |
*/ |
|
249 |
private String getExpression(String expression){ |
|
250 |
String[] words = stringUtils.split(expression, " "); |
|
251 |
//Param |
|
252 |
String param = words[0]; |
|
253 |
if (param.charAt(0) == '"'){ |
|
254 |
param = param.substring(1,param.length()); |
|
255 |
} |
|
256 |
if (param.charAt(param.length()-1) == '"'){ |
|
257 |
param = param.substring(0,param.length()-1); |
|
258 |
} |
|
259 |
//Operator |
|
260 |
String operator = words[1]; |
|
261 |
//Value |
|
262 |
String value = words[2]; |
|
263 |
for (int i=3 ; i<words.length ; i++){ |
|
264 |
value = value + " " + words[i]; |
|
265 |
} |
|
266 |
if (value.charAt(0) == '\''){ |
|
267 |
value = value.substring(1,value.length()); |
|
268 |
} |
|
269 |
if (value.charAt(value.length()-1) == '\''){ |
|
270 |
value = value.substring(0,value.length()-1); |
|
271 |
} |
|
272 |
int operatorCode = getRelationalOperator(operator); |
|
273 |
operator = getRelationalOperator(operatorCode); |
|
274 |
return createExpression(operator,param,value); |
|
275 |
} |
|
168 |
/* |
|
169 |
* (non-Javadoc) |
|
170 |
* @see org.gvsig.remoteClient.filterEncoding.QueryLanguage#toString(org.gvsig.remoteClient.filterEncoding.BinaryTree) |
|
171 |
*/ |
|
172 |
public String toString(BinaryTree tree, String version) { |
|
173 |
//If is a filter by ids... |
|
174 |
StringBuffer idQuery = null; |
|
175 |
if (getIds() != null){ |
|
176 |
idQuery = new StringBuffer(); |
|
177 |
ArrayList ids = getIds(); |
|
178 |
for (int i=0 ; i<ids.size() ; i++){ |
|
179 |
if (ids.get(i) != null){ |
|
180 |
Hashtable attributes = new Hashtable(); |
|
181 |
attributes.put("fid","\"" + ids.get(i).toString() + "\""); |
|
182 |
idQuery.append(setTag("FeatureId", attributes, null)); |
|
183 |
} |
|
184 |
} |
|
185 |
return enclosesWithFilterTag(idQuery.toString()); |
|
186 |
} |
|
187 |
//If is a filter by attributes... |
|
188 |
String filterQuery = null; |
|
189 |
if ((tree.getRoot() == null) && (getSpatialFiltersCount() == 0)){ |
|
190 |
return null; |
|
191 |
} |
|
192 |
if (tree.getRoot() != null){ |
|
193 |
currentQuery = new StringBuffer(); |
|
194 |
filterQuery = getFilterNode(tree.getRoot()); |
|
195 |
if (getSpatialFiltersCount() == 0){ |
|
196 |
return enclosesWithFilterTag(filterQuery); |
|
197 |
} |
|
198 |
} |
|
199 |
//If is a filter by area |
|
200 |
String bboxQuery = null; |
|
201 |
if (getSpatialFiltersCount() > 0){ |
|
202 |
for (int i=0 ; i<getSpatialFiltersCount() ; i++){ |
|
203 |
WFSSpatialFilterOperation spatialFilter = getSpatialFilterAt(i); |
|
204 |
SpatialFEQuery feQuery = null; |
|
205 |
if (spatialFilter instanceof WFSGeometryFilterOperation){ |
|
206 |
feQuery = new GeometryFEQuery((WFSGeometryFilterOperation)spatialFilter); |
|
207 |
}else if (spatialFilter instanceof WFSEnvelopeFilterOperation){ |
|
208 |
//TODO add this for a manager |
|
209 |
if (version.equals("1.0.0")){ |
|
210 |
feQuery = new EnvelopeFEQuery1_0_0((WFSEnvelopeFilterOperation)spatialFilter); |
|
211 |
}else{ |
|
212 |
feQuery = new EnvelopeFEQuery1_1_0((WFSEnvelopeFilterOperation)spatialFilter); |
|
213 |
} |
|
214 |
} |
|
215 |
//If there is a spatial query |
|
216 |
if (feQuery != null){ |
|
217 |
bboxQuery = feQuery.getFilterEncoding(); |
|
218 |
if (tree.getRoot() == null){ |
|
219 |
return bboxQuery; |
|
220 |
} |
|
221 |
} |
|
222 |
} |
|
223 |
} |
|
224 |
return enclosesWithFilterTag(filterQuery + bboxQuery); |
|
225 |
} |
|
276 | 226 |
|
277 |
/** |
|
278 |
* It writes a "PropertyIsXXX" part of a filtyer encoding query |
|
279 |
* |
|
280 |
* |
|
281 |
* @return The part of the query |
|
282 |
* @param property Possible Values: PropertIsLike, PropertyIsLess, PropertyIsGreater,... See |
|
283 |
* the Filter Encoding documentation |
|
284 |
* @param parameter Parameter name |
|
285 |
* @param value Parameter value |
|
286 |
* @param type Values: "P" (to comparate two propertyes) or "L" (to comparate one property |
|
287 |
* and one literal value) |
|
288 |
*/ |
|
289 |
private String createExpression(String property, String parameter, String value) { |
|
290 |
String cadena = ""; |
|
291 |
cadena = "<" + namepacePrefix + property; |
|
292 |
if (property.equals("PropertyIsLike")) { |
|
293 |
if (wildCardChar != null) { |
|
294 |
cadena = cadena + " wildCard=\"" + this.wildCardChar + "\""; |
|
295 |
} |
|
296 |
if (singleChar != null) { |
|
297 |
cadena = cadena + " singleChar=\"" + this.singleChar + "\""; |
|
298 |
} |
|
299 |
if (escapeChar != null) { |
|
300 |
cadena = cadena + " escape=\"" + this.escapeChar + "\""; |
|
301 |
} |
|
302 |
} |
|
303 |
cadena = cadena + ">" + enterLabel(parameter, "PropertyName"); |
|
304 |
cadena = cadena + enterLabel(value, "Literal"); |
|
305 |
return cadena + "</" + namepacePrefix + property + ">"; |
|
306 |
} |
|
227 |
/** |
|
228 |
* Gets the filter code from a node |
|
229 |
* @param node |
|
230 |
*/ |
|
231 |
private String getFilterNode(Node node){ |
|
232 |
if (node.isField()){ |
|
233 |
return getExpression(node.getValue()); |
|
234 |
}else{ |
|
235 |
String left = ""; |
|
236 |
String rigth = ""; |
|
237 |
if (node.getLeftNode() != null){ |
|
238 |
left = getFilterNode(node.getLeftNode()); |
|
239 |
} |
|
240 |
if (node.getRigthNode() != null){ |
|
241 |
rigth = getFilterNode(node.getRigthNode()); |
|
242 |
} |
|
243 |
int operationCode = getLogicalOperator(node.getValue()); |
|
244 |
String operation = getLogicalOperator(operationCode); |
|
245 |
return enterLabel(left+rigth, operation); |
|
246 |
} |
|
247 |
} |
|
307 | 248 |
|
308 |
/** |
|
309 |
* Envuelve a una pregunta con una etiqueta |
|
310 |
* |
|
311 |
* |
|
312 |
* @return String : parte de la query en el lenguaje soportado |
|
313 |
* @param pregunta Pregunta a envolver |
|
314 |
* @param etiqueta Nombre de la etiqueta |
|
315 |
*/ |
|
316 |
private String enterLabel(String value, String tagName) { |
|
317 |
if (tagName.equals("Filter") && (!(filterAttributes.isEmpty()))) { |
|
318 |
return setTag(tagName,filterAttributes,value); |
|
319 |
} else { |
|
320 |
return setTag(tagName,null,value); |
|
321 |
} |
|
322 |
} |
|
249 |
/** |
|
250 |
* Parses a expresion like 'A op B' and returns the |
|
251 |
* expresion using the filter encoding language |
|
252 |
* @param expression |
|
253 |
* @return |
|
254 |
*/ |
|
255 |
private String getExpression(String expression){ |
|
256 |
String[] words = stringUtils.split(expression, " "); |
|
257 |
//Param |
|
258 |
String param = words[0]; |
|
259 |
if (param.charAt(0) == '"'){ |
|
260 |
param = param.substring(1,param.length()); |
|
261 |
} |
|
262 |
if (param.charAt(param.length()-1) == '"'){ |
|
263 |
param = param.substring(0,param.length()-1); |
|
264 |
} |
|
265 |
//Operator |
|
266 |
String operator = words[1]; |
|
267 |
//Value |
|
268 |
String value = words[2]; |
|
269 |
for (int i=3 ; i<words.length ; i++){ |
|
270 |
value = value + " " + words[i]; |
|
271 |
} |
|
272 |
if (value.charAt(0) == '\''){ |
|
273 |
value = value.substring(1,value.length()); |
|
274 |
} |
|
275 |
if (value.charAt(value.length()-1) == '\''){ |
|
276 |
value = value.substring(0,value.length()-1); |
|
277 |
} |
|
278 |
int operatorCode = getRelationalOperator(operator); |
|
279 |
operator = getRelationalOperator(operatorCode); |
|
280 |
return createExpression(operator,param,value); |
|
281 |
} |
|
323 | 282 |
|
324 |
/** |
|
325 |
* Envolves a value with an XML tag |
|
326 |
* |
|
327 |
* @return String |
|
328 |
* XML tag with its value |
|
329 |
* @param tagName |
|
330 |
* XML tag name |
|
331 |
* @param attributes |
|
332 |
* XML tag attributes |
|
333 |
* @param value |
|
334 |
* Tag value |
|
335 |
*/ |
|
336 |
public String setTag(String tagName, Hashtable attributes, String value) { |
|
337 |
StringBuffer tag = new StringBuffer(); |
|
283 |
/** |
|
284 |
* It writes a "PropertyIsXXX" part of a filtyer encoding query |
|
285 |
* |
|
286 |
* |
|
287 |
* @return The part of the query |
|
288 |
* @param property Possible Values: PropertIsLike, PropertyIsLess, PropertyIsGreater,... See |
|
289 |
* the Filter Encoding documentation |
|
290 |
* @param parameter Parameter name |
|
291 |
* @param value Parameter value |
|
292 |
* @param type Values: "P" (to comparate two propertyes) or "L" (to comparate one property |
|
293 |
* and one literal value) |
|
294 |
*/ |
|
295 |
private String createExpression(String property, String parameter, String value) { |
|
296 |
String cadena = ""; |
|
297 |
cadena = "<" + WFSTTags.OGC_NAMESPACE_PREFIX + ":" + property; |
|
298 |
if (property.equals("PropertyIsLike")) { |
|
299 |
if (wildCardChar != null) { |
|
300 |
cadena = cadena + " wildCard=\"" + this.wildCardChar + "\""; |
|
301 |
} |
|
302 |
if (singleChar != null) { |
|
303 |
cadena = cadena + " singleChar=\"" + this.singleChar + "\""; |
|
304 |
} |
|
305 |
if (escapeChar != null) { |
|
306 |
cadena = cadena + " escape=\"" + this.escapeChar + "\""; |
|
307 |
} |
|
308 |
} |
|
309 |
cadena = cadena + ">" + enterLabel(nameSpacePrefix + ":" + parameter, "PropertyName"); |
|
310 |
cadena = cadena + enterLabel(value, "Literal"); |
|
311 |
return cadena + "</" + WFSTTags.OGC_NAMESPACE_PREFIX + ":" + property + ">"; |
|
312 |
} |
|
338 | 313 |
|
339 |
tag.append("<");
|
|
340 |
tag.append(namepacePrefix);
|
|
341 |
tag.append(tagName);
|
|
342 |
if (attributes != null){
|
|
343 |
Set keys = attributes.keySet();
|
|
344 |
if (attributes.size() > 0){
|
|
345 |
Iterator it = keys.iterator();
|
|
346 |
while (it.hasNext()){
|
|
347 |
String key = (String)it.next();
|
|
348 |
if (hasBlankSpaces){
|
|
349 |
tag.append(" ");
|
|
350 |
}else{
|
|
351 |
tag.append(defaultBlankSpace);
|
|
352 |
}
|
|
353 |
tag.append(key + "=" + (String)attributes.get(key));
|
|
314 |
/**
|
|
315 |
* Envuelve a una pregunta con una etiqueta
|
|
316 |
*
|
|
317 |
*
|
|
318 |
* @return String : parte de la query en el lenguaje soportado
|
|
319 |
* @param pregunta Pregunta a envolver
|
|
320 |
* @param etiqueta Nombre de la etiqueta
|
|
321 |
*/
|
|
322 |
private String enterLabel(String value, String tagName) {
|
|
323 |
if (tagName.equals("Filter") && (!(filterAttributes.isEmpty()))) {
|
|
324 |
return setTag(tagName,filterAttributes,value);
|
|
325 |
} else {
|
|
326 |
return setTag(tagName,null,value);
|
|
327 |
}
|
|
328 |
}
|
|
354 | 329 |
|
355 |
}
|
|
356 |
}
|
|
357 |
}
|
|
358 |
if (value == null){
|
|
359 |
tag.append("/>");
|
|
360 |
}else{
|
|
361 |
tag.append(">" + value);
|
|
362 |
tag.append("</");
|
|
363 |
tag.append(namepacePrefix);
|
|
364 |
tag.append(tagName);
|
|
365 |
tag.append(">");
|
|
366 |
}
|
|
367 |
return tag.toString();
|
|
368 |
}
|
|
330 |
/**
|
|
331 |
* Envolves a value with an XML tag
|
|
332 |
*
|
|
333 |
* @return String
|
|
334 |
* XML tag with its value
|
|
335 |
* @param tagName
|
|
336 |
* XML tag name
|
|
337 |
* @param attributes
|
|
338 |
* XML tag attributes
|
|
339 |
* @param value
|
|
340 |
* Tag value
|
|
341 |
*/
|
|
342 |
public String setTag(String tagName, Hashtable attributes, String value) {
|
|
343 |
StringBuffer tag = new StringBuffer();
|
|
369 | 344 |
|
345 |
tag.append("<"); |
|
346 |
tag.append(WFSTTags.OGC_NAMESPACE_PREFIX + ":"); |
|
347 |
tag.append(tagName); |
|
348 |
if (attributes != null){ |
|
349 |
Set keys = attributes.keySet(); |
|
350 |
if (attributes.size() > 0){ |
|
351 |
Iterator it = keys.iterator(); |
|
352 |
while (it.hasNext()){ |
|
353 |
String key = (String)it.next(); |
|
354 |
if (hasBlankSpaces){ |
|
355 |
tag.append(" "); |
|
356 |
}else{ |
|
357 |
tag.append(defaultBlankSpace); |
|
358 |
} |
|
359 |
tag.append(key + "=" + (String)attributes.get(key)); |
|
370 | 360 |
|
371 |
/** |
|
372 |
* Encloses a query with the filter tag |
|
373 |
* @param query |
|
374 |
* @return |
|
375 |
*/ |
|
376 |
private String enclosesWithFilterTag(String query){ |
|
377 |
StringBuffer filter = new StringBuffer(); |
|
378 |
filter.append("<" + namepacePrefix + "Filter"); |
|
379 |
if (!isQualified){ |
|
380 |
filter.append("%20"); |
|
381 |
filter.append("xmlns:ogc=\"http://www.opengis.net/ogc\"%20"); |
|
382 |
filter.append("xmlns:gml=\"http://www.opengis.net/gml\"%20"); |
|
383 |
filter.append("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"%20"); |
|
384 |
filter.append("xsi:schemaLocation=\"http://www.opengis.net/ogc%20../filter/1.0.0/filter.xsd%20http://www.opengis.net/gml%20../gml/2.1.2/geometry.xsd\""); |
|
385 |
} |
|
386 |
filter.append(">"); |
|
387 |
filter.append(query); |
|
388 |
filter.append("</" + namepacePrefix + "Filter>"); |
|
389 |
return filter.toString(); |
|
390 |
} |
|
361 |
} |
|
362 |
} |
|
363 |
} |
|
364 |
if (value == null){ |
|
365 |
tag.append("/>"); |
|
366 |
}else{ |
|
367 |
tag.append(">" + value); |
|
368 |
tag.append("</"); |
|
369 |
tag.append(WFSTTags.OGC_NAMESPACE_PREFIX + ":"); |
|
370 |
tag.append(tagName); |
|
371 |
tag.append(">"); |
|
372 |
} |
|
373 |
return tag.toString(); |
|
374 |
} |
|
391 | 375 |
|
392 |
/* |
|
393 |
* (non-Javadoc) |
|
394 |
* @see org.gvsig.remoteClient.filterEncoding.AQueryLanguage#getLogicOperator(int) |
|
395 |
*/ |
|
396 |
public String getLogicalOperator(int operator) { |
|
397 |
switch (operator){ |
|
398 |
case LOGICAL_OPERATOR_AND: |
|
399 |
return "And"; |
|
400 |
case LOGICAL_OPERATOR_OR: |
|
401 |
return "Or"; |
|
402 |
case LOGICAL_OPERATOR_NOT: |
|
403 |
return "Not"; |
|
404 |
default: |
|
405 |
return "And"; |
|
406 |
} |
|
407 |
} |
|
408 | 376 |
|
409 |
/* |
|
410 |
* (non-Javadoc) |
|
411 |
* @see org.gvsig.remoteClient.filterEncoding.AQueryLanguage#getRelationalOperator(int) |
|
412 |
*/ |
|
413 |
public String getRelationalOperator(int operator) { |
|
414 |
switch (operator){ |
|
415 |
case RELATIONAL_OPERATOR_IS_EQUALS_TO: |
|
416 |
return "PropertyIsEqualTo"; |
|
417 |
case RELATIONAL_OPERATOR_IS_NOT_EQUALS_TO: |
|
418 |
return "PropertyIsNotEqualTo"; |
|
419 |
case RELATIONAL_OPERATOR_IS_LESS_THAN: |
|
420 |
return "PropertyIsLessThan"; |
|
421 |
case RELATIONAL_OPERATOR_IS_GREATER_THAN: |
|
422 |
return "PropertyIsGreaterThan"; |
|
423 |
case RELATIONAL_OPERATOR_IS_LESS_THAN_OR_EQUAL_TO: |
|
424 |
return "PropertyIsLessThanOrEqualTo"; |
|
425 |
case RELATIONAL_OPERATOR_IS_GREATER_THAN_OR_EQUAL_TO: |
|
426 |
return "PropertyIsGreaterThanOrEqualTo"; |
|
427 |
case RELATIONAL_OPERATOR_IS_LIKE: |
|
428 |
return "PropertyIsLike"; |
|
429 |
case RELATIONAL_OPERATOR_IS_NULL: |
|
430 |
return "PropertyIsNull"; |
|
431 |
case RELATIONAL_OPERATOR_IS_BETWEEN: |
|
432 |
return "PropertyIsBetween"; |
|
433 |
default: |
|
434 |
return "PropertyIsLike"; |
|
435 |
} |
|
436 |
} |
|
377 |
/** |
|
378 |
* Encloses a query with the filter tag |
|
379 |
* @param query |
|
380 |
* @return |
|
381 |
*/ |
|
382 |
private String enclosesWithFilterTag(String query){ |
|
383 |
StringBuffer filter = new StringBuffer(); |
|
384 |
filter.append("<ogc:Filter"); |
|
385 |
if (!isQualified){ |
|
386 |
filter.append(" "); |
|
387 |
addNamespace(filter, WFSTTags.OGC_NAMESPACE_PREFIX, WFSTTags.OGC_NAMESPACE); |
|
388 |
addNamespace(filter, WFSTTags.GML_NAMESPACE_PREFIX, WFSTTags.GML_NAMESPACE); |
|
389 |
if (nameSpacePrefix != null){ |
|
390 |
addNamespace(filter, nameSpacePrefix, nameSpaceLocation); |
|
391 |
} |
|
392 |
filter.append("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" "); |
|
393 |
filter.append("xsi:schemaLocation=\"http://www.opengis.net/ogc ../filter/1.0.0/filter.xsd http://www.opengis.net/gml ../gml/2.1.2/geometry.xsd\""); |
|
394 |
} |
|
395 |
filter.append(">"); |
|
396 |
filter.append(query); |
|
397 |
filter.append("</ogc:Filter>"); |
|
398 |
return filter.toString(); |
|
399 |
} |
|
400 |
|
|
401 |
private void addNamespace(StringBuffer buffer, String nameSpacePrefix, String nameSpaceLocation){ |
|
402 |
buffer.append(WFSTTags.XMLNS + ":" + nameSpacePrefix + "=\"" + nameSpaceLocation + "\" "); |
|
403 |
} |
|
437 | 404 |
|
438 |
/* |
|
439 |
* (non-Javadoc) |
|
440 |
* @see org.gvsig.remoteClient.filterEncoding.AQueryLanguage#getGeometricOperator(int) |
|
441 |
*/ |
|
442 |
public String getGeometricOperator(int operator) { |
|
443 |
switch (operator){ |
|
444 |
case GEOMETRIC_OPERATOR_EQUALS: |
|
445 |
return "Equals"; |
|
446 |
case GEOMETRIC_OPERATOR_DISJOINT: |
|
447 |
return "Disjoint"; |
|
448 |
case GEOMETRIC_OPERATOR_TOUCHES: |
|
449 |
return "Touches"; |
|
450 |
case GEOMETRIC_OPERATOR_WITHIN: |
|
451 |
return "Within"; |
|
452 |
case GEOMETRIC_OPERATOR_OVERLAPS: |
|
453 |
return "Overlaps"; |
|
454 |
case GEOMETRIC_OPERATOR_CROSSES: |
|
455 |
return "Crosses"; |
|
456 |
case GEOMETRIC_OPERATOR_INTERSECT: |
|
457 |
return "Intersect"; |
|
458 |
case GEOMETRIC_OPERATOR_CONTAINS: |
|
459 |
return "Contains"; |
|
460 |
case GEOMETRIC_OPERATOR_DWITHIN: |
|
461 |
return "Dwithin"; |
|
462 |
case GEOMETRIC_OPERATOR_BEYOND: |
|
463 |
return "Beyond"; |
|
464 |
case GEOMETRIC_OPERATOR_BBOX: |
|
465 |
return "BBOX"; |
|
466 |
default: |
|
467 |
return "Equals"; |
|
468 |
} |
|
405 |
/* |
|
406 |
* (non-Javadoc) |
|
407 |
* @see org.gvsig.remoteClient.filterEncoding.AQueryLanguage#getLogicOperator(int) |
|
408 |
*/ |
|
409 |
public String getLogicalOperator(int operator) { |
|
410 |
switch (operator){ |
|
411 |
case LOGICAL_OPERATOR_AND: |
|
412 |
return "And"; |
|
413 |
case LOGICAL_OPERATOR_OR: |
|
414 |
return "Or"; |
|
415 |
case LOGICAL_OPERATOR_NOT: |
|
416 |
return "Not"; |
|
417 |
default: |
|
418 |
return "And"; |
|
419 |
} |
|
420 |
} |
|
469 | 421 |
|
470 |
} |
|
422 |
/* |
|
423 |
* (non-Javadoc) |
|
424 |
* @see org.gvsig.remoteClient.filterEncoding.AQueryLanguage#getRelationalOperator(int) |
|
425 |
*/ |
|
426 |
public String getRelationalOperator(int operator) { |
|
427 |
switch (operator){ |
|
428 |
case RELATIONAL_OPERATOR_IS_EQUALS_TO: |
|
429 |
return "PropertyIsEqualTo"; |
|
430 |
case RELATIONAL_OPERATOR_IS_NOT_EQUALS_TO: |
|
431 |
return "PropertyIsNotEqualTo"; |
|
432 |
case RELATIONAL_OPERATOR_IS_LESS_THAN: |
|
433 |
return "PropertyIsLessThan"; |
|
434 |
case RELATIONAL_OPERATOR_IS_GREATER_THAN: |
|
435 |
return "PropertyIsGreaterThan"; |
|
436 |
case RELATIONAL_OPERATOR_IS_LESS_THAN_OR_EQUAL_TO: |
|
437 |
return "PropertyIsLessThanOrEqualTo"; |
|
438 |
case RELATIONAL_OPERATOR_IS_GREATER_THAN_OR_EQUAL_TO: |
|
439 |
return "PropertyIsGreaterThanOrEqualTo"; |
|
440 |
case RELATIONAL_OPERATOR_IS_LIKE: |
|
441 |
return "PropertyIsLike"; |
|
442 |
case RELATIONAL_OPERATOR_IS_NULL: |
|
443 |
return "PropertyIsNull"; |
|
444 |
case RELATIONAL_OPERATOR_IS_BETWEEN: |
|
445 |
return "PropertyIsBetween"; |
|
446 |
default: |
|
447 |
return "PropertyIsLike"; |
|
448 |
} |
|
449 |
} |
|
471 | 450 |
|
472 |
public String getSeparator(int separator) { |
|
473 |
return null; |
|
474 |
} |
|
451 |
/* |
|
452 |
* (non-Javadoc) |
|
453 |
* @see org.gvsig.remoteClient.filterEncoding.AQueryLanguage#getGeometricOperator(int) |
|
454 |
*/ |
|
455 |
public String getGeometricOperator(int operator) { |
|
456 |
switch (operator){ |
|
457 |
case GEOMETRIC_OPERATOR_EQUALS: |
|
458 |
return "Equals"; |
|
459 |
case GEOMETRIC_OPERATOR_DISJOINT: |
|
460 |
return "Disjoint"; |
|
461 |
case GEOMETRIC_OPERATOR_TOUCHES: |
|
462 |
return "Touches"; |
|
463 |
case GEOMETRIC_OPERATOR_WITHIN: |
|
464 |
return "Within"; |
|
465 |
case GEOMETRIC_OPERATOR_OVERLAPS: |
|
466 |
return "Overlaps"; |
|
467 |
case GEOMETRIC_OPERATOR_CROSSES: |
|
468 |
return "Crosses"; |
|
469 |
case GEOMETRIC_OPERATOR_INTERSECT: |
|
470 |
return "Intersect"; |
|
471 |
case GEOMETRIC_OPERATOR_CONTAINS: |
|
472 |
return "Contains"; |
|
473 |
case GEOMETRIC_OPERATOR_DWITHIN: |
|
474 |
return "Dwithin"; |
|
475 |
case GEOMETRIC_OPERATOR_BEYOND: |
|
476 |
return "Beyond"; |
|
477 |
case GEOMETRIC_OPERATOR_BBOX: |
|
478 |
return "BBOX"; |
|
479 |
default: |
|
480 |
return "Equals"; |
|
481 |
} |
|
475 | 482 |
|
476 |
/** |
|
477 |
* @param isQualified the isQualified to set |
|
478 |
*/ |
|
479 |
public void setQualified(boolean isQualified) { |
|
480 |
this.isQualified = isQualified; |
|
481 |
if (isQualified){ |
|
482 |
namepacePrefix = DEFAULT_NAMESPACE_PREFIX + ":"; |
|
483 |
}else{ |
|
484 |
namepacePrefix = ""; |
|
485 |
} |
|
486 |
} |
|
483 |
} |
|
487 | 484 |
|
485 |
public String getSeparator(int separator) { |
|
486 |
return null; |
|
487 |
} |
|
488 | 488 |
|
489 |
/** |
|
490 |
* @param namepacePrefix the namepacePrefix to set |
|
491 |
*/ |
|
492 |
public void setNamepacePrefix(String namepacePrefix) { |
|
493 |
if ((namepacePrefix == null) || (namepacePrefix.equals(""))){ |
|
494 |
this.namepacePrefix = ""; |
|
495 |
}else{ |
|
496 |
this.namepacePrefix = namepacePrefix + ":"; |
|
497 |
} |
|
498 |
} |
|
489 |
/** |
|
490 |
* @param isQualified the isQualified to set |
|
491 |
*/ |
|
492 |
public void setQualified(boolean isQualified) { |
|
493 |
this.isQualified = isQualified; |
|
494 |
if (isQualified){ |
|
495 |
nameSpacePrefix = DEFAULT_NAMESPACE_PREFIX + ":"; |
|
496 |
}else{ |
|
497 |
nameSpacePrefix = ""; |
|
498 |
} |
|
499 |
} |
|
499 | 500 |
|
500 | 501 |
|
501 |
/** |
|
502 |
* @param hasBlankSpaces the hasBlankSpaces to set |
|
503 |
*/ |
|
504 |
public void setHasBlankSpaces(boolean hasBlankSpaces) { |
|
505 |
this.hasBlankSpaces = hasBlankSpaces; |
|
506 |
} |
|
502 |
/** |
|
503 |
* @param namepacePrefix the namepacePrefix to set |
|
504 |
*/ |
|
505 |
public void setNamepacePrefix(String namepacePrefix) { |
|
506 |
if ((namepacePrefix == null) || (namepacePrefix.equals(""))){ |
|
507 |
this.nameSpacePrefix = ""; |
|
508 |
}else{ |
|
509 |
this.nameSpacePrefix = namepacePrefix + ":"; |
|
510 |
} |
|
511 |
} |
|
512 |
|
|
513 |
|
|
514 |
/** |
|
515 |
* @param hasBlankSpaces the hasBlankSpaces to set |
|
516 |
*/ |
|
517 |
public void setHasBlankSpaces(boolean hasBlankSpaces) { |
|
518 |
this.hasBlankSpaces = hasBlankSpaces; |
|
519 |
} |
|
507 | 520 |
} |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wfs/filters/AbstractFilter.java | ||
---|---|---|
174 | 174 |
} |
175 | 175 |
|
176 | 176 |
public void addSpatialFilter(WFSSpatialFilterOperation spatialOperation){ |
177 |
spatialFilterOperations.add(spatialOperation); |
|
177 |
if (spatialOperation != null){ |
|
178 |
spatialFilterOperations.add(spatialOperation); |
|
179 |
} |
|
178 | 180 |
} |
179 | 181 |
|
180 | 182 |
public void addSpatialFilter(Geometry geometry,String attributeName, String nameSpacePrefix, String nameSpaceLocation, String srs, int operation) { |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wfs/wfs_1_0_0/request/WFSTransactionRequest1_0_0.java | ||
---|---|---|
77 | 77 |
IWFSTOperation firstOperation = transaction.getDeleteOperationAt(0); |
78 | 78 |
addOperationHeader(firstOperation, request); |
79 | 79 |
|
80 |
FilterEncoding filterEncoding = new FilterEncoding(); |
|
80 |
FilterEncoding filterEncoding = new FilterEncoding(status);
|
|
81 | 81 |
filterEncoding.setQualified(true); |
82 | 82 |
for (int i=0 ; i<transaction.getDeleteOperationSize() ; i++){ |
83 | 83 |
filterEncoding.addFeatureById(transaction.getDeleteOperationAt(i).getId()); |
... | ... | |
132 | 132 |
request.append(createXMLEndtTag(UPDATE_PROPERTY_TAG)); |
133 | 133 |
} |
134 | 134 |
//Add the filter encoding |
135 |
FilterEncoding filterEncoding = new FilterEncoding(); |
|
135 |
FilterEncoding filterEncoding = new FilterEncoding(status);
|
|
136 | 136 |
filterEncoding.setQualified(true); |
137 | 137 |
filterEncoding.addFeatureById(updateOperation.getId()); |
138 | 138 |
request.append(filterEncoding.toString(protocolHandler.getVersion())); |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wfs/wfs_1_0_0/request/WFSGetFeatureRequest1_0_0.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import org.gvsig.remoteclient.wfs.WFSProtocolHandler; |
4 | 4 |
import org.gvsig.remoteclient.wfs.WFSStatus; |
5 |
import org.gvsig.remoteclient.wfs.filters.filterencoding.FilterEncoding; |
|
5 | 6 |
import org.gvsig.remoteclient.wfs.request.WFSGetFeatureRequest; |
6 | 7 |
|
7 | 8 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
... | ... | |
72 | 73 |
req.append("TYPENAME=").append(status.getFeatureFullName()).append("&"); |
73 | 74 |
String[] fields = status.getFields(); |
74 | 75 |
addPropertyName(req); |
75 |
// if ((status.getFilterByAttribute() != null) || (status.getFilterByArea() != null)){
|
|
76 |
// FilterEncoding filterEncoding = new FilterEncoding(status);
|
|
77 |
// req.append("FILTER=" + filterEncoding.toString() + "&");
|
|
78 |
// }
|
|
76 |
if ((status.getFilterByAttribute() != null) || (status.getFilterByArea() != null)){ |
|
77 |
FilterEncoding filterEncoding = new FilterEncoding(status); |
|
78 |
req.append("FILTER=" + filterEncoding.toString(protocolHandler.getVersion()) + "&");
|
|
79 |
} |
|
79 | 80 |
req.append("VERSION=").append(protocolHandler.getVersion()).append("&EXCEPTIONS=XML"); |
80 | 81 |
req.append("&MAXFEATURES=").append(status.getMaxFeatures()); |
81 | 82 |
return req.toString(); |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wfs/WFSStatus.java | ||
---|---|---|
388 | 388 |
* @return the filterQueryLocked |
389 | 389 |
*/ |
390 | 390 |
public String getFilterQueryLocked() { |
391 |
FilterEncoding filter = new FilterEncoding(); |
|
391 |
FilterEncoding filter = new FilterEncoding(this);
|
|
392 | 392 |
filter.setQualified(true); |
393 | 393 |
filter.setNamepacePrefix(null); |
394 | 394 |
filter.setHasBlankSpaces(false); |
... | ... | |
399 | 399 |
* @return the filterQueryLocked |
400 | 400 |
*/ |
401 | 401 |
public String getFilterQueryLockedPost() { |
402 |
FilterEncoding filter = new FilterEncoding(); |
|
402 |
FilterEncoding filter = new FilterEncoding(this);
|
|
403 | 403 |
filter.setQualified(true); |
404 | 404 |
return getFilterQueryLocked(filter); |
405 | 405 |
} |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wfs/request/WFSGetFeatureRequest.java | ||
---|---|---|
101 | 101 |
request.append(WFSTTags.WFS_QUERY); |
102 | 102 |
request.append(" typeName=\"" + status.getFeatureFullName() + "\""); |
103 | 103 |
request.append(">"); |
104 |
if ((status.getFilterByAttribute() != null) || (status.getFilterByArea() != null)){ |
|
105 |
request.append("<" + WFSTTags.OGC_NAMESPACE_PREFIX + ":" + WFSTTags.WFS_FILTER + " "); |
|
106 |
request.append(WFSTTags.XMLNS + ":" + WFSTTags.OGC_NAMESPACE_PREFIX); |
|
107 |
request.append("=\"" + WFSTTags.OGC_NAMESPACE + "\" "); |
|
108 |
request.append(WFSTTags.XMLNS + ":" + WFSTTags.GML_NAMESPACE_PREFIX); |
|
109 |
request.append("=\"" + WFSTTags.GML_NAMESPACE + "\" "); |
|
110 |
request.append(">"); |
|
104 |
if ((status.getFilterByAttribute() != null) || (status.getFilterByArea() != null)){ |
|
111 | 105 |
FilterEncoding filterEncoding = new FilterEncoding(status); |
112 |
request.append(filterEncoding.toString(protocolHandler.getVersion())); |
|
113 |
request.append("</" + WFSTTags.OGC_NAMESPACE_PREFIX + ":" + WFSTTags.WFS_FILTER + ">"); |
|
106 |
request.append(filterEncoding.toString(protocolHandler.getVersion())); |
|
114 | 107 |
} |
115 | 108 |
request.append("</" + WFSTTags.WFS_NAMESPACE_PREFIX + ":"); |
116 | 109 |
request.append(WFSTTags.WFS_QUERY); |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wfs/WFSFeature.java | ||
---|---|---|
172 | 172 |
} |
173 | 173 |
|
174 | 174 |
public void addSRS(String key){ |
175 |
if (!this.srs.contains(key)){ |
|
176 |
srs.add(key); |
|
175 |
String epsgCode = getEPSGCode(key); |
|
176 |
if (!this.srs.contains(epsgCode)){ |
|
177 |
srs.add(epsgCode); |
|
177 | 178 |
} |
178 | 179 |
if (defaultSRS == null){ |
179 |
defaultSRS = key;
|
|
180 |
defaultSRS = epsgCode;
|
|
180 | 181 |
} |
181 | 182 |
} |
182 | 183 |
|
... | ... | |
242 | 243 |
* @param defaultSRS the defaultSRS to set |
243 | 244 |
*/ |
244 | 245 |
public void setDefaultSRS(String defaultSRS) { |
245 |
this.defaultSRS = defaultSRS;
|
|
246 |
this.defaultSRS = getEPSGCode(defaultSRS);
|
|
246 | 247 |
addSRS(defaultSRS); |
247 | 248 |
} |
249 |
|
|
250 |
private String getEPSGCode(String srs){ |
|
251 |
if (srs == null){ |
|
252 |
return null; |
|
253 |
} |
|
254 |
if ((srs.startsWith("urn:x-ogc:def:crs:")) || srs.startsWith("urn:ogc:def:crs:")){ |
|
255 |
String newString = srs.substring(srs.lastIndexOf(":") + 1, srs.length()); |
|
256 |
if (srs.indexOf("EPSG") > 0){ |
|
257 |
if (newString.indexOf("EPSG") < 0){ |
|
258 |
newString = "EPSG:" + newString; |
|
259 |
} |
|
260 |
} |
|
261 |
return newString; |
|
262 |
} |
|
263 |
if (srs.toLowerCase().startsWith("crs:")){ |
|
264 |
return srs.substring(4, srs.length()); |
|
265 |
} |
|
266 |
return srs; |
|
267 |
} |
|
268 |
|
|
248 | 269 |
} |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wms/wms_1_3_0/request/WMSGetFeatureInfoRequest1_1_3.java | ||
---|---|---|
60 | 60 |
req.append(getPartialQuery(status)).append("&I="+ x + "&J=" + y); |
61 | 61 |
req.append("&FEATURE_COUNT=10000"); |
62 | 62 |
req.append("&EXCEPTIONS=" + getExceptionsFormat()); |
63 |
return stringUtils.replaceAll(req.toString(), " ", "%20");
|
|
63 |
return req.toString();
|
|
64 | 64 |
} |
65 | 65 |
|
66 | 66 |
/** |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wms/wms_1_1_0/request/WMSGetFeatureInfoRequest1_1_0.java | ||
---|---|---|
62 | 62 |
//we set it to avoid the bug in mapserver that takes this number like max number of total features. |
63 | 63 |
req.append("&FEATURE_COUNT=10000"); |
64 | 64 |
req.append("&EXCEPTIONS=" + getExceptionsFormat()); |
65 |
return stringUtils.replaceAll(req.toString(), " ", "%20");
|
|
65 |
return req.toString();
|
|
66 | 66 |
} |
67 | 67 |
|
68 | 68 |
/** |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wms/wms_1_1_0/request/WMSGetLegendGraphicRequest1_1_0.java | ||
---|---|---|
54 | 54 |
req.append(onlineResource); |
55 | 55 |
req.append("REQUEST=GetLegendGraphic&SERVICE=WMS&VERSION=").append(protocolHandler.getVersion()); |
56 | 56 |
req.append("&LAYER=" + layerName).append("&TRANSPARENT=TRUE").append("&FORMAT=image/png"); |
57 |
return stringUtils.replaceAll(req.toString(), " ", "%20");
|
|
57 |
return req.toString();
|
|
58 | 58 |
} |
59 | 59 |
|
60 | 60 |
} |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wms/wms_1_1_0/request/WMSGetMapRequest1_1_0.java | ||
---|---|---|
56 | 56 |
req.append("REQUEST=GetMap&SERVICE=WMS&VERSION=").append(protocolHandler.getVersion()).append("&"); |
57 | 57 |
req.append(getPartialQuery(status)); |
58 | 58 |
req.append("&EXCEPTIONS=" + getExceptionsFormat()); |
59 |
return stringUtils.replaceAll(req.toString(), " ", "%20");
|
|
59 |
return req.toString();
|
|
60 | 60 |
} |
61 | 61 |
|
62 | 62 |
/** |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/ogc/request/OGCRequest.java | ||
---|---|---|
34 | 34 |
import java.net.URL; |
35 | 35 |
import java.net.UnknownHostException; |
36 | 36 |
|
37 |
import org.gvsig.compat.CompatLocator; |
|
38 |
import org.gvsig.compat.lang.StringUtils; |
|
37 | 39 |
import org.gvsig.compat.net.ICancellable; |
38 | 40 |
import org.gvsig.remoteclient.RemoteClientStatus; |
39 | 41 |
import org.gvsig.remoteclient.ogc.OGCClientOperation; |
... | ... | |
48 | 50 |
protected static final String XMLTAG_STARTCHARACTER = "<"; |
49 | 51 |
protected static final String XMLTAG_FINISHCHARACTER = "</"; |
50 | 52 |
protected static final String XMLTAG_ENDCHARACTER = ">"; |
53 |
|
|
54 |
private static final StringUtils stringUtils = CompatLocator.getStringUtils(); |
|
51 | 55 |
|
52 | 56 |
public OGCRequest(RemoteClientStatus status, OGCProtocolHandler protocolHandler) { |
53 | 57 |
super(); |
... | ... | |
131 | 135 |
* @throws IOException |
132 | 136 |
*/ |
133 | 137 |
private File sendHttpGetRequest(String onlineResource, ICancellable cancel) throws ConnectException, UnknownHostException, IOException{ |
134 |
URL url = new URL(getHttpGetRequest(onlineResource));
|
|
138 |
URL url = new URL(stringUtils.replaceAll(getHttpGetRequest(onlineResource), " ", "%20"));
|
|
135 | 139 |
if (isDeleted()){ |
136 | 140 |
Utilities.removeURL(url); |
137 | 141 |
} |
branches/v2_0_0_prep/extensions/extWFS2/src/org/gvsig/wfs/gui/panels/WFSParamsPanel.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.awt.Container; |
4 | 4 |
|
5 |
import javax.swing.JOptionPane; |
|
6 | 5 |
import javax.swing.JTabbedPane; |
7 | 6 |
|
8 | 7 |
import org.cresques.cts.IProjection; |
8 |
import org.geotools.filter.AbstractFilter; |
|
9 | 9 |
|
10 | 10 |
import org.gvsig.andami.PluginServices; |
11 | 11 |
import org.gvsig.app.gui.ILayerPanel; |
... | ... | |
624 | 624 |
parameters.setPassword(getOptionsPanel().getPassword()); |
625 | 625 |
parameters.setMaxFeatures(getOptionsPanel().getBuffer()); |
626 | 626 |
parameters.setTimeOut(getOptionsPanel().getTimeout()); |
627 |
// parameters.setFilterByArea(getAreaPanel().getArea(),
|
|
628 |
// "the_geom",
|
|
629 |
// getOptionsPanel().getSRS(),
|
|
630 |
// AFilter.GEOMETRIC_OPERATOR_INTERSECT);
|
|
631 |
// parameters.setFilterByAttribute(getFilterPanel().getFilterExpressionFromInterface());
|
|
627 |
parameters.setFilterByAreaGeometry(getAreaPanel().getArea());
|
|
628 |
parameters.setFilterByAreaCrs(getOptionsPanel().getSRS());
|
|
629 |
parameters.setFilterByAreaOperation((int)AbstractFilter.GEOMETRY_INTERSECTS);
|
|
630 |
parameters.setFilterByAreaAttribute(selectedFeature.getGeometryField().getName());
|
|
631 |
parameters.setFilterEncodingByAttribute(getFilterPanel().getQuery());
|
|
632 | 632 |
} |
633 | 633 |
|
634 | 634 |
/** |
... | ... | |
679 | 679 |
private WFSSelectedFeature getSelectedFeature(){ |
680 | 680 |
WFSSelectedFeature selectedFeature = getFeaturesPanel().getSelectedFeature(); |
681 | 681 |
selectedFeature.setSelectedFields(getFieldsPanel().getSelectedFields()); |
682 |
|
|
683 |
// If the query is incorrect -> no query (no filter) |
|
684 |
String query = getFilterPanel().getQuery(); |
|
685 |
if (query == null) { |
|
686 |
selectedFeature.setFilter(""); |
|
687 |
|
|
688 |
// Removes filter expression from the JTextArea |
|
689 |
getFilterPanel().removeFilterExpression(); |
|
690 |
|
|
691 |
// Notify to user that no filter will be applied |
|
692 |
JOptionPane.showMessageDialog(null, PluginServices.getText(null, "no_filter_will_be_applied_in_the_load_of_the_layer"), PluginServices.getText(null, "warning"), JOptionPane.WARNING_MESSAGE); |
|
693 |
} |
|
694 |
else { |
|
695 |
selectedFeature.setFilter(query); |
|
696 |
} |
|
682 |
selectedFeature.setFilter(getFilterPanel().getQuery()); |
|
697 | 683 |
return selectedFeature; |
698 | 684 |
} |
699 | 685 |
|
branches/v2_0_0_prep/extensions/extWFS2/src/org/gvsig/wfs/gui/panels/WFSFilterPanel.java | ||
---|---|---|
3 | 3 |
import java.awt.Color; |
4 | 4 |
import java.awt.event.MouseAdapter; |
5 | 5 |
import java.awt.event.MouseEvent; |
6 |
import java.io.ByteArrayInputStream; |
|
7 |
import java.io.InputStream; |
|
6 | 8 |
import java.io.UnsupportedEncodingException; |
7 | 9 |
import java.net.URLEncoder; |
8 | 10 |
import java.text.DateFormat; |
... | ... | |
26 | 28 |
import javax.swing.tree.DefaultTreeModel; |
27 | 29 |
import javax.swing.tree.TreePath; |
28 | 30 |
|
31 |
import Zql.ZExp; |
|
32 |
import Zql.ZqlParser; |
|
33 |
|
|
29 | 34 |
import org.slf4j.Logger; |
30 | 35 |
import org.slf4j.LoggerFactory; |
31 | 36 |
|
... | ... | |
102 | 107 |
*/ |
103 | 108 |
public class WFSFilterPanel extends FilterQueryJPanel implements IWFSPanel { |
104 | 109 |
private static final long serialVersionUID = -6041218260822015810L; |
110 |
private static final Logger LOG = LoggerFactory.getLogger(WFSFilterPanel.class); |
|
105 | 111 |
|
106 | 112 |
private static Logger logger = LoggerFactory.getLogger(WFSFilterPanel.class); |
107 | 113 |
private ExpressionDataSource model = null; |
... | ... | |
129 | 135 |
// At beginning, the JList is disabled (and its set a particular color for user could knew it) |
130 | 136 |
super.getValuesJList().setEnabled(false); |
131 | 137 |
//getValuesJList().setBackground(new Color(220, 220, 220)); |
138 |
|
|
139 |
//The validation option is disabled by default |
|
140 |
this.getValidateFilterExpressionJCheckBox().setSelected(false); |
|
132 | 141 |
} |
133 | 142 |
|
134 | 143 |
/* |
... | ... | |
230 | 239 |
|
231 | 240 |
if (e.getClickCount() == 2){ |
232 | 241 |
String valor = valuesListModel.getElementAt(index).toString(); |
233 |
|
|
242 |
|
|
234 | 243 |
// If value is an string -> set it between apostrophes |
235 | 244 |
if (getNodeOfCurrentPath().getDataType().getType() == DataTypes.STRING) { |
236 | 245 |
putSymbol("'" + valor + "'"); |
... | ... | |
423 | 432 |
else { |
424 | 433 |
logger.debug("Codified WFS filter query: " + writtenQuery); |
425 | 434 |
|
435 |
if (writtenQuery.trim().length() == 0){ |
|
436 |
return null; |
|
437 |
} |
|
426 | 438 |
// Codify expression (only if the validation has been successful) |
427 | 439 |
return this.codifyExpression(writtenQuery); // Ignores the spaces at beginning and end of the chain of characters |
428 | 440 |
} |
... | ... | |
506 | 518 |
} |
507 | 519 |
} |
508 | 520 |
|
509 |
return result;
|
|
521 |
return formatResutl(result);
|
|
510 | 522 |
} |
523 |
|
|
524 |
private String formatResutl(String query) { |
|
525 |
if ((query == null) || (query.equals(""))){ |
|
526 |
return null; |
|
527 |
} |
|
528 |
InputStream is = new ByteArrayInputStream(query.getBytes()); |
|
529 |
ZqlParser parser = new ZqlParser(); |
|
530 |
parser.initParser(is); |
|
531 |
ZExp exp; |
|
532 |
try { |
|
533 |
exp = parser.readExpression(); |
|
534 |
return exp.toString(); |
|
535 |
} catch (Zql.ParseException e) { |
|
536 |
LOG.error("Formatting the filter request", e); |
|
537 |
JOptionPane.showMessageDialog(null, PluginServices.getText(null, "filter_with_an_incorrect_format"), PluginServices.getText(null, "error_validating_filter_query"), JOptionPane.ERROR_MESSAGE); |
|
538 |
} |
|
539 |
return query; |
|
540 |
} |
|
511 | 541 |
|
512 | 542 |
/** |
513 | 543 |
* Checks the filter expression if it's correct |
... | ... | |
957 | 987 |
fieldValueSet.add(obj); |
958 | 988 |
} |
959 | 989 |
} |
960 |
|
|
990 |
|
|
961 | 991 |
Iterator it = fieldValueSet.iterator(); |
962 | 992 |
while (it.hasNext()) { |
963 | 993 |
String text = it.next().toString(); |
... | ... | |
966 | 996 |
} |
967 | 997 |
|
968 | 998 |
this.getValuesJList().setEnabled(valuesListModel.getSize() > 0); |
969 |
|
|
970 | 999 |
|
1000 |
|
|
971 | 1001 |
// // Find the selected field and try to obtein values related |
972 | 1002 |
// for (int i = 0; i < model.getFieldCount(); i++) { |
973 | 1003 |
// String name = model.getFieldName(i); |
branches/v2_0_0_prep/extensions/extWFS2/src/org/gvsig/fmap/dal/store/wfs/WFSStoreParameters.java | ||
---|---|---|
188 | 188 |
.setDescription("Attribute that contains the geometry") |
189 | 189 |
.setMandatory(false); |
190 | 190 |
|
191 |
definition.addDynFieldObject(DYNFIELDNAME_FILTER_BY_AREA_CRS) |
|
192 |
.setType(DataTypes.CRS) |
|
191 |
definition.addDynFieldString(DYNFIELDNAME_FILTER_BY_AREA_CRS) |
|
193 | 192 |
.setDescription("CRS to do the query") |
194 | 193 |
.setMandatory(false); |
195 | 194 |
|
branches/v2_0_0_prep/extensions/extWFS2/src/org/gvsig/fmap/dal/store/wfs/WFSStoreProvider.java | ||
---|---|---|
173 | 173 |
this.hasFilterByArea = (wfsStatus.getFilterByArea() != null); |
174 | 174 |
|
175 | 175 |
//Select the filter by attribute |
176 |
wfsStatus.setFilterByAttribute(wfsStatus.getFilterByAttribute());
|
|
176 |
wfsStatus.setFilterByAttribute(wfsParameters.getFilterEncodingByAttribute());
|
|
177 | 177 |
|
178 | 178 |
wfsStatus.setTimeout(wfsParameters.getTimeOut()); |
179 | 179 |
wfsStatus.setMaxFeatures(wfsParameters.getMaxFeatures()); |
... | ... | |
208 | 208 |
throw new WFSException("It is not possible to parse the schema"); |
209 | 209 |
} |
210 | 210 |
|
211 |
projection = CRSFactory.getCRS(getEPSGCode(feature.getDefaultSRS()));
|
|
211 |
projection = CRSFactory.getCRS(feature.getDefaultSRS());
|
|
212 | 212 |
this.setDynValue("CRS", projection); |
213 | 213 |
|
214 | 214 |
EditableFeatureType featureType = getStoreServices().createFeatureType(); |
... | ... | |
227 | 227 |
attributeDescriptor = featureType.add(featureField.getName(), dataType); |
228 | 228 |
if (typeDefinition instanceof IXSGeometryTypeDefinition){ |
229 | 229 |
if (feature.getSrs().size() > 0){ |
230 |
attributeDescriptor.setSRS(CRSFactory.getCRS(getEPSGCode((String)feature.getSrs().get(0))));
|
|
230 |
attributeDescriptor.setSRS(CRSFactory.getCRS((String)feature.getSrs().get(0)));
|
|
231 | 231 |
} |
232 | 232 |
attributeDescriptor.setGeometryType(((IXSGeometryTypeDefinition)typeDefinition).getGeometryType()); |
233 | 233 |
attributeDescriptor.setGeometrySubType(SUBTYPES.GEOM2D); |
... | ... | |
256 | 256 |
BoundaryBox boundaryBox = feature.getBbox(srs); |
257 | 257 |
if (boundaryBox == null) |
258 | 258 |
{ |
259 |
boundaryBox = feature.getBbox(getEPSGCode(srs));
|
|
259 |
boundaryBox = feature.getBbox(srs);
|
|
260 | 260 |
} |
261 | 261 |
//The projection is found |
262 | 262 |
if (boundaryBox != null){ |
... | ... | |
268 | 268 |
if (boundaryBox != null){ |
269 | 269 |
Envelope envelope = geometryManager.createEnvelope(boundaryBox.getXmin(), |
270 | 270 |
boundaryBox.getYmin(), boundaryBox.getXmax(), boundaryBox.getYmax(), SUBTYPES.GEOM2D); |
271 |
IProjection sourceProjection = CRSFactory.getCRS(getEPSGCode("EPSG:4326"));
|
|
272 |
IProjection destinationProjection = CRSFactory.getCRS(getEPSGCode(srs));
|
|
271 |
IProjection sourceProjection = CRSFactory.getCRS("EPSG:4326");
|
|
272 |
IProjection destinationProjection = CRSFactory.getCRS(srs);
|
|
273 | 273 |
if (destinationProjection != null){ |
274 | 274 |
ICoordTrans coordTrans = sourceProjection.getCT(destinationProjection); |
275 | 275 |
return envelope.convert(coordTrans); |
... | ... | |
475 | 475 |
return sourceID.toString() + "_" + hash; |
476 | 476 |
} |
477 | 477 |
} |
478 |
|
|
479 |
private String getEPSGCode(String srs){ |
|
480 |
if (srs == null){ |
|
481 |
return null; |
|
482 |
} |
|
483 |
if (srs.startsWith("urn:x-ogc:def:crs:")){ |
|
484 |
String newString = srs.substring(srs.lastIndexOf(":") + 1, srs.length()); |
|
485 |
if (srs.indexOf("EPSG") > 0){ |
|
486 |
if (newString.indexOf("EPSG") < 0){ |
|
487 |
newString = "EPSG:" + newString; |
|
488 |
} |
|
489 |
} |
|
490 |
return newString; |
|
491 |
} |
|
492 |
if (srs.toLowerCase().startsWith("crs:")){ |
|
493 |
return srs.substring(4, srs.length()); |
|
494 |
} |
|
495 |
return srs; |
|
496 |
} |
|
497 |
|
|
478 |
|
|
498 | 479 |
public Object createNewOID() { |
499 | 480 |
try { |
500 | 481 |
return String.valueOf(getFeatureCount()+1); |
Also available in: Unified diff