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 | 43020 | jjdelcerro | package org.gvsig.fmap.mapcontext.layers.vectorial; |
---|---|---|---|
2 | |||
3 | import org.cresques.cts.IProjection; |
||
4 | 44043 | jjdelcerro | import org.gvsig.expressionevaluator.ExpressionBuilder; |
5 | 43020 | jjdelcerro | 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 | 44043 | jjdelcerro | // public ExpressionBuilder createBuilder() {
|
25 | // DataManager manager = DALLocator.getDataManager();
|
||
26 | // ExpressionBuilder builder = manager.createSQLBuilder();
|
||
27 | // return builder;
|
||
28 | // }
|
||
29 | 43040 | jjdelcerro | |
30 | 44043 | jjdelcerro | private Evaluator intersects(
|
31 | 43034 | jjdelcerro | Geometry geometry, |
32 | IProjection projection, |
||
33 | FeatureType featureType, |
||
34 | String geomName,
|
||
35 | ExpressionBuilder builder |
||
36 | ) { |
||
37 | 43020 | jjdelcerro | return new IntersectsGeometryEvaluator(geometry, projection, featureType, geomName, builder); |
38 | } |
||
39 | |||
40 | 44043 | jjdelcerro | private Evaluator intersects(
|
41 | 43034 | jjdelcerro | Envelope envelope, |
42 | IProjection projection, |
||
43 | FeatureType featureType, |
||
44 | String geomName,
|
||
45 | ExpressionBuilder builder |
||
46 | ) { |
||
47 | 43020 | jjdelcerro | return new IntersectsEnvelopeEvaluator(envelope, projection, featureType, geomName, builder); |
48 | } |
||
49 | |||
50 | 43034 | jjdelcerro | public Evaluator intersects(
|
51 | Geometry geometry, |
||
52 | IProjection projection, |
||
53 | FeatureStore store |
||
54 | ) { |
||
55 | 43020 | jjdelcerro | try {
|
56 | FeatureType featureType = store.getDefaultFeatureType(); |
||
57 | String geomName = featureType.getDefaultGeometryAttributeName();
|
||
58 | 44043 | jjdelcerro | ExpressionBuilder builder = (ExpressionBuilder) store.createExpressionBuilder(); |
59 | 43020 | jjdelcerro | 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 | 43034 | jjdelcerro | public Evaluator intersects(
|
66 | 44063 | jjdelcerro | 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 | 43034 | jjdelcerro | Envelope envelope, |
82 | IProjection projection, |
||
83 | FeatureStore store |
||
84 | ) { |
||
85 | 43020 | jjdelcerro | try {
|
86 | FeatureType featureType = store.getDefaultFeatureType(); |
||
87 | String geomName = featureType.getDefaultGeometryAttributeName();
|
||
88 | 43521 | jjdelcerro | ExpressionBuilder builder = store.createExpressionBuilder(); |
89 | 43020 | jjdelcerro | 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 | 44043 | jjdelcerro | private Evaluator contains(
|
96 | 43034 | jjdelcerro | Envelope envelope, |
97 | IProjection projection, |
||
98 | FeatureType featureType, |
||
99 | String geomName,
|
||
100 | ExpressionBuilder builder |
||
101 | ){ |
||
102 | 43040 | jjdelcerro | return new ContainsEnvelopeEvaluator(envelope, projection, featureType, geomName, builder); |
103 | 43020 | jjdelcerro | } |
104 | |||
105 | 44043 | jjdelcerro | private Evaluator contains(
|
106 | 43034 | jjdelcerro | 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 | 43020 | jjdelcerro | } |
114 | |||
115 | 43034 | jjdelcerro | public Evaluator contains(
|
116 | Geometry geometry, |
||
117 | IProjection projection, |
||
118 | FeatureStore store |
||
119 | ) { |
||
120 | 43020 | jjdelcerro | try {
|
121 | FeatureType featureType = store.getDefaultFeatureType(); |
||
122 | String geomName = featureType.getDefaultGeometryAttributeName();
|
||
123 | 43521 | jjdelcerro | ExpressionBuilder builder = store.createExpressionBuilder(); |
124 | 43034 | jjdelcerro | return this.contains(geometry, projection, featureType, geomName,builder); |
125 | 43020 | jjdelcerro | } catch (DataException ex) {
|
126 | throw new RuntimeException("Can't create contains evaluator.",ex); |
||
127 | } |
||
128 | } |
||
129 | |||
130 | 43034 | jjdelcerro | public Evaluator contains(
|
131 | Envelope envelope, |
||
132 | IProjection projection, |
||
133 | FeatureStore store |
||
134 | ) { |
||
135 | 43020 | jjdelcerro | try {
|
136 | FeatureType featureType = store.getDefaultFeatureType(); |
||
137 | String geomName = featureType.getDefaultGeometryAttributeName();
|
||
138 | 43521 | jjdelcerro | ExpressionBuilder builder = store.createExpressionBuilder(); |
139 | 43034 | jjdelcerro | return this.contains(envelope, projection, featureType, geomName,builder); |
140 | 43020 | jjdelcerro | } catch (DataException ex) {
|
141 | throw new RuntimeException("Can't create contains evaluator.",ex); |
||
142 | } |
||
143 | } |
||
144 | |||
145 | 44043 | jjdelcerro | private Evaluator not_contains(
|
146 | 43034 | jjdelcerro | 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 | 43020 | jjdelcerro | } |
154 | |||
155 | 43034 | jjdelcerro | public Evaluator not_contains(
|
156 | Geometry geometry, |
||
157 | IProjection projection, |
||
158 | FeatureStore store |
||
159 | ) { |
||
160 | 43020 | jjdelcerro | try {
|
161 | FeatureType featureType = store.getDefaultFeatureType(); |
||
162 | String geomName = featureType.getDefaultGeometryAttributeName();
|
||
163 | 43521 | jjdelcerro | ExpressionBuilder builder = store.createExpressionBuilder(); |
164 | 43034 | jjdelcerro | return this.not_contains(geometry, projection, featureType, geomName,builder); |
165 | 43020 | jjdelcerro | } catch (DataException ex) {
|
166 | throw new RuntimeException("Can't create not_contains evaluator.",ex); |
||
167 | } |
||
168 | } |
||
169 | |||
170 | 43034 | jjdelcerro | 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 | 43020 | jjdelcerro | } |
179 | |||
180 | 44043 | jjdelcerro | private Evaluator crosses(
|
181 | 43034 | jjdelcerro | 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 | 43020 | jjdelcerro | } |
189 | |||
190 | 43034 | jjdelcerro | public Evaluator crosses(
|
191 | Geometry geometry, |
||
192 | IProjection projection, |
||
193 | FeatureStore store |
||
194 | ) { |
||
195 | 43020 | jjdelcerro | try {
|
196 | FeatureType featureType = store.getDefaultFeatureType(); |
||
197 | String geomName = featureType.getDefaultGeometryAttributeName();
|
||
198 | 43521 | jjdelcerro | ExpressionBuilder builder = store.createExpressionBuilder(); |
199 | 43034 | jjdelcerro | return this.crosses(geometry, projection, featureType, geomName,builder); |
200 | 43020 | jjdelcerro | } catch (DataException ex) {
|
201 | throw new RuntimeException("Can't create crosses evaluator.",ex); |
||
202 | } |
||
203 | } |
||
204 | |||
205 | 43034 | jjdelcerro | public Evaluator crosses(
|
206 | Envelope envelope, |
||
207 | IProjection projection, |
||
208 | FeatureStore store |
||
209 | ) { |
||
210 | 43020 | jjdelcerro | try {
|
211 | FeatureType featureType = store.getDefaultFeatureType(); |
||
212 | String geomName = featureType.getDefaultGeometryAttributeName();
|
||
213 | 43521 | jjdelcerro | ExpressionBuilder builder = store.createExpressionBuilder(); |
214 | 43034 | jjdelcerro | return this.crosses(envelope, projection, featureType, geomName,builder); |
215 | 43020 | jjdelcerro | } catch (DataException ex) {
|
216 | throw new RuntimeException("Can't create crosses evaluator.",ex); |
||
217 | } |
||
218 | } |
||
219 | |||
220 | 44043 | jjdelcerro | private Evaluator disjoint(
|
221 | 43034 | jjdelcerro | 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 | 43020 | jjdelcerro | } |
229 | |||
230 | 43034 | jjdelcerro | public Evaluator disjoint(
|
231 | Geometry geometry, |
||
232 | IProjection projection, |
||
233 | FeatureStore store |
||
234 | ) { |
||
235 | 43020 | jjdelcerro | try {
|
236 | FeatureType featureType = store.getDefaultFeatureType(); |
||
237 | String geomName = featureType.getDefaultGeometryAttributeName();
|
||
238 | 43521 | jjdelcerro | ExpressionBuilder builder = store.createExpressionBuilder(); |
239 | 43034 | jjdelcerro | return this.disjoint(geometry, projection, featureType, geomName,builder); |
240 | 43020 | jjdelcerro | } catch (DataException ex) {
|
241 | throw new RuntimeException("Can't create disjoint evaluator.",ex); |
||
242 | } |
||
243 | } |
||
244 | |||
245 | 44043 | jjdelcerro | private Evaluator overlaps(
|
246 | 43034 | jjdelcerro | 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 | 43020 | jjdelcerro | } |
254 | |||
255 | 43034 | jjdelcerro | public Evaluator overlaps(
|
256 | Geometry geometry, |
||
257 | IProjection projection, |
||
258 | FeatureStore store |
||
259 | ) { |
||
260 | 43020 | jjdelcerro | try {
|
261 | FeatureType featureType = store.getDefaultFeatureType(); |
||
262 | String geomName = featureType.getDefaultGeometryAttributeName();
|
||
263 | 43521 | jjdelcerro | ExpressionBuilder builder = store.createExpressionBuilder(); |
264 | 43034 | jjdelcerro | return this.overlaps(geometry, projection, featureType, geomName,builder); |
265 | 43020 | jjdelcerro | } catch (DataException ex) {
|
266 | throw new RuntimeException("Can't create overlaps evaluator.",ex); |
||
267 | } |
||
268 | } |
||
269 | |||
270 | 44043 | jjdelcerro | private Evaluator touches(
|
271 | 43034 | jjdelcerro | 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 | 43020 | jjdelcerro | } |
279 | |||
280 | 43034 | jjdelcerro | public Evaluator touches(
|
281 | Geometry geometry, |
||
282 | IProjection projection, |
||
283 | FeatureStore store |
||
284 | ) { |
||
285 | 43020 | jjdelcerro | try {
|
286 | FeatureType featureType = store.getDefaultFeatureType(); |
||
287 | String geomName = featureType.getDefaultGeometryAttributeName();
|
||
288 | 43521 | jjdelcerro | ExpressionBuilder builder = store.createExpressionBuilder(); |
289 | 43034 | jjdelcerro | return this.touches(geometry, projection, featureType, geomName,builder); |
290 | 43020 | jjdelcerro | } catch (DataException ex) {
|
291 | throw new RuntimeException("Can't create touches evaluator.",ex); |
||
292 | } |
||
293 | } |
||
294 | |||
295 | 44043 | jjdelcerro | private Evaluator within(
|
296 | 43034 | jjdelcerro | 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 | 43020 | jjdelcerro | } |
304 | |||
305 | 43034 | jjdelcerro | public Evaluator within(
|
306 | Geometry geometry, |
||
307 | IProjection projection, |
||
308 | FeatureStore store |
||
309 | ) { |
||
310 | 43020 | jjdelcerro | try {
|
311 | FeatureType featureType = store.getDefaultFeatureType(); |
||
312 | String geomName = featureType.getDefaultGeometryAttributeName();
|
||
313 | 43521 | jjdelcerro | ExpressionBuilder builder = store.createExpressionBuilder(); |
314 | 43034 | jjdelcerro | return this.within(geometry, projection, featureType, geomName,builder); |
315 | 43020 | jjdelcerro | } catch (DataException ex) {
|
316 | throw new RuntimeException("Can't create within evaluator.",ex); |
||
317 | } |
||
318 | } |
||
319 | |||
320 | 44043 | jjdelcerro | private Evaluator equals(
|
321 | 43034 | jjdelcerro | 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 | 43020 | jjdelcerro | } |
329 | |||
330 | 43034 | jjdelcerro | public Evaluator equals(
|
331 | Geometry geometry, |
||
332 | IProjection projection, |
||
333 | FeatureStore store |
||
334 | ) { |
||
335 | 43020 | jjdelcerro | try {
|
336 | FeatureType featureType = store.getDefaultFeatureType(); |
||
337 | String geomName = featureType.getDefaultGeometryAttributeName();
|
||
338 | 43521 | jjdelcerro | ExpressionBuilder builder = store.createExpressionBuilder(); |
339 | 43034 | jjdelcerro | return this.equals(geometry, projection, featureType, geomName,builder); |
340 | 43020 | jjdelcerro | } catch (DataException ex) {
|
341 | throw new RuntimeException("Can't create equals evaluator.",ex); |
||
342 | } |
||
343 | } |
||
344 | |||
345 | } |