Revision 43040 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.mapcontext/org.gvsig.fmap.mapcontext.api/src/main/java/org/gvsig/fmap/mapcontext/layers/vectorial/IntersectsGeometryEvaluator.java
IntersectsGeometryEvaluator.java | ||
---|---|---|
28 | 28 |
import org.gvsig.fmap.dal.feature.Feature; |
29 | 29 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
30 | 30 |
import org.gvsig.fmap.dal.feature.FeatureType; |
31 |
import org.gvsig.fmap.dal.SQLBuilder; |
|
32 | 31 |
import org.gvsig.fmap.geom.Geometry; |
33 | 32 |
import org.gvsig.tools.evaluator.AbstractEvaluator; |
34 | 33 |
import org.gvsig.tools.evaluator.EvaluatorData; |
... | ... | |
36 | 35 |
|
37 | 36 |
public class IntersectsGeometryEvaluator extends AbstractEvaluator { |
38 | 37 |
|
39 |
private String geomName; |
|
40 |
private Geometry geometry; |
|
41 |
private Geometry geometryTrans; |
|
42 |
private boolean isDefault; |
|
43 |
private ExpressionBuilder condition; |
|
38 |
private final String geomName; |
|
39 |
private final Geometry geometry; |
|
40 |
private final Geometry geometryTrans; |
|
41 |
private final boolean isDefault; |
|
42 |
private final ExpressionBuilder builder; |
|
43 |
private final IProjection projection; |
|
44 | 44 |
|
45 |
IntersectsGeometryEvaluator(Geometry geometry, |
|
46 |
IProjection projection, FeatureType featureType, |
|
45 |
/** |
|
46 |
* @param geometry |
|
47 |
* @param projection |
|
48 |
* @param featureType |
|
49 |
* @param geomName |
|
50 |
* @deprecated use @{link org.gvsig.fmap.mapcontext.layers.vectorial.SpatialEvaluatorsFactory} |
|
51 |
*/ |
|
52 |
public IntersectsGeometryEvaluator( |
|
53 |
Geometry geometry, |
|
54 |
IProjection projection, |
|
55 |
FeatureType featureType, |
|
56 |
String geomName |
|
57 |
) { |
|
58 |
this( |
|
59 |
geometry, |
|
60 |
projection, |
|
61 |
featureType, |
|
62 |
geomName, |
|
63 |
SpatialEvaluatorsFactory.getInstance().createBuilder() |
|
64 |
); |
|
65 |
} |
|
66 |
|
|
67 |
IntersectsGeometryEvaluator( |
|
68 |
Geometry geometry, |
|
69 |
IProjection projection, |
|
70 |
FeatureType featureType, |
|
47 | 71 |
String geomName, |
48 |
ExpressionBuilder builder) { |
|
72 |
ExpressionBuilder builder |
|
73 |
) { |
|
49 | 74 |
FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) featureType |
50 | 75 |
.get(geomName); |
51 | 76 |
this.isDefault = featureType.getDefaultGeometryAttributeName().equals(geomName); |
52 | 77 |
this.geometry = geometry; |
78 |
this.projection = projection; |
|
79 |
this.builder = builder; |
|
53 | 80 |
this.geometryTrans = geometry.cloneGeometry(); |
54 | 81 |
ICoordTrans ct = null; |
55 | 82 |
|
... | ... | |
63 | 90 |
} |
64 | 91 |
this.geomName = geomName; |
65 | 92 |
this.getFieldsInfo().addMatchFieldValue(geomName, geometryTrans); |
66 |
this.condition = builder.set( |
|
67 |
builder.ST_Intersects( |
|
68 |
builder.geometry(geometry, projection), |
|
69 |
builder.column(geomName) |
|
70 |
) |
|
71 |
); |
|
72 | 93 |
} |
73 | 94 |
|
74 | 95 |
@Override |
75 | 96 |
public Object evaluate(EvaluatorData data) throws EvaluatorException { |
76 | 97 |
try { |
77 |
Geometry geom ;
|
|
98 |
Geometry geom; |
|
78 | 99 |
if (isDefault) { |
79 | 100 |
Feature feature = (Feature) data.getContextValue("feature"); |
80 | 101 |
geom = feature.getDefaultGeometry(); |
... | ... | |
99 | 120 |
|
100 | 121 |
@Override |
101 | 122 |
public String getSQL() { |
102 |
return this.condition.toString(); |
|
123 |
return builder.set( |
|
124 |
builder.ST_Intersects( |
|
125 |
builder.geometry(geometry, this.projection), |
|
126 |
builder.column(geomName) |
|
127 |
) |
|
128 |
).toString(); |
|
103 | 129 |
} |
104 | 130 |
|
105 | 131 |
} |
Also available in: Unified diff