-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimpleAttributeVectorFilter.java
57 lines (44 loc) · 1.16 KB
/
SimpleAttributeVectorFilter.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package es.udc.sextante.gridAnalysis.IRI;
import es.unex.sextante.dataObjects.IFeature;
import es.unex.sextante.dataObjects.IRecord;
import es.unex.sextante.dataObjects.vectorFilters.IVectorLayerFilter;
public class SimpleAttributeVectorFilter
implements
IVectorLayerFilter {
private int ATTRIB_IDX = -1;
private String OPERATION = "=";
private double VALUE = 0;
/**
*
* @param attr_idx
* @param operation Only "=", ">" or "<"
* @param value
*/
public SimpleAttributeVectorFilter(final int attr_idx, final String operation, final double value) {
ATTRIB_IDX = attr_idx;
OPERATION = operation.trim();
VALUE = value;
}
public boolean accept(final IFeature feature,
final int iIndex) {
boolean b = false;
IRecord record = feature.getRecord();
Object[] values = record.getValues();
//TODO Reconocer bien los tipos de los campos
double v = (Double)values[ATTRIB_IDX];
if (OPERATION.equals("=")){
if (v == VALUE){
b = true;
}
} else if (OPERATION.equals("<")){
if (v < VALUE){
b = true;
}
} else if (OPERATION.equals(">")){
if (v > VALUE){
b = true;
}
}
return b;
}
}