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