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