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 @ 43518
History | View | Annotate | Download (1.09 KB)
1 |
package org.gvsig.expressionevaluator.impl.function.spatial; |
---|---|
2 |
|
3 |
import org.apache.commons.lang3.Range; |
4 |
import org.gvsig.expressionevaluator.spi.AbstractFunction; |
5 |
import org.gvsig.fmap.geom.Geometry; |
6 |
import org.gvsig.fmap.geom.type.GeometryType; |
7 |
|
8 |
public class STDimensionFunction extends AbstractFunction { |
9 |
|
10 |
public STDimensionFunction() {
|
11 |
super("OGC", "ST_Dimension", Range.is(1)); |
12 |
} |
13 |
|
14 |
@Override
|
15 |
public Object call(Object[] args) throws Exception { |
16 |
Geometry geom = getGeom(args, 0);
|
17 |
GeometryType type = geom.getGeometryType(); |
18 |
if( type.isSubTypeOf(Geometry.TYPES.POINT)
|
19 |
|| type.isSubTypeOf(Geometry.TYPES.MULTIPOINT) ) { |
20 |
return 0; |
21 |
} |
22 |
if( type.isSubTypeOf(Geometry.TYPES.CURVE)
|
23 |
|| type.isSubTypeOf(Geometry.TYPES.MULTICURVE) ) { |
24 |
return 1; |
25 |
} |
26 |
if( type.isSubTypeOf(Geometry.TYPES.SURFACE)
|
27 |
|| type.isSubTypeOf(Geometry.TYPES.MULTISURFACE) ) { |
28 |
return 2; |
29 |
} |
30 |
if( type.isSubTypeOf(Geometry.TYPES.SOLID) ) {
|
31 |
return 3; |
32 |
} |
33 |
return -1; |
34 |
} |
35 |
|
36 |
} |