Revision 1260 org.gvsig.geoprocess/trunk/org.gvsig.geoprocess/org.gvsig.geoprocess.algorithm/org.gvsig.geoprocess.algorithm.buffer/src/main/java/org/gvsig/geoprocess/algorithm/buffer/FieldDistance.java
FieldDistance.java | ||
---|---|---|
33 | 33 |
public class FieldDistance extends AbstractDistance { |
34 | 34 |
|
35 | 35 |
private String attributeName = null; |
36 |
private int attributeIndex = -1; |
|
37 | 36 |
|
38 | 37 |
public FieldDistance(String attributeName) { |
39 | 38 |
this.attributeName = attributeName; |
40 | 39 |
} |
41 | 40 |
|
42 |
public FieldDistance(int attributeIndex) { |
|
43 |
this.attributeIndex = attributeIndex; |
|
44 |
} |
|
45 |
|
|
46 | 41 |
public double getBufferDistance(IProjection projection, int distanceUnits, int mapUnits) { |
47 | 42 |
double value = 0D; |
48 | 43 |
Object obj; |
49 |
if( this.attributeIndex<0 ) { |
|
50 |
obj = feature.get(attributeName); |
|
51 |
} else { |
|
52 |
obj = feature.get(attributeIndex); |
|
53 |
} |
|
44 |
obj = feature.get(attributeName); |
|
54 | 45 |
if (obj instanceof Number) { |
55 | 46 |
value = ((Number) obj).doubleValue(); |
56 | 47 |
} else { |
Also available in: Unified diff