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 @ 43521
History | View | Annotate | Download (1.17 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 | 43521 | jjdelcerro | public Object call(Interpreter interpreter, Object[] args) throws Exception { |
17 | 43518 | jjdelcerro | Geometry geom = getGeom(args, 0);
|
18 | GeometryType type = geom.getGeometryType(); |
||
19 | if( type.isSubTypeOf(Geometry.TYPES.POINT)
|
||
20 | || type.isSubTypeOf(Geometry.TYPES.MULTIPOINT) ) { |
||
21 | return 0; |
||
22 | } |
||
23 | if( type.isSubTypeOf(Geometry.TYPES.CURVE)
|
||
24 | || type.isSubTypeOf(Geometry.TYPES.MULTICURVE) ) { |
||
25 | return 1; |
||
26 | } |
||
27 | if( type.isSubTypeOf(Geometry.TYPES.SURFACE)
|
||
28 | || type.isSubTypeOf(Geometry.TYPES.MULTISURFACE) ) { |
||
29 | return 2; |
||
30 | } |
||
31 | if( type.isSubTypeOf(Geometry.TYPES.SOLID) ) {
|
||
32 | return 3; |
||
33 | } |
||
34 | return -1; |
||
35 | 43512 | jjdelcerro | } |
36 | 43518 | jjdelcerro | |
37 | 43512 | jjdelcerro | } |