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 | 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 | Envelope envelope, |
||
67 | IProjection projection, |
||
68 | FeatureStore store |
||
69 | ) { |
||
70 | 43020 | jjdelcerro | try {
|
71 | FeatureType featureType = store.getDefaultFeatureType(); |
||
72 | String geomName = featureType.getDefaultGeometryAttributeName();
|
||
73 | 43521 | jjdelcerro | ExpressionBuilder builder = store.createExpressionBuilder(); |
74 | 43020 | jjdelcerro | 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 | 44043 | jjdelcerro | private Evaluator contains(
|
81 | 43034 | jjdelcerro | Envelope envelope, |
82 | IProjection projection, |
||
83 | FeatureType featureType, |
||
84 | String geomName,
|
||
85 | ExpressionBuilder builder |
||
86 | ){ |
||
87 | 43040 | jjdelcerro | return new ContainsEnvelopeEvaluator(envelope, projection, featureType, geomName, builder); |
88 | 43020 | jjdelcerro | } |
89 | |||
90 | 44043 | jjdelcerro | private Evaluator contains(
|
91 | 43034 | jjdelcerro | 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 | 43020 | jjdelcerro | } |
99 | |||
100 | 43034 | jjdelcerro | public Evaluator contains(
|
101 | Geometry geometry, |
||
102 | IProjection projection, |
||
103 | FeatureStore store |
||
104 | ) { |
||
105 | 43020 | jjdelcerro | try {
|
106 | FeatureType featureType = store.getDefaultFeatureType(); |
||
107 | String geomName = featureType.getDefaultGeometryAttributeName();
|
||
108 | 43521 | jjdelcerro | ExpressionBuilder builder = store.createExpressionBuilder(); |
109 | 43034 | jjdelcerro | return this.contains(geometry, projection, featureType, geomName,builder); |
110 | 43020 | jjdelcerro | } catch (DataException ex) {
|
111 | throw new RuntimeException("Can't create contains evaluator.",ex); |
||
112 | } |
||
113 | } |
||
114 | |||
115 | 43034 | jjdelcerro | public Evaluator contains(
|
116 | Envelope envelope, |
||
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(envelope, projection, featureType, geomName,builder); |
125 | 43020 | jjdelcerro | } catch (DataException ex) {
|
126 | throw new RuntimeException("Can't create contains evaluator.",ex); |
||
127 | } |
||
128 | } |
||
129 | |||
130 | 44043 | jjdelcerro | private Evaluator not_contains(
|
131 | 43034 | jjdelcerro | 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 | 43020 | jjdelcerro | } |
139 | |||
140 | 43034 | jjdelcerro | public Evaluator not_contains(
|
141 | Geometry geometry, |
||
142 | IProjection projection, |
||
143 | FeatureStore store |
||
144 | ) { |
||
145 | 43020 | jjdelcerro | try {
|
146 | FeatureType featureType = store.getDefaultFeatureType(); |
||
147 | String geomName = featureType.getDefaultGeometryAttributeName();
|
||
148 | 43521 | jjdelcerro | ExpressionBuilder builder = store.createExpressionBuilder(); |
149 | 43034 | jjdelcerro | return this.not_contains(geometry, projection, featureType, geomName,builder); |
150 | 43020 | jjdelcerro | } catch (DataException ex) {
|
151 | throw new RuntimeException("Can't create not_contains evaluator.",ex); |
||
152 | } |
||
153 | } |
||
154 | |||
155 | 43034 | jjdelcerro | 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 | 43020 | jjdelcerro | } |
164 | |||
165 | 44043 | jjdelcerro | private Evaluator crosses(
|
166 | 43034 | jjdelcerro | 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 | 43020 | jjdelcerro | } |
174 | |||
175 | 43034 | jjdelcerro | public Evaluator crosses(
|
176 | Geometry geometry, |
||
177 | IProjection projection, |
||
178 | FeatureStore store |
||
179 | ) { |
||
180 | 43020 | jjdelcerro | try {
|
181 | FeatureType featureType = store.getDefaultFeatureType(); |
||
182 | String geomName = featureType.getDefaultGeometryAttributeName();
|
||
183 | 43521 | jjdelcerro | ExpressionBuilder builder = store.createExpressionBuilder(); |
184 | 43034 | jjdelcerro | return this.crosses(geometry, projection, featureType, geomName,builder); |
185 | 43020 | jjdelcerro | } catch (DataException ex) {
|
186 | throw new RuntimeException("Can't create crosses evaluator.",ex); |
||
187 | } |
||
188 | } |
||
189 | |||
190 | 43034 | jjdelcerro | public Evaluator crosses(
|
191 | Envelope envelope, |
||
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(envelope, projection, featureType, geomName,builder); |
200 | 43020 | jjdelcerro | } catch (DataException ex) {
|
201 | throw new RuntimeException("Can't create crosses evaluator.",ex); |
||
202 | } |
||
203 | } |
||
204 | |||
205 | 44043 | jjdelcerro | private Evaluator disjoint(
|
206 | 43034 | jjdelcerro | 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 | 43020 | jjdelcerro | } |
214 | |||
215 | 43034 | jjdelcerro | public Evaluator disjoint(
|
216 | Geometry geometry, |
||
217 | IProjection projection, |
||
218 | FeatureStore store |
||
219 | ) { |
||
220 | 43020 | jjdelcerro | try {
|
221 | FeatureType featureType = store.getDefaultFeatureType(); |
||
222 | String geomName = featureType.getDefaultGeometryAttributeName();
|
||
223 | 43521 | jjdelcerro | ExpressionBuilder builder = store.createExpressionBuilder(); |
224 | 43034 | jjdelcerro | return this.disjoint(geometry, projection, featureType, geomName,builder); |
225 | 43020 | jjdelcerro | } catch (DataException ex) {
|
226 | throw new RuntimeException("Can't create disjoint evaluator.",ex); |
||
227 | } |
||
228 | } |
||
229 | |||
230 | 44043 | jjdelcerro | private Evaluator overlaps(
|
231 | 43034 | jjdelcerro | 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 | 43020 | jjdelcerro | } |
239 | |||
240 | 43034 | jjdelcerro | public Evaluator overlaps(
|
241 | Geometry geometry, |
||
242 | IProjection projection, |
||
243 | FeatureStore store |
||
244 | ) { |
||
245 | 43020 | jjdelcerro | try {
|
246 | FeatureType featureType = store.getDefaultFeatureType(); |
||
247 | String geomName = featureType.getDefaultGeometryAttributeName();
|
||
248 | 43521 | jjdelcerro | ExpressionBuilder builder = store.createExpressionBuilder(); |
249 | 43034 | jjdelcerro | return this.overlaps(geometry, projection, featureType, geomName,builder); |
250 | 43020 | jjdelcerro | } catch (DataException ex) {
|
251 | throw new RuntimeException("Can't create overlaps evaluator.",ex); |
||
252 | } |
||
253 | } |
||
254 | |||
255 | 44043 | jjdelcerro | private Evaluator touches(
|
256 | 43034 | jjdelcerro | 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 | 43020 | jjdelcerro | } |
264 | |||
265 | 43034 | jjdelcerro | public Evaluator touches(
|
266 | Geometry geometry, |
||
267 | IProjection projection, |
||
268 | FeatureStore store |
||
269 | ) { |
||
270 | 43020 | jjdelcerro | try {
|
271 | FeatureType featureType = store.getDefaultFeatureType(); |
||
272 | String geomName = featureType.getDefaultGeometryAttributeName();
|
||
273 | 43521 | jjdelcerro | ExpressionBuilder builder = store.createExpressionBuilder(); |
274 | 43034 | jjdelcerro | return this.touches(geometry, projection, featureType, geomName,builder); |
275 | 43020 | jjdelcerro | } catch (DataException ex) {
|
276 | throw new RuntimeException("Can't create touches evaluator.",ex); |
||
277 | } |
||
278 | } |
||
279 | |||
280 | 44043 | jjdelcerro | private Evaluator within(
|
281 | 43034 | jjdelcerro | 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 | 43020 | jjdelcerro | } |
289 | |||
290 | 43034 | jjdelcerro | public Evaluator within(
|
291 | Geometry geometry, |
||
292 | IProjection projection, |
||
293 | FeatureStore store |
||
294 | ) { |
||
295 | 43020 | jjdelcerro | try {
|
296 | FeatureType featureType = store.getDefaultFeatureType(); |
||
297 | String geomName = featureType.getDefaultGeometryAttributeName();
|
||
298 | 43521 | jjdelcerro | ExpressionBuilder builder = store.createExpressionBuilder(); |
299 | 43034 | jjdelcerro | return this.within(geometry, projection, featureType, geomName,builder); |
300 | 43020 | jjdelcerro | } catch (DataException ex) {
|
301 | throw new RuntimeException("Can't create within evaluator.",ex); |
||
302 | } |
||
303 | } |
||
304 | |||
305 | 44043 | jjdelcerro | private Evaluator equals(
|
306 | 43034 | jjdelcerro | 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 | 43020 | jjdelcerro | } |
314 | |||
315 | 43034 | jjdelcerro | public Evaluator equals(
|
316 | Geometry geometry, |
||
317 | IProjection projection, |
||
318 | FeatureStore store |
||
319 | ) { |
||
320 | 43020 | jjdelcerro | try {
|
321 | FeatureType featureType = store.getDefaultFeatureType(); |
||
322 | String geomName = featureType.getDefaultGeometryAttributeName();
|
||
323 | 43521 | jjdelcerro | ExpressionBuilder builder = store.createExpressionBuilder(); |
324 | 43034 | jjdelcerro | return this.equals(geometry, projection, featureType, geomName,builder); |
325 | 43020 | jjdelcerro | } catch (DataException ex) {
|
326 | throw new RuntimeException("Can't create equals evaluator.",ex); |
||
327 | } |
||
328 | } |
||
329 | |||
330 | } |