svn-gvsig-desktop / branches / v02_desarrollo / libraries / sld / temp / org.gvsig.sldsupport.lib.impl / src / main / java / org / gvsig / sldsupport / impl / sld1_0_0 / parsing / filteroperator / FilterOperatorElement.java @ 40799
History | View | Annotate | Download (4.4 KB)
1 |
package org.gvsig.sldsupport.impl.sld1_0_0.parsing.filteroperator; |
---|---|
2 |
|
3 |
import java.io.IOException; |
4 |
|
5 |
import org.gvsig.sldsupport.exception.SLDReadException; |
6 |
import org.gvsig.sldsupport.impl.sld1_0_0.parsing.filteroperator.comparison.BinaryComparisonOperatorElement; |
7 |
import org.gvsig.sldsupport.impl.sld1_0_0.parsing.filteroperator.comparison.IsBetweenComparisonElement; |
8 |
import org.gvsig.sldsupport.impl.sld1_0_0.parsing.filteroperator.comparison.IsLikeComparisonElement; |
9 |
import org.gvsig.sldsupport.impl.sld1_0_0.parsing.filteroperator.comparison.IsNullComparisonElement; |
10 |
import org.gvsig.sldsupport.impl.sld1_0_0.parsing.filteroperator.logic.BinaryLogicOperatorElement; |
11 |
import org.gvsig.sldsupport.impl.sld1_0_0.parsing.filteroperator.logic.UnaryLogicOperatorElement; |
12 |
import org.gvsig.sldsupport.impl.sld1_0_0.parsing.filteroperator.spatial.BBoxOperatorElement; |
13 |
import org.gvsig.sldsupport.impl.sld1_0_0.parsing.filteroperator.spatial.BinarySpatialOperatorElement; |
14 |
import org.gvsig.sldsupport.impl.util.SLDUtils; |
15 |
import org.gvsig.sldsupport.sld.filter.FilterTags; |
16 |
import org.gvsig.sldsupport.sld.filter.SLDFilterOperator; |
17 |
import org.gvsig.sldsupport.sld.filter.operator.spatial.SLDDistanceBufferOperator; |
18 |
import org.xmlpull.v1.XmlPullParser; |
19 |
import org.xmlpull.v1.XmlPullParserException; |
20 |
|
21 |
public class FilterOperatorElement { |
22 |
|
23 |
public static SLDFilterOperator parse(XmlPullParser parser , String version) |
24 |
throws XmlPullParserException, IOException, SLDReadException { |
25 |
|
26 |
String name = parser.getName();
|
27 |
SLDFilterOperator operator = null;
|
28 |
// ****************************************************************
|
29 |
// SPATIAL
|
30 |
// ****************************************************************
|
31 |
if (SLDUtils.isStr(name, FilterTags.BBOX)) {
|
32 |
operator = BBoxOperatorElement.parse(parser, version); |
33 |
return operator;
|
34 |
} |
35 |
if (SLDUtils.isStr(name, FilterTags.CONTAINS)
|
36 |
|| SLDUtils.isStr(name, FilterTags.CROSSES) |
37 |
|| SLDUtils.isStr(name, FilterTags.DISJOINT) |
38 |
|| SLDUtils.isStr(name, FilterTags.EQUALS) |
39 |
|| SLDUtils.isStr(name, FilterTags.INTERSECTS) |
40 |
|| SLDUtils.isStr(name, FilterTags.OVERLAPS) |
41 |
|| SLDUtils.isStr(name, FilterTags.TOUCHES) |
42 |
|| SLDUtils.isStr(name, FilterTags.WITHIN) |
43 |
) { |
44 |
operator = BinarySpatialOperatorElement.parse(parser, version); |
45 |
return operator;
|
46 |
} |
47 |
if (SLDUtils.isStr(name, SLDDistanceBufferOperator.DISTANCE_BUFFER_OPERATOR_BEYOND)
|
48 |
|| SLDUtils.isStr(name, SLDDistanceBufferOperator.DISTANCE_BUFFER_OPERATOR_DWITHIN) |
49 |
) { |
50 |
/*
|
51 |
* TODO
|
52 |
* Not supported (it is necessary to parse a GML geometry here)
|
53 |
*/
|
54 |
throw new SLDReadException("Distance buffer operator not supported: " + name); |
55 |
} |
56 |
// ****************************************************************
|
57 |
// COMPARISON
|
58 |
// ****************************************************************
|
59 |
if (SLDUtils.isStr(name, FilterTags.PROPERTYISEQUALTO)
|
60 |
|| SLDUtils.isStr(name, FilterTags.PROPERTYISNOTEQUALTO) |
61 |
|| SLDUtils.isStr(name, FilterTags.PROPERTYISLESSTHAN) |
62 |
|| SLDUtils.isStr(name, FilterTags.PROPERTYISLESSOREQUALTHAN) |
63 |
|| SLDUtils.isStr(name, FilterTags.PROPERTYISGREATERTHAN) |
64 |
|| SLDUtils.isStr(name, FilterTags.PROPERTYISGREATEROREQUALTHAN) |
65 |
) { |
66 |
operator = BinaryComparisonOperatorElement.parse(parser, version); |
67 |
return operator;
|
68 |
} |
69 |
if (SLDUtils.isStr(name, FilterTags.PROPERTYISLIKE)) {
|
70 |
operator = IsLikeComparisonElement.parse(parser, version); |
71 |
return operator;
|
72 |
} |
73 |
if (SLDUtils.isStr(name, FilterTags.PROPERTYISNULL)) {
|
74 |
operator = IsNullComparisonElement.parse(parser, version); |
75 |
return operator;
|
76 |
} |
77 |
if (SLDUtils.isStr(name, FilterTags.PROPERTYISBETWEEN)) {
|
78 |
operator = IsBetweenComparisonElement.parse(parser, version); |
79 |
return operator;
|
80 |
} |
81 |
// ****************************************************************
|
82 |
// LOGIC
|
83 |
// ****************************************************************
|
84 |
if (SLDUtils.isStr(name, FilterTags.AND)
|
85 |
|| SLDUtils.isStr(name, FilterTags.OR)) { |
86 |
operator = BinaryLogicOperatorElement.parse(parser, version); |
87 |
return operator;
|
88 |
} |
89 |
if (SLDUtils.isStr(name, FilterTags.NOT)) {
|
90 |
operator = UnaryLogicOperatorElement.parse(parser, version); |
91 |
return operator;
|
92 |
} |
93 |
// ****************************************************************
|
94 |
throw new SLDReadException("Unexpected entity in filter operator: " + name); |
95 |
} |
96 |
} |