svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_mapcontext / src / org / gvsig / fmap / mapcontext / layers / vectorial / OverlapsGeometryEvaluator.java @ 26438
History | View | Annotate | Download (2.49 KB)
1 |
package org.gvsig.fmap.mapcontext.layers.vectorial; |
---|---|
2 |
|
3 |
import org.cresques.cts.ICoordTrans; |
4 |
import org.cresques.cts.IProjection; |
5 |
import org.gvsig.fmap.crs.CRSFactory; |
6 |
import org.gvsig.fmap.dal.feature.Feature; |
7 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
8 |
import org.gvsig.fmap.dal.feature.FeatureType; |
9 |
import org.gvsig.fmap.geom.Geometry; |
10 |
import org.gvsig.fmap.geom.operation.relationship.DefaultRelationshipGeometryOperationContext; |
11 |
import org.gvsig.fmap.geom.operation.relationship.Equals; |
12 |
import org.gvsig.fmap.geom.operation.relationship.Overlaps; |
13 |
import org.gvsig.tools.evaluator.AbstractEvaluator; |
14 |
import org.gvsig.tools.evaluator.EvaluatorData; |
15 |
import org.gvsig.tools.evaluator.EvaluatorException; |
16 |
/**
|
17 |
*
|
18 |
* @author Vicente Caballero Navarro
|
19 |
*
|
20 |
*/
|
21 |
public class OverlapsGeometryEvaluator extends AbstractEvaluator { |
22 |
|
23 |
private String geomName; |
24 |
private Geometry geometry;
|
25 |
private Geometry geometryTrans;
|
26 |
private String srs; |
27 |
private boolean isDefault; |
28 |
|
29 |
public OverlapsGeometryEvaluator(Geometry geometry,
|
30 |
IProjection envelopeProjection, FeatureType featureType, |
31 |
String geomName) {
|
32 |
FeatureAttributeDescriptor fad = (FeatureAttributeDescriptor) featureType |
33 |
.get(geomName); |
34 |
this.isDefault = featureType.getDefaultGeometryAttributeName().equals(
|
35 |
geomName); |
36 |
this.geometry = geometry;
|
37 |
this.geometryTrans = geometry.cloneGeometry();
|
38 |
this.srs = envelopeProjection.getAbrev();
|
39 |
ICoordTrans ct = envelopeProjection.getCT(CRSFactory.getCRS(fad |
40 |
.getSRS())); |
41 |
if (ct != null) { |
42 |
geometryTrans.reProject(ct); |
43 |
} |
44 |
this.geomName = geomName;
|
45 |
|
46 |
this.getFieldsInfo().addMatchFieldValue(geomName, geometryTrans);
|
47 |
|
48 |
} |
49 |
|
50 |
public Object evaluate(EvaluatorData data) throws EvaluatorException { |
51 |
try {
|
52 |
DefaultRelationshipGeometryOperationContext context; |
53 |
if (isDefault) {
|
54 |
Feature feature = (Feature) data.getContextValue("feature");
|
55 |
context =new DefaultRelationshipGeometryOperationContext(feature
|
56 |
.getDefaultGeometry()); |
57 |
|
58 |
} else {
|
59 |
Geometry geom = (Geometry) data.getDataValue(geomName); |
60 |
|
61 |
context = new DefaultRelationshipGeometryOperationContext(geom);
|
62 |
} |
63 |
return geometryTrans.invokeOperation(Overlaps.CODE, context);
|
64 |
|
65 |
} catch (Exception e) { |
66 |
throw new EvaluatorException(e); |
67 |
} |
68 |
} |
69 |
|
70 |
public String getName() { |
71 |
return "overlaps with geometry"; |
72 |
} |
73 |
|
74 |
public String getCQL() { |
75 |
return " overlaps(GeomFromText('" + geometry.toString() + "', " + "'" |
76 |
+ srs + "'" + "), " + geomName + ") "; |
77 |
} |
78 |
|
79 |
} |