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/IntersectsEnvelopeEvaluator.java
IntersectsEnvelopeEvaluator.java | ||
---|---|---|
36 | 36 |
|
37 | 37 |
public class IntersectsEnvelopeEvaluator extends AbstractEvaluator { |
38 | 38 |
|
39 |
private Envelope envelope; |
|
40 |
private String geomName; |
|
41 |
private boolean isDefault; |
|
42 |
private ExpressionBuilder condition; |
|
43 |
String defaultGeometryAttributeName; |
|
39 |
private final Envelope envelope; |
|
40 |
private final String geomName; |
|
41 |
private final boolean isDefault; |
|
42 |
private final String defaultGeometryAttributeName; |
|
43 |
private final IProjection projection; |
|
44 |
private final ExpressionBuilder builder; |
|
44 | 45 |
|
45 |
|
|
46 |
IntersectsEnvelopeEvaluator(Envelope envelope, |
|
47 |
IProjection envelopeProjection, FeatureType featureType, |
|
46 |
/** |
|
47 |
* @param envelope |
|
48 |
* @param envelopeProjection |
|
49 |
* @param featureType |
|
50 |
* @param geomName |
|
51 |
* @deprecated use @{link org.gvsig.fmap.mapcontext.layers.vectorial.SpatialEvaluatorsFactory} |
|
52 |
*/ |
|
53 |
public IntersectsEnvelopeEvaluator( |
|
54 |
Envelope envelope, |
|
55 |
IProjection envelopeProjection, |
|
56 |
FeatureType featureType, |
|
57 |
String geomName |
|
58 |
) { |
|
59 |
this( |
|
60 |
envelope, |
|
61 |
envelopeProjection, |
|
62 |
featureType, |
|
63 |
geomName, |
|
64 |
SpatialEvaluatorsFactory.getInstance().createBuilder() |
|
65 |
); |
|
66 |
} |
|
67 |
|
|
68 |
IntersectsEnvelopeEvaluator( |
|
69 |
Envelope envelope, |
|
70 |
IProjection envelopeProjection, |
|
71 |
FeatureType featureType, |
|
48 | 72 |
String geomName, |
49 |
ExpressionBuilder builder) { |
|
73 |
ExpressionBuilder builder |
|
74 |
) { |
|
50 | 75 |
FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) featureType.get(geomName); |
51 | 76 |
defaultGeometryAttributeName = featureType.getDefaultGeometryAttributeName(); |
52 | 77 |
this.isDefault = defaultGeometryAttributeName.equals(geomName); |
53 | 78 |
this.envelope = envelope; |
79 |
this.projection = envelopeProjection; |
|
80 |
this.builder = builder; |
|
54 | 81 |
this.geomName = geomName; |
55 | 82 |
this.getFieldsInfo().addMatchFieldValue(geomName, envelope); |
56 |
|
|
57 |
this.condition = builder.set( |
|
58 |
builder.ST_Intersects( |
|
59 |
builder.geometry(envelope.getGeometry(), envelopeProjection), |
|
60 |
builder.ST_Envelope(builder.column(geomName)) |
|
61 |
) |
|
62 |
); |
|
63 | 83 |
} |
64 | 84 |
|
65 | 85 |
@Override |
... | ... | |
72 | 92 |
} else { |
73 | 93 |
geom = (Geometry) data.getDataValue(geomName); |
74 | 94 |
if (geom == null) { |
75 |
return Boolean.FALSE;
|
|
95 |
return false;
|
|
76 | 96 |
} |
77 | 97 |
featureEnvelope = geom.getEnvelope(); |
78 | 98 |
} |
79 | 99 |
if (envelope.intersects(featureEnvelope)) { |
80 | 100 |
return envelope.intersects(geom); |
81 | 101 |
} |
82 |
return Boolean.FALSE;
|
|
102 |
return false;
|
|
83 | 103 |
} |
84 | 104 |
|
85 | 105 |
@Override |
... | ... | |
89 | 109 |
|
90 | 110 |
@Override |
91 | 111 |
public String getSQL() { |
92 |
return this.condition.toString(); |
|
112 |
return builder.set( |
|
113 |
builder.ST_Intersects( |
|
114 |
builder.geometry(envelope.getGeometry(), this.projection), |
|
115 |
builder.ST_Envelope(builder.column(geomName)) |
|
116 |
) |
|
117 |
).toString(); |
|
93 | 118 |
} |
94 | 119 |
} |
Also available in: Unified diff