Revision 42464 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 | ||
---|---|---|
24 | 24 |
package org.gvsig.fmap.mapcontext.layers.vectorial; |
25 | 25 |
|
26 | 26 |
import org.cresques.cts.IProjection; |
27 |
|
|
27 | 28 |
import org.gvsig.fmap.dal.exception.DataEvaluatorRuntimeException; |
28 | 29 |
import org.gvsig.fmap.dal.feature.Feature; |
29 | 30 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
... | ... | |
44 | 45 |
private Envelope envelopeTrans; |
45 | 46 |
private boolean isDefault; |
46 | 47 |
private String srs; |
48 |
String defaultGeometryAttributeName; |
|
47 | 49 |
|
48 | 50 |
public IntersectsEnvelopeEvaluator(Envelope envelope, |
49 | 51 |
IProjection envelopeProjection, FeatureType featureType, |
... | ... | |
51 | 53 |
FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) featureType |
52 | 54 |
.get(geomName); |
53 | 55 |
|
54 |
this.isDefault = featureType.getDefaultGeometryAttributeName().equals( |
|
56 |
defaultGeometryAttributeName = featureType.getDefaultGeometryAttributeName(); |
|
57 |
this.isDefault = defaultGeometryAttributeName.equals( |
|
55 | 58 |
geomName); |
56 | 59 |
this.envelope = envelope; |
57 | 60 |
// this.srs = envelopeProjection.getAbrev(); |
... | ... | |
74 | 77 |
|
75 | 78 |
} |
76 | 79 |
|
77 |
public Object evaluate(EvaluatorData data) throws EvaluatorException { |
|
78 |
Envelope featureEnvelope; |
|
79 |
if (isDefault) { |
|
80 |
featureEnvelope = ((Feature) data.getContextValue("feature")) |
|
81 |
.getDefaultEnvelope(); |
|
82 |
} else { |
|
83 |
Geometry geom = (Geometry) data.getDataValue(geomName); |
|
84 |
if( geom == null ) { |
|
85 |
return Boolean.FALSE; |
|
86 |
} |
|
87 |
featureEnvelope = geom.getEnvelope(); |
|
88 |
} |
|
89 |
return new Boolean(envelopeTrans.intersects(featureEnvelope)); |
|
80 |
public Object evaluate(EvaluatorData data) throws EvaluatorException { |
|
81 |
Envelope featureEnvelope; |
|
82 |
Geometry geom = null; |
|
83 |
if (isDefault) { |
|
84 |
geom = (Geometry) data.getDataValue(defaultGeometryAttributeName); |
|
85 |
featureEnvelope = ((Feature) data.getContextValue("feature")).getDefaultEnvelope(); |
|
86 |
} else { |
|
87 |
geom = (Geometry) data.getDataValue(geomName); |
|
88 |
if (geom == null) { |
|
89 |
return Boolean.FALSE; |
|
90 |
} |
|
91 |
featureEnvelope = geom.getEnvelope(); |
|
92 |
} |
|
93 |
if (envelopeTrans.intersects(featureEnvelope)) { |
|
94 |
return new Boolean(envelopeTrans.intersects(geom)); |
|
95 |
} |
|
96 |
return Boolean.FALSE; |
|
97 |
} |
|
90 | 98 |
|
91 |
} |
|
92 |
|
|
93 | 99 |
public String getName() { |
94 | 100 |
return "intersects envelope"; |
95 | 101 |
} |
Also available in: Unified diff