Statistics
| Revision:

root / trunk / libraries / libExpressions / src / main / java / org / gvsig / operators / Geometry.java @ 23299

History | View | Annotate | Download (1.79 KB)

1
package org.gvsig.operators;
2

    
3
import org.apache.bsf.BSFException;
4
import org.apache.bsf.BSFManager;
5
import org.gvsig.baseclasses.GraphicOperator;
6
import org.gvsig.baseclasses.Index;
7
import org.gvsig.expresions.EvalOperatorsTask;
8

    
9
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
10
import com.iver.cit.gvsig.exceptions.expansionfile.ExpansionFileReadException;
11
import com.iver.cit.gvsig.fmap.core.IGeometry;
12
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
13
import com.iver.cit.gvsig.fmap.layers.ReadableVectorial;
14

    
15
/**
16
 * @author Vicente Caballero Navarro
17
 */
18
public class Geometry extends GraphicOperator{
19

    
20
        public String addText(String s) {
21
                return s.concat(toString()+"()");
22
        }
23
        public double process(Index index) throws DriverIOException {
24
                return 0;
25
        }
26
        public IGeometry getGeometry(Index index) throws ExpansionFileReadException, ReadDriverException {
27
                ReadableVectorial adapter = getLayer().getSource();
28
                   IGeometry geom=adapter.getShape(index.get());
29
                   return geom;
30
        }
31
        public void eval(BSFManager interpreter) throws BSFException {
32
                interpreter.declareBean("jgeometry",this,Geometry.class);
33
//                interpreter.eval(ExpressionFieldExtension.BEANSHELL,null,-1,-1,"java.lang.Object geometry(){return geometry.getGeometry(indexRow);};");
34
                interpreter.exec(EvalOperatorsTask.JYTHON,null,-1,-1,"def geometry():\n" +
35
                                "  return jgeometry.getGeometry(indexRow)");
36
        }
37
        public String toString() {
38
                return "geometry";
39
        }
40
        public boolean isEnable() {
41
                return false;
42
        }
43
        public String getTooltip(){
44
                return "operator"+":  "+addText("")+"\n"+getDescription();
45
        }
46
        public String getDescription() {
47
        return  "returns" + ": " +
48
         "numeric_value" + "\n" +
49
         "description" + ": " +
50
        "Returns the geometry of this row.";
51
    }
52
}