svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.expressionevaluator / org.gvsig.expressionevaluator.geometry / org.gvsig.expressionevaluator.geometry.lib / org.gvsig.expressionevaluator.geometry.lib.impl / src / main / java / org / gvsig / expressionevaluator / impl / function / spatial / STNumGeometriesFunction.java @ 47566
History | View | Annotate | Download (879 Bytes)
1 |
package org.gvsig.expressionevaluator.impl.function.spatial; |
---|---|
2 |
|
3 |
import org.apache.commons.lang3.Range; |
4 |
import org.gvsig.expressionevaluator.Interpreter; |
5 |
import org.gvsig.expressionevaluator.spi.AbstractGeometryFunction; |
6 |
import org.gvsig.fmap.geom.Geometry; |
7 |
import org.gvsig.fmap.geom.aggregate.Aggregate; |
8 |
|
9 |
public class STNumGeometriesFunction extends AbstractGeometryFunction { |
10 |
|
11 |
public STNumGeometriesFunction() {
|
12 |
super("OGC", "ST_NumGeometries", Range.is(1)); |
13 |
} |
14 |
|
15 |
@Override
|
16 |
public boolean allowConstantFolding() { |
17 |
return true; |
18 |
} |
19 |
|
20 |
@Override
|
21 |
public Object call(Interpreter interpreter, Object[] args) throws Exception { |
22 |
Geometry geom = getGeom(args, 0);
|
23 |
if( geom instanceof Aggregate ) { |
24 |
int r = ((Aggregate) geom).getPrimitivesNumber();
|
25 |
return r;
|
26 |
} |
27 |
return null; |
28 |
} |
29 |
|
30 |
} |