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