Revision 43 org.gvsig.sextante/trunk/org.gvsig.sextante.app/org.gvsig.sextante.app.algorithm/org.gvsig.sextante.app.algorithm.buffer/src/main/java/org/gvsig/sextante/app/algorithm/buffer/FieldDistance.java
FieldDistance.java | ||
---|---|---|
21 | 21 |
package org.gvsig.sextante.app.algorithm.buffer; |
22 | 22 |
|
23 | 23 |
import org.cresques.cts.IProjection; |
24 |
import org.gvsig.fmap.dal.feature.Feature; |
|
25 |
import org.gvsig.sextante.app.extension.core.MapTools; |
|
24 | 26 |
|
25 | 27 |
/** |
26 | 28 |
* Computes a constant size of each geometry built |
27 | 29 |
* @author <a href="mailto:nachobrodin@gmail.com">Nacho Brodin</a> |
28 | 30 |
*/ |
29 | 31 |
public class FieldDistance implements IDistance { |
30 |
|
|
32 |
private Feature feature = null; |
|
33 |
private int attributePosition = 0; |
|
34 |
|
|
35 |
public FieldDistance(int attributePosition) { |
|
36 |
this.attributePosition = attributePosition; |
|
37 |
} |
|
38 |
|
|
39 |
public void setFeature(Feature feature) { |
|
40 |
this.feature = feature; |
|
41 |
} |
|
42 |
|
|
31 | 43 |
/* |
32 | 44 |
* (non-Javadoc) |
33 | 45 |
* @see org.gvsig.sextante.app.algorithm.buffer.IDistance#getBufferDistance(double, org.cresques.cts.IProjection, int, int) |
34 | 46 |
*/ |
35 |
public double getBufferDistance(double distance, IProjection viewProj,
|
|
47 |
public double getBufferDistance(double distance, IProjection projection,
|
|
36 | 48 |
int distanceUnits, int mapUnits) { |
37 |
return 0; |
|
49 |
double attr = 0D; |
|
50 |
Object obj = feature.get(attributePosition); |
|
51 |
if(obj instanceof Double) |
|
52 |
attr = ((Double)obj).doubleValue(); |
|
53 |
else if(obj instanceof Integer) |
|
54 |
attr = ((Integer)obj).doubleValue(); |
|
55 |
else if(obj instanceof Float) |
|
56 |
attr = ((Float)obj).doubleValue(); |
|
57 |
else return 0; |
|
58 |
|
|
59 |
return MapTools.getInInternalUnits(attr, projection, distanceUnits, mapUnits); |
|
38 | 60 |
} |
39 | 61 |
|
40 | 62 |
} |
Also available in: Unified diff