svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.expressionevaluator / org.gvsig.expressionevaluator.lib / org.gvsig.expressionevaluator.lib.impl / src / main / java / org / gvsig / expressionevaluator / impl / function / spatial / STDimensionFunction.java @ 44009
History | View | Annotate | Download (1.25 KB)
1 | 43512 | jjdelcerro | package org.gvsig.expressionevaluator.impl.function.spatial; |
---|---|---|---|
2 | |||
3 | import org.apache.commons.lang3.Range; |
||
4 | 43521 | jjdelcerro | import org.gvsig.expressionevaluator.Interpreter; |
5 | 43512 | jjdelcerro | import org.gvsig.expressionevaluator.spi.AbstractFunction; |
6 | 43518 | jjdelcerro | import org.gvsig.fmap.geom.Geometry; |
7 | import org.gvsig.fmap.geom.type.GeometryType; |
||
8 | 43512 | jjdelcerro | |
9 | 43518 | jjdelcerro | public class STDimensionFunction extends AbstractFunction { |
10 | 43512 | jjdelcerro | |
11 | 43518 | jjdelcerro | public STDimensionFunction() {
|
12 | super("OGC", "ST_Dimension", Range.is(1)); |
||
13 | 43512 | jjdelcerro | } |
14 | 43518 | jjdelcerro | |
15 | 43512 | jjdelcerro | @Override
|
16 | 44009 | jjdelcerro | public boolean allowConstantFolding() { |
17 | return true; |
||
18 | } |
||
19 | |||
20 | @Override
|
||
21 | 43521 | jjdelcerro | public Object call(Interpreter interpreter, Object[] args) throws Exception { |
22 | 43518 | jjdelcerro | Geometry geom = getGeom(args, 0);
|
23 | GeometryType type = geom.getGeometryType(); |
||
24 | if( type.isSubTypeOf(Geometry.TYPES.POINT)
|
||
25 | || type.isSubTypeOf(Geometry.TYPES.MULTIPOINT) ) { |
||
26 | return 0; |
||
27 | } |
||
28 | if( type.isSubTypeOf(Geometry.TYPES.CURVE)
|
||
29 | || type.isSubTypeOf(Geometry.TYPES.MULTICURVE) ) { |
||
30 | return 1; |
||
31 | } |
||
32 | if( type.isSubTypeOf(Geometry.TYPES.SURFACE)
|
||
33 | || type.isSubTypeOf(Geometry.TYPES.MULTISURFACE) ) { |
||
34 | return 2; |
||
35 | } |
||
36 | if( type.isSubTypeOf(Geometry.TYPES.SOLID) ) {
|
||
37 | return 3; |
||
38 | } |
||
39 | return -1; |
||
40 | 43512 | jjdelcerro | } |
41 | 43518 | jjdelcerro | |
42 | 43512 | jjdelcerro | } |