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 @ 43034
History | View | Annotate | Download (11.5 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(
|
26 |
Geometry geometry, |
27 |
IProjection projection, |
28 |
FeatureType featureType, |
29 |
String geomName,
|
30 |
ExpressionBuilder builder |
31 |
) { |
32 |
return new IntersectsGeometryEvaluator(geometry, projection, featureType, geomName, builder); |
33 |
} |
34 |
|
35 |
public Evaluator intersects(
|
36 |
Envelope envelope, |
37 |
IProjection projection, |
38 |
FeatureType featureType, |
39 |
String geomName,
|
40 |
ExpressionBuilder builder |
41 |
) { |
42 |
return new IntersectsEnvelopeEvaluator(envelope, projection, featureType, geomName, builder); |
43 |
} |
44 |
|
45 |
public Evaluator intersects(
|
46 |
Geometry geometry, |
47 |
IProjection projection, |
48 |
FeatureStore store |
49 |
) { |
50 |
try {
|
51 |
FeatureType featureType = store.getDefaultFeatureType(); |
52 |
String geomName = featureType.getDefaultGeometryAttributeName();
|
53 |
ExpressionBuilder builder = store.createExpressionBuilder(); |
54 |
return intersects(geometry, projection, featureType, geomName,builder);
|
55 |
} catch (DataException ex) {
|
56 |
throw new RuntimeException("Can't create intersects evaluator.",ex); |
57 |
} |
58 |
} |
59 |
|
60 |
public Evaluator intersects(
|
61 |
Envelope envelope, |
62 |
IProjection projection, |
63 |
FeatureStore store |
64 |
) { |
65 |
try {
|
66 |
FeatureType featureType = store.getDefaultFeatureType(); |
67 |
String geomName = featureType.getDefaultGeometryAttributeName();
|
68 |
ExpressionBuilder builder = store.createExpressionBuilder(); |
69 |
return intersects(envelope, projection, featureType, geomName,builder);
|
70 |
} catch (DataException ex) {
|
71 |
throw new RuntimeException("Can't create intersects evaluator.",ex); |
72 |
} |
73 |
} |
74 |
|
75 |
public Evaluator contains(
|
76 |
Envelope envelope, |
77 |
IProjection projection, |
78 |
FeatureType featureType, |
79 |
String geomName,
|
80 |
ExpressionBuilder builder |
81 |
){ |
82 |
return new ContainsEnvelopeEvaluator(envelope, projection, featureType, geomName); |
83 |
} |
84 |
|
85 |
public Evaluator contains(
|
86 |
Geometry geometry, |
87 |
IProjection projection, |
88 |
FeatureType featureType, |
89 |
String geomName,
|
90 |
ExpressionBuilder builder |
91 |
){ |
92 |
return new ContainsGeometryEvaluator(geometry, projection, featureType, geomName, builder); |
93 |
} |
94 |
|
95 |
public Evaluator contains(
|
96 |
Geometry geometry, |
97 |
IProjection projection, |
98 |
FeatureStore store |
99 |
) { |
100 |
try {
|
101 |
FeatureType featureType = store.getDefaultFeatureType(); |
102 |
String geomName = featureType.getDefaultGeometryAttributeName();
|
103 |
ExpressionBuilder builder = store.createExpressionBuilder(); |
104 |
return this.contains(geometry, projection, featureType, geomName,builder); |
105 |
} catch (DataException ex) {
|
106 |
throw new RuntimeException("Can't create contains evaluator.",ex); |
107 |
} |
108 |
} |
109 |
|
110 |
public Evaluator contains(
|
111 |
Envelope envelope, |
112 |
IProjection projection, |
113 |
FeatureStore store |
114 |
) { |
115 |
try {
|
116 |
FeatureType featureType = store.getDefaultFeatureType(); |
117 |
String geomName = featureType.getDefaultGeometryAttributeName();
|
118 |
ExpressionBuilder builder = store.createExpressionBuilder(); |
119 |
return this.contains(envelope, projection, featureType, geomName,builder); |
120 |
} catch (DataException ex) {
|
121 |
throw new RuntimeException("Can't create contains evaluator.",ex); |
122 |
} |
123 |
} |
124 |
|
125 |
public Evaluator not_contains(
|
126 |
Geometry geometry, |
127 |
IProjection projection, |
128 |
FeatureType featureType, |
129 |
String geomName,
|
130 |
ExpressionBuilder builder |
131 |
){ |
132 |
return new OutGeometryEvaluator(geometry, projection, featureType, geomName, builder); |
133 |
} |
134 |
|
135 |
public Evaluator not_contains(
|
136 |
Geometry geometry, |
137 |
IProjection projection, |
138 |
FeatureStore store |
139 |
) { |
140 |
try {
|
141 |
FeatureType featureType = store.getDefaultFeatureType(); |
142 |
String geomName = featureType.getDefaultGeometryAttributeName();
|
143 |
ExpressionBuilder builder = store.createExpressionBuilder(); |
144 |
return this.not_contains(geometry, projection, featureType, geomName,builder); |
145 |
} catch (DataException ex) {
|
146 |
throw new RuntimeException("Can't create not_contains evaluator.",ex); |
147 |
} |
148 |
} |
149 |
|
150 |
public Evaluator crosses(
|
151 |
Geometry geometry, |
152 |
IProjection projection, |
153 |
FeatureType featureType, |
154 |
String geomName,
|
155 |
ExpressionBuilder builder |
156 |
) { |
157 |
return new CrossesGeometryEvaluator(geometry, projection, featureType, geomName, builder); |
158 |
} |
159 |
|
160 |
public Evaluator crosses(
|
161 |
Envelope envelope, |
162 |
IProjection projection, |
163 |
FeatureType featureType, |
164 |
String geomName,
|
165 |
ExpressionBuilder builder |
166 |
) { |
167 |
return new CrossEnvelopeEvaluator(envelope, projection, featureType, geomName, builder); |
168 |
} |
169 |
|
170 |
public Evaluator crosses(
|
171 |
Geometry geometry, |
172 |
IProjection projection, |
173 |
FeatureStore store |
174 |
) { |
175 |
try {
|
176 |
FeatureType featureType = store.getDefaultFeatureType(); |
177 |
String geomName = featureType.getDefaultGeometryAttributeName();
|
178 |
ExpressionBuilder builder = store.createExpressionBuilder(); |
179 |
return this.crosses(geometry, projection, featureType, geomName,builder); |
180 |
} catch (DataException ex) {
|
181 |
throw new RuntimeException("Can't create crosses evaluator.",ex); |
182 |
} |
183 |
} |
184 |
|
185 |
public Evaluator crosses(
|
186 |
Envelope envelope, |
187 |
IProjection projection, |
188 |
FeatureStore store |
189 |
) { |
190 |
try {
|
191 |
FeatureType featureType = store.getDefaultFeatureType(); |
192 |
String geomName = featureType.getDefaultGeometryAttributeName();
|
193 |
ExpressionBuilder builder = store.createExpressionBuilder(); |
194 |
return this.crosses(envelope, projection, featureType, geomName,builder); |
195 |
} catch (DataException ex) {
|
196 |
throw new RuntimeException("Can't create crosses evaluator.",ex); |
197 |
} |
198 |
} |
199 |
|
200 |
public Evaluator disjoint(
|
201 |
Geometry geometry, |
202 |
IProjection projection, |
203 |
FeatureType featureType, |
204 |
String geomName,
|
205 |
ExpressionBuilder builder |
206 |
) { |
207 |
return new DisjointGeometryEvaluator(geometry, projection, featureType, geomName, builder); |
208 |
} |
209 |
|
210 |
public Evaluator disjoint(
|
211 |
Geometry geometry, |
212 |
IProjection projection, |
213 |
FeatureStore store |
214 |
) { |
215 |
try {
|
216 |
FeatureType featureType = store.getDefaultFeatureType(); |
217 |
String geomName = featureType.getDefaultGeometryAttributeName();
|
218 |
ExpressionBuilder builder = store.createExpressionBuilder(); |
219 |
return this.disjoint(geometry, projection, featureType, geomName,builder); |
220 |
} catch (DataException ex) {
|
221 |
throw new RuntimeException("Can't create disjoint evaluator.",ex); |
222 |
} |
223 |
} |
224 |
|
225 |
public Evaluator overlaps(
|
226 |
Geometry geometry, |
227 |
IProjection projection, |
228 |
FeatureType featureType, |
229 |
String geomName,
|
230 |
ExpressionBuilder builder |
231 |
) { |
232 |
return new OverlapsGeometryEvaluator(geometry, projection, featureType, geomName, builder); |
233 |
} |
234 |
|
235 |
public Evaluator overlaps(
|
236 |
Geometry geometry, |
237 |
IProjection projection, |
238 |
FeatureStore store |
239 |
) { |
240 |
try {
|
241 |
FeatureType featureType = store.getDefaultFeatureType(); |
242 |
String geomName = featureType.getDefaultGeometryAttributeName();
|
243 |
ExpressionBuilder builder = store.createExpressionBuilder(); |
244 |
return this.overlaps(geometry, projection, featureType, geomName,builder); |
245 |
} catch (DataException ex) {
|
246 |
throw new RuntimeException("Can't create overlaps evaluator.",ex); |
247 |
} |
248 |
} |
249 |
|
250 |
public Evaluator touches(
|
251 |
Geometry geometry, |
252 |
IProjection projection, |
253 |
FeatureType featureType, |
254 |
String geomName,
|
255 |
ExpressionBuilder builder |
256 |
) { |
257 |
return new TouchesGeometryEvaluator(geometry, projection, featureType, geomName,builder); |
258 |
} |
259 |
|
260 |
public Evaluator touches(
|
261 |
Geometry geometry, |
262 |
IProjection projection, |
263 |
FeatureStore store |
264 |
) { |
265 |
try {
|
266 |
FeatureType featureType = store.getDefaultFeatureType(); |
267 |
String geomName = featureType.getDefaultGeometryAttributeName();
|
268 |
ExpressionBuilder builder = store.createExpressionBuilder(); |
269 |
return this.touches(geometry, projection, featureType, geomName,builder); |
270 |
} catch (DataException ex) {
|
271 |
throw new RuntimeException("Can't create touches evaluator.",ex); |
272 |
} |
273 |
} |
274 |
|
275 |
public Evaluator within(
|
276 |
Geometry geometry, |
277 |
IProjection projection, |
278 |
FeatureType featureType, |
279 |
String geomName,
|
280 |
ExpressionBuilder builder |
281 |
) { |
282 |
return new WithinGeometryEvaluator(geometry, projection, featureType, geomName,builder); |
283 |
} |
284 |
|
285 |
public Evaluator within(
|
286 |
Geometry geometry, |
287 |
IProjection projection, |
288 |
FeatureStore store |
289 |
) { |
290 |
try {
|
291 |
FeatureType featureType = store.getDefaultFeatureType(); |
292 |
String geomName = featureType.getDefaultGeometryAttributeName();
|
293 |
ExpressionBuilder builder = store.createExpressionBuilder(); |
294 |
return this.within(geometry, projection, featureType, geomName,builder); |
295 |
} catch (DataException ex) {
|
296 |
throw new RuntimeException("Can't create within evaluator.",ex); |
297 |
} |
298 |
} |
299 |
|
300 |
public Evaluator equals(
|
301 |
Geometry geometry, |
302 |
IProjection projection, |
303 |
FeatureType featureType, |
304 |
String geomName,
|
305 |
ExpressionBuilder builder |
306 |
) { |
307 |
return new EqualsGeometryEvaluator(geometry, projection, featureType, geomName,builder); |
308 |
} |
309 |
|
310 |
public Evaluator equals(
|
311 |
Geometry geometry, |
312 |
IProjection projection, |
313 |
FeatureStore store |
314 |
) { |
315 |
try {
|
316 |
FeatureType featureType = store.getDefaultFeatureType(); |
317 |
String geomName = featureType.getDefaultGeometryAttributeName();
|
318 |
ExpressionBuilder builder = store.createExpressionBuilder(); |
319 |
return this.equals(geometry, projection, featureType, geomName,builder); |
320 |
} catch (DataException ex) {
|
321 |
throw new RuntimeException("Can't create equals evaluator.",ex); |
322 |
} |
323 |
} |
324 |
|
325 |
} |