Revision 43017
tags/org.gvsig.desktop-2.0.157/org.gvsig.desktop.library/org.gvsig.tools.evaluator.sqljep/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
|
3 |
<modelVersion>4.0.0</modelVersion> |
|
4 |
<artifactId>org.gvsig.tools.evaluator.sqljep</artifactId> |
|
5 |
<name>${project.artifactId}</name> |
|
6 |
|
|
7 |
<parent> |
|
8 |
<groupId>org.gvsig</groupId> |
|
9 |
<artifactId>org.gvsig.desktop.library</artifactId> |
|
10 |
<version>2.0.157</version> |
|
11 |
</parent> |
|
12 |
|
|
13 |
<dependencies> |
|
14 |
<dependency> |
|
15 |
<groupId>org.gvsig</groupId> |
|
16 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
17 |
<scope>compile</scope> |
|
18 |
</dependency> |
|
19 |
<dependency> |
|
20 |
<groupId>org.gvsig</groupId> |
|
21 |
<artifactId>org.gvsig.fmap.geometry.api</artifactId> |
|
22 |
<scope>compile</scope> |
|
23 |
</dependency> |
|
24 |
<dependency> |
|
25 |
<groupId>org.slf4j</groupId> |
|
26 |
<artifactId>slf4j-api</artifactId> |
|
27 |
<scope>compile</scope> |
|
28 |
</dependency> |
|
29 |
<dependency> |
|
30 |
<groupId>net.sf</groupId> |
|
31 |
<artifactId>sqljep</artifactId> |
|
32 |
<scope>compile</scope> |
|
33 |
</dependency> |
|
34 |
</dependencies> |
|
35 |
|
|
36 |
<build> |
|
37 |
<plugins> |
|
38 |
|
|
39 |
<!-- TODO: MAKE TESTS WORK AND REMOVE THIS OPTION --> |
|
40 |
<plugin> |
|
41 |
<groupId>org.apache.maven.plugins</groupId> |
|
42 |
<artifactId>maven-surefire-plugin</artifactId> |
|
43 |
<configuration> |
|
44 |
<skipTests>true</skipTests> |
|
45 |
</configuration> |
|
46 |
</plugin> |
|
47 |
|
|
48 |
</plugins> |
|
49 |
</build> |
|
50 |
|
|
51 |
</project> |
|
0 | 52 |
tags/org.gvsig.desktop-2.0.157/org.gvsig.desktop.library/org.gvsig.tools.evaluator.sqljep/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.tools.evaluator.sqljep.SQLJEPLibrary |
tags/org.gvsig.desktop-2.0.157/org.gvsig.desktop.library/org.gvsig.tools.evaluator.sqljep/src/main/java/org/gvsig/tools/evaluator/sqljep/SQLJEPEvaluator.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
package org.gvsig.tools.evaluator.sqljep; |
|
25 |
|
|
26 |
import java.math.BigDecimal; |
|
27 |
import java.util.Map; |
|
28 |
import java.util.Map.Entry; |
|
29 |
|
|
30 |
import org.gvsig.tools.evaluator.EvaluatorData; |
|
31 |
import org.gvsig.tools.evaluator.EvaluatorException; |
|
32 |
import org.gvsig.tools.evaluator.EvaluatorFieldsInfo; |
|
33 |
import org.gvsig.tools.evaluator.EvaluatorParseException; |
|
34 |
import org.gvsig.tools.evaluator.EvaluatorWithDescriptions; |
|
35 |
import org.gvsig.tools.evaluator.sqljep.function.Boundary; |
|
36 |
import org.gvsig.tools.evaluator.sqljep.function.Equals; |
|
37 |
import org.gvsig.tools.evaluator.sqljep.function.GeomFromText; |
|
38 |
import org.gvsig.tools.evaluator.sqljep.function.Intersects; |
|
39 |
import org.gvsig.tools.evaluator.sqljep.function.Overlaps; |
|
40 |
import org.gvsig.tools.persistence.Persistent; |
|
41 |
import org.gvsig.tools.persistence.PersistentState; |
|
42 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
43 |
|
|
44 |
import org.medfoster.sqljep.ParseException; |
|
45 |
import org.medfoster.sqljep.RowJEP; |
|
46 |
import org.slf4j.Logger; |
|
47 |
import org.slf4j.LoggerFactory; |
|
48 |
|
|
49 |
public class SQLJEPEvaluator extends RowJEP |
|
50 |
implements EvaluatorWithDescriptions, Persistent { |
|
51 |
|
|
52 |
private static final Logger logger = |
|
53 |
LoggerFactory.getLogger(SQLJEPEvaluator.class); |
|
54 |
|
|
55 |
public static final String TODATE_FUNCTION_NAME = "to_timestamp"; |
|
56 |
|
|
57 |
// private String expresion; |
|
58 |
private EvaluatorData data; |
|
59 |
private boolean not_parsed; |
|
60 |
|
|
61 |
|
|
62 |
public SQLJEPEvaluator(String expresion) { |
|
63 |
|
|
64 |
super(expresion); |
|
65 |
// this.expresion = expresion; |
|
66 |
this.data = null; |
|
67 |
not_parsed = true; |
|
68 |
} |
|
69 |
|
|
70 |
public String getName() { |
|
71 |
return "SQLJEP(" + expression + ")"; |
|
72 |
} |
|
73 |
|
|
74 |
public String getSQL() { |
|
75 |
return expression; |
|
76 |
} |
|
77 |
|
|
78 |
public String getDescription() { |
|
79 |
return "SQLJEP-based evaluator"; |
|
80 |
} |
|
81 |
|
|
82 |
/* |
|
83 |
public EvaluatorFieldValue[] getFieldValues(String name) { |
|
84 |
return null; |
|
85 |
} |
|
86 |
*/ |
|
87 |
|
|
88 |
public Object evaluate(EvaluatorData data) throws EvaluatorException { |
|
89 |
this.data = data; |
|
90 |
Object value = null; |
|
91 |
try { |
|
92 |
if (not_parsed) { |
|
93 |
this.parseExpression(); |
|
94 |
not_parsed = false; |
|
95 |
} |
|
96 |
} catch (ParseException e) { |
|
97 |
/* |
|
98 |
* Notify parse exception |
|
99 |
*/ |
|
100 |
throw new EvaluatorParseException(e); |
|
101 |
} |
|
102 |
|
|
103 |
try { |
|
104 |
value = this.getValue(); |
|
105 |
} catch (Exception e) { |
|
106 |
/* |
|
107 |
* Notify evaluation exception |
|
108 |
* (catching also runtime exceptions) |
|
109 |
*/ |
|
110 |
throw new EvaluatorException(e); |
|
111 |
} |
|
112 |
this.data = null; |
|
113 |
return value; |
|
114 |
} |
|
115 |
|
|
116 |
/* |
|
117 |
public int findColumn(String name) { |
|
118 |
return -1; |
|
119 |
} |
|
120 |
*/ |
|
121 |
|
|
122 |
/* |
|
123 |
public Comparable getColumnObject(int arg0) throws ParseException { |
|
124 |
return null; |
|
125 |
} |
|
126 |
*/ |
|
127 |
|
|
128 |
public Entry getVariable(String name) throws ParseException { |
|
129 |
return new MyEntry(name); |
|
130 |
} |
|
131 |
|
|
132 |
@Override |
|
133 |
public void saveToState(PersistentState ps) throws PersistenceException { |
|
134 |
ps.set("expression", this.expression); |
|
135 |
} |
|
136 |
|
|
137 |
@Override |
|
138 |
public void loadFromState(PersistentState ps) throws PersistenceException { |
|
139 |
this.clear(); |
|
140 |
this.expression = ps.getString("expression"); |
|
141 |
} |
|
142 |
|
|
143 |
private class MyEntry implements Map.Entry { |
|
144 |
private String key; |
|
145 |
|
|
146 |
public MyEntry(String key) { |
|
147 |
this.key = key; |
|
148 |
} |
|
149 |
|
|
150 |
public Object getKey() { |
|
151 |
return this.key; |
|
152 |
} |
|
153 |
|
|
154 |
public Object getValue() { |
|
155 |
|
|
156 |
Object resp = null; |
|
157 |
|
|
158 |
if (data.hasDataValue(key)) { |
|
159 |
resp = data.getDataValue(key); |
|
160 |
resp = fixDecimal(resp); |
|
161 |
return resp; |
|
162 |
} |
|
163 |
resp = data.getDataValue(key);; |
|
164 |
resp = fixDecimal(resp); |
|
165 |
return resp; |
|
166 |
} |
|
167 |
|
|
168 |
/** |
|
169 |
* @param resp |
|
170 |
* @return |
|
171 |
*/ |
|
172 |
private Object fixDecimal(Object obj) { |
|
173 |
|
|
174 |
if (obj instanceof Double) { |
|
175 |
Double dou = (Double) obj; |
|
176 |
String doustr = Double.toString(dou); |
|
177 |
return new BigDecimal(doustr); |
|
178 |
} else { |
|
179 |
if (obj instanceof Float) { |
|
180 |
Float flo = (Float) obj; |
|
181 |
String flostr = Float.toString(flo); |
|
182 |
return new BigDecimal(flostr); |
|
183 |
} else { |
|
184 |
return obj; |
|
185 |
} |
|
186 |
} |
|
187 |
} |
|
188 |
|
|
189 |
public Object setValue(Object arg0) { |
|
190 |
return null; |
|
191 |
} |
|
192 |
|
|
193 |
} |
|
194 |
|
|
195 |
public EvaluatorFieldsInfo getFieldsInfo() { |
|
196 |
// TODO Auto-generated method stub |
|
197 |
return null; |
|
198 |
} |
|
199 |
|
|
200 |
private static Description[] available_operators; |
|
201 |
private static Description[] available_functions; |
|
202 |
|
|
203 |
public Description[] getAvailableOperators() { |
|
204 |
|
|
205 |
if (available_operators == null) { |
|
206 |
available_operators = new Description[] { |
|
207 |
|
|
208 |
new DefaultDescription( |
|
209 |
"+", |
|
210 |
"Returns the sum (addition) of the left operand and" |
|
211 |
+ " the right operand.", |
|
212 |
" + ", |
|
213 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_NUMBER), |
|
214 |
new DefaultDescription( |
|
215 |
"-", |
|
216 |
"Returns the difference (subtraction) of the left operand minus" |
|
217 |
+ " the right operand. It can be used as unary operator to" |
|
218 |
+ " change the sign of the right operand.", |
|
219 |
" - ", |
|
220 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_NUMBER), |
|
221 |
new DefaultDescription( |
|
222 |
"*", |
|
223 |
"Returns the product (multiplication) of the left operand by" |
|
224 |
+ " the right operand.", |
|
225 |
" * ", |
|
226 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_NUMBER), |
|
227 |
new DefaultDescription( |
|
228 |
"/", |
|
229 |
"Returns the division of the left operand by" |
|
230 |
+ " the right operand.", |
|
231 |
" / ", |
|
232 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_NUMBER), |
|
233 |
new DefaultDescription( |
|
234 |
">", |
|
235 |
"Returns TRUE if the left operand is greater than " |
|
236 |
+ "the right operand; FALSE otherwise.", |
|
237 |
" > ", |
|
238 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_NUMBER |
|
239 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_STRING |
|
240 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME |
|
241 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_BOOLEAN), |
|
242 |
new DefaultDescription( |
|
243 |
"<", |
|
244 |
"Returns TRUE if the left operand is smaller" |
|
245 |
+ " than the right operand; FALSE otherwise.", |
|
246 |
" < ", |
|
247 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_NUMBER |
|
248 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_STRING |
|
249 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME |
|
250 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_BOOLEAN), |
|
251 |
new DefaultDescription( |
|
252 |
">=", |
|
253 |
"Returns TRUE if the left operand is greater or " |
|
254 |
+ "equal to the right operand; FALSE otherwise.", |
|
255 |
" >= ", |
|
256 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_NUMBER |
|
257 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_STRING |
|
258 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME |
|
259 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_BOOLEAN), |
|
260 |
new DefaultDescription( |
|
261 |
"<=", |
|
262 |
"Returns TRUE if the left operand is less or " |
|
263 |
+ "equal to the right operand; FALSE otherwise.", |
|
264 |
" <= ", |
|
265 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_NUMBER |
|
266 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_STRING |
|
267 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME |
|
268 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_BOOLEAN), |
|
269 |
new DefaultDescription( |
|
270 |
"=", |
|
271 |
"Returns TRUE if the left operand equals " |
|
272 |
+ "the right operand; FALSE otherwise.", |
|
273 |
" = ", |
|
274 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_NUMBER |
|
275 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_STRING |
|
276 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME |
|
277 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_BOOLEAN), |
|
278 |
new DefaultDescription( |
|
279 |
"!=", |
|
280 |
"Returns TRUE if the left operand is not equal to " |
|
281 |
+ "the right operand; FALSE otherwise.", |
|
282 |
" != ", |
|
283 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_NUMBER |
|
284 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_STRING |
|
285 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME |
|
286 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_BOOLEAN), |
|
287 |
new DefaultDescription( |
|
288 |
"And", |
|
289 |
"Returns TRUE if both operands are TRUE" |
|
290 |
+ "; FALSE otherwise.", |
|
291 |
" and <Right_value>", |
|
292 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_BOOLEAN), |
|
293 |
new DefaultDescription( |
|
294 |
"Or", |
|
295 |
"Returns TRUE if the left operand is TRUE or the " |
|
296 |
+ "right operand is TRUE; FALSE otherwise.", |
|
297 |
" or ", |
|
298 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_BOOLEAN), |
|
299 |
new DefaultDescription( |
|
300 |
"Not", |
|
301 |
"Returns the logical inverse of the right operand: TRUE if the right " |
|
302 |
+ "operand is FALSE; FALSE otherwise.", |
|
303 |
"not ", |
|
304 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_BOOLEAN), |
|
305 |
new DefaultDescription( |
|
306 |
"In", |
|
307 |
"Returns TRUE if the left operand equals one of the comma-separated" |
|
308 |
+ " values; FALSE otherwise.", |
|
309 |
" in ( <Comma_separated_values> )", |
|
310 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_NUMBER |
|
311 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_STRING |
|
312 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME |
|
313 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_BOOLEAN), |
|
314 |
new DefaultDescription( |
|
315 |
"Between", |
|
316 |
"Returns TRUE if the left operand is greater or equal than " + |
|
317 |
"the first right operand and less or equal than the second " + |
|
318 |
"right operand; FALSE otherwise.", |
|
319 |
" between <Right_value_1> and <Right_value_2>", |
|
320 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_NUMBER |
|
321 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_STRING |
|
322 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME |
|
323 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_BOOLEAN), |
|
324 |
new DefaultDescription( |
|
325 |
"Like", |
|
326 |
"Returns TRUE if the left operand matches the pattern expressed " + |
|
327 |
"by the right operand; FALSE otherwise. Use '%' as wildcard.", |
|
328 |
" like <Right_value>", |
|
329 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_STRING), |
|
330 |
new DefaultDescription( |
|
331 |
"Is Null", |
|
332 |
"Returns TRUE if the left operand has NULL value;" + |
|
333 |
" FALSE otherwise.", |
|
334 |
" is null", |
|
335 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_NUMBER |
|
336 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_STRING |
|
337 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME |
|
338 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_BOOLEAN), |
|
339 |
new DefaultDescription( |
|
340 |
"Is Not Null", |
|
341 |
"Returns TRUE if the left operand does not have NULL value;" + |
|
342 |
" FALSE otherwise.", |
|
343 |
" is not null", |
|
344 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_NUMBER |
|
345 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_STRING |
|
346 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME |
|
347 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_BOOLEAN) |
|
348 |
|
|
349 |
|
|
350 |
|
|
351 |
}; |
|
352 |
} |
|
353 |
return available_operators; |
|
354 |
} |
|
355 |
|
|
356 |
|
|
357 |
public Description[] getAvailableFunctions() { |
|
358 |
|
|
359 |
if (available_functions == null) { |
|
360 |
available_functions = new Description[] { |
|
361 |
|
|
362 |
new DefaultDescription( |
|
363 |
"Equals", |
|
364 |
"Returns TRUE if the two input values are equal; " |
|
365 |
+ "FALSE otherwise.", |
|
366 |
Equals.NAME + "( <Value_1> , <Value_2> )", |
|
367 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_NUMBER |
|
368 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_STRING |
|
369 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME |
|
370 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_GEOMETRY), |
|
371 |
new DefaultDescription( |
|
372 |
GeomFromText.NAME, |
|
373 |
"Returns the geometry object equivalent to the " |
|
374 |
+ "input WKT string (single quotes).", |
|
375 |
GeomFromText.NAME + "( <Geometry_in_WKT> )", |
|
376 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_STRING |
|
377 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_GEOMETRY), |
|
378 |
new DefaultDescription( |
|
379 |
"Intersects", |
|
380 |
"Returns TRUE if the two input geometries intersect; " |
|
381 |
+ "FALSE otherwise.", |
|
382 |
Intersects.NAME + "( <Geometry_1> , <Geometry_2> )", |
|
383 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_GEOMETRY), |
|
384 |
new DefaultDescription( |
|
385 |
"Overlaps", |
|
386 |
"Returns TRUE if the two input geometries overlap; " |
|
387 |
+ "FALSE otherwise. Geometries overlap when they have some but " |
|
388 |
+ "not all points in common, they have the same dimension, " |
|
389 |
+ "and the intersection of the interiors of the two " |
|
390 |
+ "geometries has the same dimension as the " |
|
391 |
+ "geometries themselves.", |
|
392 |
Overlaps.NAME + "( <Geometry_1> , <Geometry_2> )", |
|
393 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_GEOMETRY), |
|
394 |
new DefaultDescription( |
|
395 |
"Boundary", |
|
396 |
"Returns a geometry which is the bounding box of the " |
|
397 |
+ "input geometry.", |
|
398 |
Boundary.NAME + "( <Geometry> )", |
|
399 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_GEOMETRY), |
|
400 |
new DefaultDescription( |
|
401 |
"To_timestamp", |
|
402 |
"Converts the input value to the timestamp type.", |
|
403 |
"to_timestamp( <Value> )", |
|
404 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME), |
|
405 |
// =============================================== |
|
406 |
// =============================================== |
|
407 |
// =============================================== |
|
408 |
|
|
409 |
new DefaultDescription( |
|
410 |
"Abs", |
|
411 |
"Returns the absolute value of the input numeric value.", |
|
412 |
"abs( <Numeric_value> )", |
|
413 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_NUMBER), |
|
414 |
new DefaultDescription( |
|
415 |
"Power", |
|
416 |
"Takes two numeric inputs and returns numeric result as " |
|
417 |
+ "first argument raised to second argument.", |
|
418 |
"power( <Base> , <Exponent> )", |
|
419 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_NUMBER), |
|
420 |
new DefaultDescription( |
|
421 |
"Mod", |
|
422 |
"Returns the remainder of the first argument divided by " |
|
423 |
+ "the second argument.", |
|
424 |
"mod( <Numeric_value_1> , <Numeric_value_2> )", |
|
425 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_NUMBER), |
|
426 |
new DefaultDescription( |
|
427 |
"Substr", |
|
428 |
"Returns a substring of the first argument, starting at " |
|
429 |
+ "the character indicated by the second argument. " |
|
430 |
+ "The optional third argument indicates the length " |
|
431 |
+ "of the result.", |
|
432 |
"substr( <String> , <Start_index> [ , <Length> ] )", |
|
433 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_STRING), |
|
434 |
new DefaultDescription( |
|
435 |
"Sign", |
|
436 |
"Returns 1 for positive input values, -1 for negative values" |
|
437 |
+ " and 0 when input is 0.", |
|
438 |
"sign( <Numeric_value> )", |
|
439 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_NUMBER), |
|
440 |
new DefaultDescription( |
|
441 |
"Ceil", |
|
442 |
"Returns the smallest whole number greater than or equal to " |
|
443 |
+ "the input numeric value.", |
|
444 |
"ceil( <Numeric_value> )", |
|
445 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_NUMBER), |
|
446 |
new DefaultDescription( |
|
447 |
"Floor", |
|
448 |
"Returns the largest whole number equal to or less than " |
|
449 |
+ "the input numeric value.", |
|
450 |
"floor( <Numeric_value> )", |
|
451 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_NUMBER), |
|
452 |
new DefaultDescription( |
|
453 |
"Trunc", |
|
454 |
"Returns the first argument truncated to as many decimal " |
|
455 |
+ "places as indicated by the second optional argument " |
|
456 |
+ "(defaults to zero).", |
|
457 |
"trunc( <Numeric_value> [ , <Integer_value> ] )", |
|
458 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_NUMBER), |
|
459 |
new DefaultDescription( |
|
460 |
"Round", |
|
461 |
"Returns the first argument rounded to as many places " |
|
462 |
+ "to the right of the decimal point as " |
|
463 |
+ "indicated by the second optional argument " |
|
464 |
+ "(defaults to zero).", |
|
465 |
"round( <Numeric_value> [ , <Integer_value> ] )", |
|
466 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_NUMBER), |
|
467 |
new DefaultDescription( |
|
468 |
"Length", |
|
469 |
"Returns the length (number of characters) of the " |
|
470 |
+ "input string.", |
|
471 |
"length( <String> )", |
|
472 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_STRING), |
|
473 |
new DefaultDescription( |
|
474 |
"Concat", |
|
475 |
"Returns the concatenation of the two input strings.", |
|
476 |
"concat( <String_1> , <String_2> )", |
|
477 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_STRING), |
|
478 |
new DefaultDescription( |
|
479 |
"Instr", |
|
480 |
"Searches for a string using some parameters (similar to " + |
|
481 |
"same function in Oracle).", |
|
482 |
"instr( <String_1> , <String_2> , <Int_1> , <Int_2> )", |
|
483 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_STRING), |
|
484 |
new DefaultDescription( |
|
485 |
"Trim", |
|
486 |
"Removes all leading and trailing spaces from the input" + |
|
487 |
" string.", |
|
488 |
"trim( <String> )", |
|
489 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_STRING), |
|
490 |
new DefaultDescription( |
|
491 |
"Rtrim", |
|
492 |
"Removes all trailing (right-hand) spaces from " + |
|
493 |
"the input string.", |
|
494 |
"Rtrim( <String> )", |
|
495 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_STRING), |
|
496 |
new DefaultDescription( |
|
497 |
"Ltrim", |
|
498 |
"Removes all leading (left-hand) spaces from " + |
|
499 |
"the input string.", |
|
500 |
"Ltrim( <String> )", |
|
501 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_STRING), |
|
502 |
new DefaultDescription( |
|
503 |
"Rpad", |
|
504 |
"Appends <String_2> to <String_1> as many times as needed to reach " + |
|
505 |
"length <L>. <String_2> defaults to a white space.", |
|
506 |
"rpad( <String_1> , <L> [ , <String_2> ] )", |
|
507 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_STRING), |
|
508 |
new DefaultDescription( |
|
509 |
"Lpad", |
|
510 |
"Prepends <String_2> to <String_1> as many times as needed to reach " + |
|
511 |
"length <L>. <String_2> defaults to a white space.", |
|
512 |
"lpad( <String_1> , <L> [ , <String_2> ] )", |
|
513 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_STRING), |
|
514 |
new DefaultDescription( |
|
515 |
"Upper", |
|
516 |
"Returns the input string in upper case.", |
|
517 |
"upper( <String> )", |
|
518 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_STRING), |
|
519 |
new DefaultDescription( |
|
520 |
"Lower", |
|
521 |
"Returns the input string in lower case.", |
|
522 |
"lower( <String> )", |
|
523 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_STRING), |
|
524 |
new DefaultDescription( |
|
525 |
"Translate", |
|
526 |
"Replaces characters following the order of the second and third" + |
|
527 |
" parameters.", |
|
528 |
"translate( <String_1> , <String_2> , <String_3> )", |
|
529 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_STRING), |
|
530 |
new DefaultDescription( |
|
531 |
"Replace", |
|
532 |
"Replaces in <String_1> the occurrences of <String_2>" + |
|
533 |
" with <String_3>.", |
|
534 |
"replace( <String_1> , <String_2> , <String_3> )", |
|
535 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_STRING), |
|
536 |
new DefaultDescription( |
|
537 |
"Initcap", |
|
538 |
"Sets the first character in each word to uppercase and the " + |
|
539 |
"rest to lowercase.", |
|
540 |
"initcap( <String> )", |
|
541 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_STRING), |
|
542 |
new DefaultDescription( |
|
543 |
"Value", |
|
544 |
"Returns the first non-null value from the input values. " + |
|
545 |
"Can be used to avoid null values in a field.", |
|
546 |
"value( <Value_1> , <Value_2> ... )", |
|
547 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_NUMBER |
|
548 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_STRING |
|
549 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME |
|
550 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_BOOLEAN), |
|
551 |
new DefaultDescription( |
|
552 |
"Decode", |
|
553 |
"This function works like a IF-THEN-ELSE block.", |
|
554 |
"decode( <Expression> , <Search> , <Result> ... )", |
|
555 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_NUMBER |
|
556 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_STRING |
|
557 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME |
|
558 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_BOOLEAN), |
|
559 |
new DefaultDescription( |
|
560 |
"To_char", |
|
561 |
"Converts the input value to string.", |
|
562 |
"to_char( <Value> )", |
|
563 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_NUMBER |
|
564 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_STRING |
|
565 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME |
|
566 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_BOOLEAN), |
|
567 |
new DefaultDescription( |
|
568 |
"To_number", |
|
569 |
"Converts the input string to a number.", |
|
570 |
"to_number( <String> )", |
|
571 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_NUMBER |
|
572 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_STRING), |
|
573 |
new DefaultDescription( |
|
574 |
"Imatch", |
|
575 |
"Returns a string representing the phonetic value of the " + |
|
576 |
"input string. Similar to Soundex function in Oracle.", |
|
577 |
"imatch( <String> )", |
|
578 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_STRING), |
|
579 |
new DefaultDescription( |
|
580 |
"Case", |
|
581 |
"This function works like a CASE-WHEN block.", |
|
582 |
"case( <Expression> ... )", |
|
583 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_BOOLEAN), |
|
584 |
|
|
585 |
|
|
586 |
new DefaultDescription( |
|
587 |
"Index", |
|
588 |
"Returns the position of a substring in a string.", |
|
589 |
"index( <String> , <Substring> )", |
|
590 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_STRING), |
|
591 |
new DefaultDescription( |
|
592 |
"Num", |
|
593 |
"Returns the numeric value of the input string.", |
|
594 |
"num( <String> )", |
|
595 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_BOOLEAN), |
|
596 |
new DefaultDescription( |
|
597 |
"Chr", |
|
598 |
"Converts the input value to string.", |
|
599 |
"chr( <Value> )", |
|
600 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_NUMBER |
|
601 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_STRING |
|
602 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME |
|
603 |
| EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_BOOLEAN), |
|
604 |
/* |
|
605 |
* date |
|
606 |
*/ |
|
607 |
new DefaultDescription( |
|
608 |
"Months_between", |
|
609 |
"Returns the number of months (as a float-point value) between " + |
|
610 |
"<Earliest_date> and <Latest_date>.", |
|
611 |
"months_between( <Latest_date> , <Earliest_date> )", |
|
612 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME), |
|
613 |
new DefaultDescription( |
|
614 |
"Add_months", |
|
615 |
"Adds a number of months to the input date.", |
|
616 |
"add_months( <Input_date> , <Number_of_months_integer>)", |
|
617 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME), |
|
618 |
new DefaultDescription( |
|
619 |
"Last_day", |
|
620 |
"Returns the date corresponding to the last day of the month " + |
|
621 |
"of the input date.", |
|
622 |
"last_day( <Input_date> )", |
|
623 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME), |
|
624 |
new DefaultDescription( |
|
625 |
"Next_day", |
|
626 |
"Returns the date of the first weekday named by the string " + |
|
627 |
"<Day_of_the_week> " + |
|
628 |
"that is later than <Input_date>.", |
|
629 |
"next_day( <Input_date> , <Day_of_the_week> )", |
|
630 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME), |
|
631 |
new DefaultDescription( |
|
632 |
"To_date", |
|
633 |
"Converts the input string to a date following the" + |
|
634 |
" optional format.", |
|
635 |
"to_date( <Input_string> [ , <Format> ] )", |
|
636 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME), |
|
637 |
new DefaultDescription( |
|
638 |
"Adddate", |
|
639 |
"Returns a date which is <Number_of_days> days after the" + |
|
640 |
" input date.", |
|
641 |
"adddate( <Input_date> , <Number_of_days> )", |
|
642 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME), |
|
643 |
new DefaultDescription( |
|
644 |
"Subdate", |
|
645 |
"Returns a date which is <Number_of_days> days before the" + |
|
646 |
" input date.", |
|
647 |
"subdate( <Input_date> , <Number_of_days> )", |
|
648 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME), |
|
649 |
new DefaultDescription( |
|
650 |
"Addtime", |
|
651 |
"Adds the second input time <Add_time> to the first " + |
|
652 |
"input time <Input_date>.", |
|
653 |
"addtime( <Input_time> , <Add_time> )", |
|
654 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME), |
|
655 |
new DefaultDescription( |
|
656 |
"Subtime", |
|
657 |
"Subtracts the second input time <Sub_time> from the first " + |
|
658 |
"input time <Input_date>.", |
|
659 |
"subtime( <Input_time> , <Sub_time> )", |
|
660 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME), |
|
661 |
new DefaultDescription( |
|
662 |
"Year", |
|
663 |
"Returns a numeric value representing the year of the " + |
|
664 |
"input date.", |
|
665 |
"year( <Input_date> )", |
|
666 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME), |
|
667 |
new DefaultDescription( |
|
668 |
"Month", |
|
669 |
"Returns a numeric value representing the month of the " + |
|
670 |
"input date.", |
|
671 |
"month( <Input_date> )", |
|
672 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME), |
|
673 |
new DefaultDescription( |
|
674 |
"Day", |
|
675 |
"Returns a numeric value representing the day of the " + |
|
676 |
"input date.", |
|
677 |
"day( <Input_date> )", |
|
678 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME), |
|
679 |
new DefaultDescription( |
|
680 |
"Dayofmonth", |
|
681 |
"Returns a numeric value between 1 and 31 corresponding to " + |
|
682 |
"the day of the month of the input date.", |
|
683 |
"dayofmonth( <Input_date> )", |
|
684 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME), |
|
685 |
new DefaultDescription( |
|
686 |
"Hour", |
|
687 |
"Returns a numeric value representing the number " + |
|
688 |
"of hours of the input time value.", |
|
689 |
"hour( <Time_value> )", |
|
690 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME), |
|
691 |
new DefaultDescription( |
|
692 |
"Minute", |
|
693 |
"Returns a numeric value representing the number " + |
|
694 |
"of minutes of the input time value.", |
|
695 |
"minute( <Time_value> )", |
|
696 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME), |
|
697 |
new DefaultDescription( |
|
698 |
"Second", |
|
699 |
"Returns a numeric value representing the number " + |
|
700 |
"of seconds of the input time value.", |
|
701 |
"second( <Time_value> )", |
|
702 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME), |
|
703 |
new DefaultDescription( |
|
704 |
"Microsecond", |
|
705 |
"Returns the number of microseconds of the input " + |
|
706 |
"timestamp value", |
|
707 |
"microseconds( <Timestamp_value> )", |
|
708 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME), |
|
709 |
new DefaultDescription( |
|
710 |
"Datediff", |
|
711 |
"Returns the number of days between the two input dates.", |
|
712 |
"datediff( <Date_1> , <Date_2> )", |
|
713 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME), |
|
714 |
new DefaultDescription( |
|
715 |
"Dayofweek", |
|
716 |
"Returns a numeric value between 1 (Monday) and 7 " + |
|
717 |
"(Sunday) corresponding to " + |
|
718 |
"the day of the week of the input date.", |
|
719 |
"dayofweek( <Input_date> )", |
|
720 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME), |
|
721 |
new DefaultDescription( |
|
722 |
"Weekofyear", |
|
723 |
"Returns a numeric value between 1 and 53 " + |
|
724 |
"corresponding to" + |
|
725 |
" the number of the week of the input date.", |
|
726 |
"weekofyear( <Input_date> )", |
|
727 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME), |
|
728 |
new DefaultDescription( |
|
729 |
"Dayname", |
|
730 |
"Returns the name of the day corresponding to the input" + |
|
731 |
" date ('Sunday', 'Monday', etc).", |
|
732 |
"dayname( <Input_date> )", |
|
733 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME), |
|
734 |
new DefaultDescription( |
|
735 |
"Monthname", |
|
736 |
"Returns the name of the month corresponding to the input" + |
|
737 |
" date ('January', 'February', etc).", |
|
738 |
"monthname( <Input_date> )", |
|
739 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME), |
|
740 |
new DefaultDescription( |
|
741 |
"Makedate", |
|
742 |
"Returns a date corresponding to the day denoted by " + |
|
743 |
"<Day_integer> (between 1 and 366) of the year " + |
|
744 |
"<Year_integer>.", |
|
745 |
"makedate( <Year_integer> , <Day_integer> )", |
|
746 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME), |
|
747 |
new DefaultDescription( |
|
748 |
"Maketime", |
|
749 |
"Creates a time value with the input number of" + |
|
750 |
" hours, minutes and seconds.", |
|
751 |
"maketime( <Hours> , <Minutes> , <Seconds> )", |
|
752 |
EvaluatorWithDescriptions.Description.DATATYPE_CATEGORY_DATETIME) |
|
753 |
|
|
754 |
}; |
|
755 |
} |
|
756 |
return available_functions; |
|
757 |
} |
|
758 |
|
|
759 |
// ======================================================= |
|
760 |
// ======================================================= |
|
761 |
// ======================================================= |
|
762 |
|
|
763 |
private class DefaultDescription implements Description{ |
|
764 |
|
|
765 |
private String name, desc, template; |
|
766 |
private int categories; |
|
767 |
|
|
768 |
public DefaultDescription( |
|
769 |
String name, String desc, String template, |
|
770 |
int datatype_categories) { |
|
771 |
|
|
772 |
this.name = name; |
|
773 |
this.desc = desc; |
|
774 |
this.template = template; |
|
775 |
this.categories = datatype_categories; |
|
776 |
} |
|
777 |
|
|
778 |
/* (non-Javadoc) |
|
779 |
* @see org.gvsig.tools.evaluator.EvaluatorWithDescriptions.Description#getName() |
|
780 |
*/ |
|
781 |
public String getName() { |
|
782 |
return name; |
|
783 |
} |
|
784 |
|
|
785 |
/* (non-Javadoc) |
|
786 |
* @see org.gvsig.tools.evaluator.EvaluatorWithDescriptions.Description#getDescription() |
|
787 |
*/ |
|
788 |
public String getDescription() { |
|
789 |
return desc; |
|
790 |
} |
|
791 |
|
|
792 |
/* (non-Javadoc) |
|
793 |
* @see org.gvsig.tools.evaluator.EvaluatorWithDescriptions.Description#getTemplate() |
|
794 |
*/ |
|
795 |
public String getTemplate() { |
|
796 |
return template; |
|
797 |
} |
|
798 |
|
|
799 |
/* (non-Javadoc) |
|
800 |
* @see org.gvsig.tools.evaluator.EvaluatorWithDescriptions.Description#getDataTypeCategories() |
|
801 |
*/ |
|
802 |
public int getDataTypeCategories() { |
|
803 |
return this.categories; |
|
804 |
} |
|
805 |
|
|
806 |
} |
|
807 |
} |
|
0 | 808 |
tags/org.gvsig.desktop-2.0.157/org.gvsig.desktop.library/org.gvsig.tools.evaluator.sqljep/src/main/java/org/gvsig/tools/evaluator/sqljep/SQLJEPLibrary.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
25 |
* |
|
26 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
27 |
* of the Valencian Government (CIT) |
|
28 |
* |
|
29 |
* This program is free software; you can redistribute it and/or |
|
30 |
* modify it under the terms of the GNU General Public License |
|
31 |
* as published by the Free Software Foundation; either version 2 |
|
32 |
* of the License, or (at your option) any later version. |
|
33 |
* |
|
34 |
* This program is distributed in the hope that it will be useful, |
|
35 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
36 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
37 |
* GNU General Public License for more details. |
|
38 |
* |
|
39 |
* You should have received a copy of the GNU General Public License |
|
40 |
* along with this program; if not, write to the Free Software |
|
41 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
42 |
* MA 02110-1301, USA. |
|
43 |
* |
|
44 |
*/ |
|
45 |
package org.gvsig.tools.evaluator.sqljep; |
|
46 |
|
|
47 |
import org.medfoster.sqljep.BaseJEP; |
|
48 |
import org.medfoster.sqljep.function.ToDate; |
|
49 |
|
|
50 |
import org.gvsig.fmap.geom.GeometryLibrary; |
|
51 |
import org.gvsig.tools.ToolsLibrary; |
|
52 |
import org.gvsig.tools.evaluator.sqljep.function.Boundary; |
|
53 |
import org.gvsig.tools.evaluator.sqljep.function.Equals; |
|
54 |
import org.gvsig.tools.evaluator.sqljep.function.GeomFromText; |
|
55 |
import org.gvsig.tools.evaluator.sqljep.function.Intersects; |
|
56 |
import org.gvsig.tools.evaluator.sqljep.function.OpenGISFunctions; |
|
57 |
import org.gvsig.tools.evaluator.sqljep.function.Overlaps; |
|
58 |
import org.gvsig.tools.library.AbstractLibrary; |
|
59 |
import org.gvsig.tools.library.LibraryException; |
|
60 |
|
|
61 |
public class SQLJEPLibrary extends AbstractLibrary { |
|
62 |
|
|
63 |
@Override |
|
64 |
public void doRegistration() { |
|
65 |
registerAsServiceOf(ToolsLibrary.class); |
|
66 |
require(GeometryLibrary.class); |
|
67 |
} |
|
68 |
|
|
69 |
@Override |
|
70 |
protected void doInitialize() throws LibraryException { |
|
71 |
} |
|
72 |
|
|
73 |
@Override |
|
74 |
protected void doPostInitialize() throws LibraryException { |
|
75 |
BaseJEP.addFunction(Equals.NAME, new Equals()); |
|
76 |
BaseJEP.addFunction(GeomFromText.NAME, new GeomFromText()); |
|
77 |
BaseJEP.addFunction(Intersects.NAME, new Intersects()); |
|
78 |
BaseJEP.addFunction(Overlaps.NAME, new Overlaps()); |
|
79 |
BaseJEP.addFunction(Boundary.NAME, new Boundary()); |
|
80 |
BaseJEP.addFunction(SQLJEPEvaluator.TODATE_FUNCTION_NAME, new ToDate()); |
|
81 |
OpenGISFunctions.registerFunctions(); |
|
82 |
} |
|
83 |
} |
|
0 | 84 |
tags/org.gvsig.desktop-2.0.157/org.gvsig.desktop.library/org.gvsig.tools.evaluator.sqljep/src/main/java/org/gvsig/tools/evaluator/sqljep/function/Equals.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
25 |
* |
|
26 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
27 |
* of the Valencian Government (CIT) |
|
28 |
* |
|
29 |
* This program is free software; you can redistribute it and/or |
|
30 |
* modify it under the terms of the GNU General Public License |
|
31 |
* as published by the Free Software Foundation; either version 2 |
|
32 |
* of the License, or (at your option) any later version. |
|
33 |
* |
|
34 |
* This program is distributed in the hope that it will be useful, |
|
35 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
36 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
37 |
* GNU General Public License for more details. |
|
38 |
* |
|
39 |
* You should have received a copy of the GNU General Public License |
|
40 |
* along with this program; if not, write to the Free Software |
|
41 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
42 |
* MA 02110-1301, USA. |
|
43 |
* |
|
44 |
*/ |
|
45 |
|
|
46 |
/* |
|
47 |
* AUTHORS (In addition to CIT): |
|
48 |
* 2008 IVER T.I {{Task}} |
|
49 |
*/ |
|
50 |
|
|
51 |
/** |
|
52 |
* |
|
53 |
*/ |
|
54 |
package org.gvsig.tools.evaluator.sqljep.function; |
|
55 |
|
|
56 |
import org.gvsig.fmap.geom.Geometry; |
|
57 |
import org.medfoster.sqljep.ASTFunNode; |
|
58 |
import org.medfoster.sqljep.JepRuntime; |
|
59 |
import org.medfoster.sqljep.ParseException; |
|
60 |
import org.medfoster.sqljep.function.PostfixCommand; |
|
61 |
|
|
62 |
/** |
|
63 |
* @author jmvivo |
|
64 |
* |
|
65 |
*/ |
|
66 |
public class Equals extends PostfixCommand { |
|
67 |
|
|
68 |
public static final String NAME = "equals"; |
|
69 |
|
|
70 |
final public int getNumberOfParameters() { |
|
71 |
return 2; |
|
72 |
} |
|
73 |
/* (non-Javadoc) |
|
74 |
* @see org.medfoster.sqljep.function.PostfixCommand#evaluate(org.medfoster.sqljep.ASTFunNode, org.medfoster.sqljep.JepRuntime) |
|
75 |
*/ |
|
76 |
public void evaluate(ASTFunNode node, JepRuntime runtime) |
|
77 |
throws ParseException { |
|
78 |
node.childrenAccept(runtime.ev, null); |
|
79 |
Comparable param2 = (Comparable)runtime.stack.pop(); |
|
80 |
Comparable param1 = (Comparable)runtime.stack.pop(); |
|
81 |
if (param1 == null || param2 == null) { |
|
82 |
runtime.stack.push(Boolean.FALSE); |
|
83 |
} else if ((param1 instanceof Geometry) |
|
84 |
&& (param2 instanceof Geometry)) { |
|
85 |
runtime.stack.push(new Boolean(isEquals((Geometry)param1, (Geometry)param2))); |
|
86 |
} else{ |
|
87 |
runtime.stack.push(new Boolean(param1.equals(param2))); |
|
88 |
} |
|
89 |
} |
|
90 |
|
|
91 |
private static boolean isEquals(Geometry g1, Geometry g2) throws ParseException { |
|
92 |
return (g1.equals(g2)); |
|
93 |
} |
|
94 |
|
|
95 |
} |
|
96 |
|
|
0 | 97 |
tags/org.gvsig.desktop-2.0.157/org.gvsig.desktop.library/org.gvsig.tools.evaluator.sqljep/src/main/java/org/gvsig/tools/evaluator/sqljep/function/Overlaps.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2013 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
23 |
*/ |
|
24 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
25 |
* |
|
26 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
27 |
* of the Valencian Government (CIT) |
|
28 |
* |
|
29 |
* This program is free software; you can redistribute it and/or |
|
30 |
* modify it under the terms of the GNU General Public License |
|
31 |
* as published by the Free Software Foundation; either version 2 |
|
32 |
* of the License, or (at your option) any later version. |
|
33 |
* |
|
34 |
* This program is distributed in the hope that it will be useful, |
|
35 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
36 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
37 |
* GNU General Public License for more details. |
|
38 |
* |
|
39 |
* You should have received a copy of the GNU General Public License |
|
40 |
* along with this program; if not, write to the Free Software |
|
41 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
42 |
* MA 02110-1301, USA. |
|
43 |
* |
|
44 |
*/ |
|
45 |
|
|
46 |
/* |
|
47 |
* AUTHORS (In addition to CIT): |
|
48 |
* 2008 IVER T.I. S.A. {{Task}} |
|
49 |
*/ |
|
50 |
|
|
51 |
package org.gvsig.tools.evaluator.sqljep.function; |
|
52 |
|
|
53 |
import org.gvsig.fmap.geom.Geometry; |
|
54 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
|
55 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
|
56 |
import org.medfoster.sqljep.ASTFunNode; |
|
57 |
import org.medfoster.sqljep.JepRuntime; |
|
58 |
import org.medfoster.sqljep.ParseException; |
|
59 |
import org.medfoster.sqljep.function.PostfixCommand; |
|
60 |
|
|
61 |
public class Overlaps extends PostfixCommand { |
|
62 |
|
|
63 |
public static final String NAME = "overlaps"; |
|
64 |
|
|
65 |
final public int getNumberOfParameters() { |
|
66 |
return 2; |
|
67 |
} |
|
68 |
|
|
69 |
/* (non-Javadoc) |
|
70 |
* @see org.medfoster.sqljep.function.PostfixCommand#evaluate(org.medfoster.sqljep.ASTFunNode, org.medfoster.sqljep.JepRuntime) |
|
71 |
*/ |
|
72 |
public void evaluate(ASTFunNode node, JepRuntime runtime) |
|
73 |
throws ParseException { |
|
74 |
node.childrenAccept(runtime.ev, null); |
|
75 |
Geometry geom1 = (Geometry)runtime.stack.pop(); |
|
76 |
Geometry geom2 = (Geometry)runtime.stack.pop(); |
|
77 |
try { |
|
78 |
runtime.stack.push( Boolean.valueOf(geom1.overlaps(geom2)) ); |
|
79 |
} catch (GeometryOperationNotSupportedException e) { |
|
80 |
throw new ParseException(NAME, e); |
|
81 |
} catch (GeometryOperationException e) { |
|
82 |
throw new ParseException(NAME, e); |
|
83 |
} |
|
84 |
} |
|
85 |
} |
|
0 | 86 |
tags/org.gvsig.desktop-2.0.157/org.gvsig.desktop.library/org.gvsig.tools.evaluator.sqljep/src/main/java/org/gvsig/tools/evaluator/sqljep/function/OpenGISFunctions.java | ||
---|---|---|
1 |
package org.gvsig.tools.evaluator.sqljep.function; |
|
2 |
|
|
3 |
import org.gvsig.fmap.geom.Geometry; |
|
4 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
5 |
import org.gvsig.fmap.geom.GeometryManager; |
|
6 |
import org.gvsig.fmap.geom.aggregate.Aggregate; |
|
7 |
import org.gvsig.fmap.geom.primitive.OrientablePrimitive; |
|
8 |
import org.gvsig.fmap.geom.primitive.Point; |
|
9 |
import org.gvsig.fmap.geom.type.GeometryType; |
|
10 |
import org.gvsig.tools.ToolsLocator; |
|
11 |
import org.gvsig.tools.dataTypes.CoercionException; |
|
12 |
import org.gvsig.tools.dataTypes.DataTypes; |
|
13 |
import org.medfoster.sqljep.ASTFunNode; |
|
14 |
import org.medfoster.sqljep.BaseJEP; |
|
15 |
import org.medfoster.sqljep.JepRuntime; |
|
16 |
import org.medfoster.sqljep.ParseException; |
|
17 |
import org.medfoster.sqljep.function.PostfixCommand; |
|
18 |
|
|
19 |
public class OpenGISFunctions { |
|
20 |
|
|
21 |
public static BaseFunction[] functions = { |
|
22 |
new ST_Distance(), |
|
23 |
new ST_Disjoint(), |
|
24 |
new ST_Touches(), |
|
25 |
new ST_Crosses(), |
|
26 |
new ST_Within(), |
|
27 |
new ST_Overlaps(), |
|
28 |
new ST_Contains(), |
|
29 |
new ST_Covers(), |
|
30 |
new ST_CoveredBy(), |
|
31 |
new ST_Intersects(), |
|
32 |
new ST_Centroid(), |
|
33 |
new ST_Area(), |
|
34 |
// new ST_Length(), |
|
35 |
// new ST_Boundary(), |
|
36 |
new ST_Buffer(), |
|
37 |
new ST_ConvexHull(), |
|
38 |
new ST_Intersection(), |
|
39 |
new ST_Difference(), |
|
40 |
new ST_Union(), |
|
41 |
new ST_AsText(), |
|
42 |
// new ST_AsBinary(), |
|
43 |
// new ST_SRID(), |
|
44 |
new ST_Dimension(), |
|
45 |
new ST_Envelope(), |
|
46 |
new ST_IsSimple(), |
|
47 |
// new ST_IsRing(), |
|
48 |
new ST_NumGeometries(), |
|
49 |
new ST_GeometryN(), |
|
50 |
new ST_NumPoints(), |
|
51 |
new ST_PointN(), |
|
52 |
new ST_StartPoint(), |
|
53 |
new ST_EndPoint(), |
|
54 |
new ST_X(), |
|
55 |
new ST_Y(), |
|
56 |
new ST_Z(), |
|
57 |
new ST_GeomFromText(), |
|
58 |
new ST_isValid() |
|
59 |
}; |
|
60 |
|
|
61 |
public static void registerFunctions() { |
|
62 |
for( int i=0; i<functions.length; i++ ) { |
|
63 |
BaseFunction f = functions[i]; |
|
64 |
BaseJEP.addFunction(f.getName(),f ); |
|
65 |
} |
|
66 |
} |
|
67 |
|
|
68 |
|
|
69 |
public static abstract class BaseFunction extends PostfixCommand { |
|
70 |
|
|
71 |
public String getName() { |
|
72 |
String name = this.getClass().getName(); |
|
73 |
int index = name.lastIndexOf("."); |
|
74 |
if ( index < 1 ) { |
|
75 |
return name; |
|
76 |
} |
|
77 |
return name.substring(index + 1); |
|
78 |
} |
|
79 |
|
|
80 |
public Geometry pop_geometry(JepRuntime runtime) |
|
81 |
throws ParseException { |
|
82 |
return (Geometry) runtime.stack.pop(); |
|
83 |
} |
|
84 |
|
|
85 |
public double pop_double(JepRuntime runtime) |
|
86 |
throws ParseException { |
|
87 |
Double value = null; |
|
88 |
try { |
|
89 |
value = (Double) ToolsLocator.getDataTypesManager().coerce( |
|
90 |
DataTypes.DOUBLE, runtime.stack.pop() |
|
91 |
); |
|
92 |
} catch (CoercionException ex) { |
|
93 |
throw new ParseException(this.getName(), ex); |
|
94 |
} |
|
95 |
return value.doubleValue(); |
|
96 |
} |
|
97 |
|
|
98 |
public int pop_int(JepRuntime runtime) |
|
99 |
throws ParseException { |
|
100 |
Integer value = null; |
|
101 |
try { |
|
102 |
value = (Integer) ToolsLocator.getDataTypesManager().coerce( |
|
103 |
DataTypes.INT, runtime.stack.pop() |
|
104 |
); |
|
105 |
} catch (CoercionException ex) { |
|
106 |
throw new ParseException(this.getName(), ex); |
|
107 |
} |
|
108 |
return value.intValue(); |
|
109 |
} |
|
110 |
|
|
111 |
public String pop_string(JepRuntime runtime) |
|
112 |
throws ParseException { |
|
113 |
String value = null; |
|
114 |
try { |
|
115 |
value = (String) ToolsLocator.getDataTypesManager().coerce( |
|
116 |
DataTypes.STRING, runtime.stack.pop() |
|
117 |
); |
|
118 |
} catch (CoercionException ex) { |
|
119 |
throw new ParseException(this.getName(), ex); |
|
120 |
} |
|
121 |
return value; |
|
122 |
} |
|
123 |
|
|
124 |
public void evaluate(ASTFunNode node, JepRuntime runtime) |
|
125 |
throws ParseException { |
|
126 |
try { |
|
127 |
Comparable value = this.evaluate(runtime); |
|
128 |
runtime.stack.push(value); |
|
129 |
} catch (Exception ex) { |
|
130 |
throw new ParseException(getName(), ex); |
|
131 |
} |
|
132 |
} |
|
133 |
|
|
134 |
public abstract Comparable evaluate(JepRuntime runtime) throws Exception; |
|
135 |
} |
|
136 |
|
|
137 |
public static abstract class Function_geom1_geom2 extends BaseFunction { |
|
138 |
|
|
139 |
final public int getNumberOfParameters() { |
|
140 |
return 2; |
|
141 |
} |
|
142 |
|
|
143 |
public Comparable evaluate(JepRuntime runtime) |
|
144 |
throws Exception { |
|
145 |
Geometry geom1 = pop_geometry(runtime); |
|
146 |
Geometry geom2 = pop_geometry(runtime); |
|
147 |
return evaluate(geom1, geom2); |
|
148 |
} |
|
149 |
|
|
150 |
public abstract Comparable evaluate(Geometry geom1, Geometry geom2) throws Exception; |
|
151 |
} |
|
152 |
|
|
153 |
public static abstract class Function_geom1 extends BaseFunction { |
|
154 |
|
|
155 |
final public int getNumberOfParameters() { |
|
156 |
return 1; |
|
157 |
} |
|
158 |
|
|
159 |
public Comparable evaluate(JepRuntime runtime) |
|
160 |
throws Exception { |
|
161 |
Geometry geom1 = pop_geometry(runtime); |
|
162 |
return evaluate(geom1); |
|
163 |
} |
|
164 |
|
|
165 |
public abstract Comparable evaluate(Geometry geom1) throws Exception; |
|
166 |
} |
|
167 |
|
|
168 |
public static abstract class Function_geom1_double extends BaseFunction { |
|
169 |
|
|
170 |
final public int getNumberOfParameters() { |
|
171 |
return 2; |
|
172 |
} |
|
173 |
|
|
174 |
public Comparable evaluate(JepRuntime runtime) |
|
175 |
throws Exception { |
|
176 |
Geometry geom1 = pop_geometry(runtime); |
|
177 |
double value = pop_double(runtime); |
|
178 |
return evaluate(geom1, value); |
|
179 |
} |
|
180 |
|
|
181 |
public abstract Comparable evaluate(Geometry geom1, double value) throws Exception; |
|
182 |
} |
|
183 |
|
|
184 |
public static abstract class Function_geom1_int extends BaseFunction { |
|
185 |
|
|
186 |
final public int getNumberOfParameters() { |
|
187 |
return 2; |
|
188 |
} |
|
189 |
|
|
190 |
public Comparable evaluate(JepRuntime runtime) |
|
191 |
throws Exception { |
|
192 |
Geometry geom1 = pop_geometry(runtime); |
|
193 |
int value = pop_int(runtime); |
|
194 |
return evaluate(geom1, value); |
|
195 |
} |
|
196 |
|
|
197 |
public abstract Comparable evaluate(Geometry geom1, int value) throws Exception; |
|
198 |
} |
|
199 |
|
|
200 |
public static abstract class Function_string extends BaseFunction { |
|
201 |
|
|
202 |
final public int getNumberOfParameters() { |
|
203 |
return 1; |
|
204 |
} |
|
205 |
|
|
206 |
public Comparable evaluate(JepRuntime runtime) |
|
207 |
throws Exception { |
|
208 |
String value = pop_string(runtime); |
|
209 |
return evaluate(value); |
|
210 |
} |
|
211 |
|
|
212 |
public abstract Comparable evaluate(String value) throws Exception; |
|
213 |
} |
|
214 |
|
|
215 |
public static class ST_Distance extends Function_geom1_geom2 { |
|
216 |
|
|
217 |
public Comparable evaluate(Geometry geom1, Geometry geom2) throws Exception { |
|
218 |
return Double.valueOf(geom1.distance(geom2)); |
|
219 |
} |
|
220 |
} |
|
221 |
|
|
222 |
public static class ST_Disjoint extends Function_geom1_geom2 { |
|
223 |
|
|
224 |
public Comparable evaluate(Geometry geom1, Geometry geom2) throws Exception { |
|
225 |
return Boolean.valueOf(geom1.disjoint(geom2)); |
|
226 |
} |
|
227 |
} |
|
228 |
|
|
229 |
public static class ST_Touches extends Function_geom1_geom2 { |
|
230 |
|
|
231 |
public Comparable evaluate(Geometry geom1, Geometry geom2) throws Exception { |
|
232 |
return Boolean.valueOf(geom1.touches(geom2)); |
|
233 |
} |
|
234 |
} |
|
235 |
|
|
236 |
public static class ST_Crosses extends Function_geom1_geom2 { |
|
237 |
|
|
238 |
public Comparable evaluate(Geometry geom1, Geometry geom2) throws Exception { |
|
239 |
return Boolean.valueOf(geom1.crosses(geom2)); |
|
240 |
} |
|
241 |
} |
|
242 |
|
|
243 |
public static class ST_Within extends Function_geom1_geom2 { |
|
244 |
|
|
245 |
public Comparable evaluate(Geometry geom1, Geometry geom2) throws Exception { |
|
246 |
return Boolean.valueOf(geom1.within(geom2)); |
|
247 |
} |
|
248 |
} |
|
249 |
|
|
250 |
public static class ST_Overlaps extends Function_geom1_geom2 { |
|
251 |
|
|
252 |
public Comparable evaluate(Geometry geom1, Geometry geom2) throws Exception { |
|
253 |
return Boolean.valueOf(geom1.overlaps(geom2)); |
|
254 |
} |
|
255 |
} |
|
256 |
|
|
257 |
public static class ST_Contains extends Function_geom1_geom2 { |
|
258 |
|
|
259 |
public Comparable evaluate(Geometry geom1, Geometry geom2) throws Exception { |
|
260 |
return Boolean.valueOf(geom1.contains(geom2)); |
|
261 |
} |
|
262 |
} |
|
263 |
|
|
264 |
public static class ST_Covers extends Function_geom1_geom2 { |
|
265 |
|
|
266 |
public Comparable evaluate(Geometry geom1, Geometry geom2) throws Exception { |
|
267 |
return Boolean.valueOf(geom1.covers(geom2)); |
|
268 |
} |
|
269 |
} |
|
270 |
|
|
271 |
public static class ST_CoveredBy extends Function_geom1_geom2 { |
|
272 |
|
|
273 |
public Comparable evaluate(Geometry geom1, Geometry geom2) throws Exception { |
|
274 |
return Boolean.valueOf(geom1.coveredBy(geom2)); |
|
275 |
} |
|
276 |
} |
|
277 |
|
|
278 |
public static class ST_Intersects extends Function_geom1_geom2 { |
|
279 |
|
|
280 |
public Comparable evaluate(Geometry geom1, Geometry geom2) throws Exception { |
|
281 |
return Boolean.valueOf(geom1.intersects(geom2)); |
|
282 |
} |
|
283 |
} |
|
284 |
|
|
285 |
public static class ST_Centroid extends Function_geom1 { |
|
286 |
|
|
287 |
public Comparable evaluate(Geometry geom1) throws Exception { |
|
288 |
return geom1.centroid(); |
|
289 |
} |
|
290 |
} |
|
291 |
|
|
292 |
public static class ST_Area extends Function_geom1 { |
|
293 |
|
|
294 |
public Comparable evaluate(Geometry geom1) throws Exception { |
|
295 |
return Double.valueOf(geom1.area()); |
|
296 |
} |
|
297 |
} |
|
298 |
|
|
299 |
// public static class ST_Length extends Function_geom1 { |
|
300 |
// |
|
301 |
// public Comparable evaluate(Geometry geom1, Geometry geom2) throws Exception { |
|
302 |
// return Double.valueOf(geom1.length()); |
|
303 |
// } |
|
304 |
// } |
|
305 |
// public static class ST_Boundary extends Function_geom1 { |
|
306 |
// |
|
307 |
// public Comparable evaluate(Geometry geom1) throws Exception { |
|
308 |
// return geom1.boundary(); |
|
309 |
// } |
|
310 |
// } |
|
311 |
public static class ST_Buffer extends Function_geom1_double { |
|
312 |
|
Also available in: Unified diff