svn-gvsig-desktop / 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 / SpatialEvaluatorsFactory.java @ 43020
History | View | Annotate | Download (10.6 KB)
1 |
package org.gvsig.fmap.mapcontext.layers.vectorial; |
---|---|
2 |
|
3 |
import org.cresques.cts.IProjection; |
4 |
import org.gvsig.fmap.dal.exception.DataException; |
5 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
6 |
import org.gvsig.fmap.dal.feature.FeatureType; |
7 |
import org.gvsig.fmap.dal.ExpressionBuilder; |
8 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
9 |
import org.gvsig.fmap.geom.Geometry; |
10 |
import org.gvsig.fmap.geom.primitive.Envelope; |
11 |
import org.gvsig.tools.evaluator.Evaluator; |
12 |
|
13 |
public class SpatialEvaluatorsFactory { |
14 |
|
15 |
private static final SpatialEvaluatorsFactory factory = new SpatialEvaluatorsFactory(); |
16 |
|
17 |
public static SpatialEvaluatorsFactory getInstance() { |
18 |
return factory;
|
19 |
} |
20 |
|
21 |
private SpatialEvaluatorsFactory() {
|
22 |
|
23 |
} |
24 |
|
25 |
public Evaluator intersects(Geometry geometry,
|
26 |
IProjection projection, |
27 |
FeatureType featureType, |
28 |
String geomName,
|
29 |
ExpressionBuilder builder) { |
30 |
return new IntersectsGeometryEvaluator(geometry, projection, featureType, geomName, builder); |
31 |
} |
32 |
|
33 |
public Evaluator intersects(Envelope envelope,
|
34 |
IProjection projection, |
35 |
FeatureType featureType, |
36 |
String geomName,
|
37 |
ExpressionBuilder builder) { |
38 |
return new IntersectsEnvelopeEvaluator(envelope, projection, featureType, geomName, builder); |
39 |
} |
40 |
|
41 |
public Evaluator intersects(Geometry geometry,
|
42 |
IProjection projection, |
43 |
FeatureStore store) { |
44 |
|
45 |
|
46 |
try {
|
47 |
FeatureType featureType = store.getDefaultFeatureType(); |
48 |
String geomName = featureType.getDefaultGeometryAttributeName();
|
49 |
ExpressionBuilder builder = store.createExpressionBuilder(); |
50 |
return intersects(geometry, projection, featureType, geomName,builder);
|
51 |
} catch (DataException ex) {
|
52 |
throw new RuntimeException("Can't create intersects evaluator.",ex); |
53 |
} |
54 |
} |
55 |
|
56 |
public Evaluator intersects(Envelope envelope,
|
57 |
IProjection projection, |
58 |
FeatureStore store) { |
59 |
try {
|
60 |
FeatureType featureType = store.getDefaultFeatureType(); |
61 |
String geomName = featureType.getDefaultGeometryAttributeName();
|
62 |
ExpressionBuilder builder = store.createExpressionBuilder(); |
63 |
return intersects(envelope, projection, featureType, geomName,builder);
|
64 |
} catch (DataException ex) {
|
65 |
throw new RuntimeException("Can't create intersects evaluator.",ex); |
66 |
} |
67 |
} |
68 |
|
69 |
public Evaluator contains(Envelope envelope,
|
70 |
IProjection projection, |
71 |
FeatureType featureType, |
72 |
String geomName,
|
73 |
ExpressionBuilder builder){ |
74 |
return new ContainsEnvelopeEvaluator(envelope, projection, featureType, geomName); |
75 |
} |
76 |
|
77 |
public Evaluator contains(Geometry geometry,
|
78 |
IProjection projection, |
79 |
FeatureType featureType, |
80 |
String geomName,
|
81 |
ExpressionBuilder builder){ |
82 |
return new ContainsGeometryEvaluator(geometry, projection, featureType, geomName); |
83 |
} |
84 |
|
85 |
public Evaluator contains(Geometry geometry,
|
86 |
IProjection projection, |
87 |
FeatureStore store) { |
88 |
try {
|
89 |
FeatureType featureType = store.getDefaultFeatureType(); |
90 |
String geomName = featureType.getDefaultGeometryAttributeName();
|
91 |
ExpressionBuilder builder = store.createExpressionBuilder(); |
92 |
return contains(geometry, projection, featureType, geomName,builder);
|
93 |
} catch (DataException ex) {
|
94 |
throw new RuntimeException("Can't create contains evaluator.",ex); |
95 |
} |
96 |
} |
97 |
|
98 |
public Evaluator contains(Envelope envelope,
|
99 |
IProjection projection, |
100 |
FeatureStore store) { |
101 |
try {
|
102 |
FeatureType featureType = store.getDefaultFeatureType(); |
103 |
String geomName = featureType.getDefaultGeometryAttributeName();
|
104 |
ExpressionBuilder builder = store.createExpressionBuilder(); |
105 |
return contains(envelope, projection, featureType, geomName,builder);
|
106 |
} catch (DataException ex) {
|
107 |
throw new RuntimeException("Can't create contains evaluator.",ex); |
108 |
} |
109 |
} |
110 |
|
111 |
public Evaluator not_contains(Geometry geometry,
|
112 |
IProjection projection, |
113 |
FeatureType featureType, |
114 |
String geomName,
|
115 |
ExpressionBuilder builder){ |
116 |
return new OutGeometryEvaluator(geometry, projection, featureType, geomName); |
117 |
} |
118 |
|
119 |
public Evaluator not_contains(Geometry geometry,
|
120 |
IProjection projection, |
121 |
FeatureStore store) { |
122 |
try {
|
123 |
FeatureType featureType = store.getDefaultFeatureType(); |
124 |
String geomName = featureType.getDefaultGeometryAttributeName();
|
125 |
ExpressionBuilder builder = store.createExpressionBuilder(); |
126 |
return not_contains(geometry, projection, featureType, geomName,builder);
|
127 |
} catch (DataException ex) {
|
128 |
throw new RuntimeException("Can't create not_contains evaluator.",ex); |
129 |
} |
130 |
} |
131 |
|
132 |
public Evaluator crosses(Geometry geometry,
|
133 |
IProjection projection, |
134 |
FeatureType featureType, |
135 |
String geomName,
|
136 |
ExpressionBuilder builder) { |
137 |
return new CrossesGeometryEvaluator(geometry, projection, featureType, geomName); |
138 |
} |
139 |
|
140 |
public Evaluator crosses(Envelope envelope,
|
141 |
IProjection projection, |
142 |
FeatureType featureType, |
143 |
String geomName,
|
144 |
ExpressionBuilder builder) { |
145 |
return new CrossEnvelopeEvaluator(envelope, projection, featureType, geomName); |
146 |
} |
147 |
|
148 |
public Evaluator crosses(Geometry geometry,
|
149 |
IProjection projection, |
150 |
FeatureStore store) { |
151 |
try {
|
152 |
FeatureType featureType = store.getDefaultFeatureType(); |
153 |
String geomName = featureType.getDefaultGeometryAttributeName();
|
154 |
ExpressionBuilder builder = store.createExpressionBuilder(); |
155 |
return crosses(geometry, projection, featureType, geomName,builder);
|
156 |
} catch (DataException ex) {
|
157 |
throw new RuntimeException("Can't create crosses evaluator.",ex); |
158 |
} |
159 |
} |
160 |
|
161 |
public Evaluator crosses(Envelope envelope,
|
162 |
IProjection projection, |
163 |
FeatureStore store) { |
164 |
try {
|
165 |
FeatureType featureType = store.getDefaultFeatureType(); |
166 |
String geomName = featureType.getDefaultGeometryAttributeName();
|
167 |
ExpressionBuilder builder = store.createExpressionBuilder(); |
168 |
return crosses(envelope, projection, featureType, geomName,builder);
|
169 |
} catch (DataException ex) {
|
170 |
throw new RuntimeException("Can't create crosses evaluator.",ex); |
171 |
} |
172 |
} |
173 |
|
174 |
public Evaluator disjoint(Geometry geometry,
|
175 |
IProjection projection, |
176 |
FeatureType featureType, |
177 |
String geomName,
|
178 |
ExpressionBuilder builder) { |
179 |
return new DisjointGeometryEvaluator(geometry, projection, featureType, geomName); |
180 |
} |
181 |
|
182 |
public Evaluator disjoint(Geometry geometry,
|
183 |
IProjection projection, |
184 |
FeatureStore store) { |
185 |
try {
|
186 |
FeatureType featureType = store.getDefaultFeatureType(); |
187 |
String geomName = featureType.getDefaultGeometryAttributeName();
|
188 |
ExpressionBuilder builder = store.createExpressionBuilder(); |
189 |
return disjoint(geometry, projection, featureType, geomName,builder);
|
190 |
} catch (DataException ex) {
|
191 |
throw new RuntimeException("Can't create disjoint evaluator.",ex); |
192 |
} |
193 |
} |
194 |
|
195 |
public Evaluator overlaps(Geometry geometry,
|
196 |
IProjection projection, |
197 |
FeatureType featureType, |
198 |
String geomName,
|
199 |
ExpressionBuilder builder) { |
200 |
return new OverlapsGeometryEvaluator(geometry, projection, featureType, geomName); |
201 |
} |
202 |
|
203 |
public Evaluator overlaps(Geometry geometry,
|
204 |
IProjection projection, |
205 |
FeatureStore store) { |
206 |
try {
|
207 |
FeatureType featureType = store.getDefaultFeatureType(); |
208 |
String geomName = featureType.getDefaultGeometryAttributeName();
|
209 |
ExpressionBuilder builder = store.createExpressionBuilder(); |
210 |
return overlaps(geometry, projection, featureType, geomName,builder);
|
211 |
} catch (DataException ex) {
|
212 |
throw new RuntimeException("Can't create overlaps evaluator.",ex); |
213 |
} |
214 |
} |
215 |
|
216 |
public Evaluator touches(Geometry geometry,
|
217 |
IProjection projection, |
218 |
FeatureType featureType, |
219 |
String geomName,
|
220 |
ExpressionBuilder builder) { |
221 |
return new TouchesGeometryEvaluator(geometry, projection, featureType, geomName); |
222 |
} |
223 |
|
224 |
public Evaluator touches(Geometry geometry,
|
225 |
IProjection projection, |
226 |
FeatureStore store) { |
227 |
try {
|
228 |
FeatureType featureType = store.getDefaultFeatureType(); |
229 |
String geomName = featureType.getDefaultGeometryAttributeName();
|
230 |
ExpressionBuilder builder = store.createExpressionBuilder(); |
231 |
return touches(geometry, projection, featureType, geomName,builder);
|
232 |
} catch (DataException ex) {
|
233 |
throw new RuntimeException("Can't create touches evaluator.",ex); |
234 |
} |
235 |
} |
236 |
|
237 |
public Evaluator within(Geometry geometry,
|
238 |
IProjection projection, |
239 |
FeatureType featureType, |
240 |
String geomName,
|
241 |
ExpressionBuilder builder) { |
242 |
return new WithinGeometryEvaluator(geometry, projection, featureType, geomName); |
243 |
} |
244 |
|
245 |
public Evaluator within(Geometry geometry,
|
246 |
IProjection projection, |
247 |
FeatureStore store) { |
248 |
try {
|
249 |
FeatureType featureType = store.getDefaultFeatureType(); |
250 |
String geomName = featureType.getDefaultGeometryAttributeName();
|
251 |
ExpressionBuilder builder = store.createExpressionBuilder(); |
252 |
return within(geometry, projection, featureType, geomName,builder);
|
253 |
} catch (DataException ex) {
|
254 |
throw new RuntimeException("Can't create within evaluator.",ex); |
255 |
} |
256 |
} |
257 |
|
258 |
public Evaluator equals(Geometry geometry,
|
259 |
IProjection projection, |
260 |
FeatureType featureType, |
261 |
String geomName,
|
262 |
ExpressionBuilder builder) { |
263 |
return new EqualsGeometryEvaluator(geometry, projection, featureType, geomName); |
264 |
} |
265 |
|
266 |
public Evaluator equals(Geometry geometry,
|
267 |
IProjection projection, |
268 |
FeatureStore store) { |
269 |
try {
|
270 |
FeatureType featureType = store.getDefaultFeatureType(); |
271 |
String geomName = featureType.getDefaultGeometryAttributeName();
|
272 |
ExpressionBuilder builder = store.createExpressionBuilder(); |
273 |
return equals(geometry, projection, featureType, geomName,builder);
|
274 |
} catch (DataException ex) {
|
275 |
throw new RuntimeException("Can't create equals evaluator.",ex); |
276 |
} |
277 |
} |
278 |
|
279 |
} |