Statistics
| Revision:

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 @ 44644

History | View | Annotate | Download (12.7 KB)

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