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