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