Revision 23048 trunk/libraries/libTopology/src/org/gvsig/jts/SnapCoordinateList.java
SnapCoordinateList.java | ||
---|---|---|
60 | 60 |
* JTS coordinate list that uses snap to avoid consecutives coordinates at a |
61 | 61 |
* distance lower than the cluster tolerance. |
62 | 62 |
* |
63 |
* |
|
64 |
* FIXME There could be coordinates non consecutives at a distance slower than |
|
65 |
* snap tolerance. |
|
66 |
* |
|
63 | 67 |
* @author azabala |
64 | 68 |
* |
65 | 69 |
*/ |
... | ... | |
101 | 105 |
public void add(Coordinate coord, boolean allowRepeated) { |
102 | 106 |
// don't add duplicate coordinates |
103 | 107 |
if (!allowRepeated) { |
104 |
if (size() >= 1) { |
|
105 |
Coordinate last = (Coordinate) get(size() - 1); |
|
108 |
// with this code we only filter consecutive snapped points |
|
109 |
// if (size() >= 1) { |
|
110 |
// Coordinate last = (Coordinate) get(size() - 1); |
|
111 |
// if(SnapCGAlgorithms.snapEquals2D(last, coord, snapTolerance)) |
|
112 |
// return; |
|
113 |
// }//if |
|
114 |
int size = size(); |
|
115 |
/* |
|
116 |
If size == 1, we check the existing point, |
|
117 |
if size > 1, we dont check the first point (because closed geometries |
|
118 |
musnt snap the first and last point |
|
119 |
* */ |
|
120 |
if(size > 1){ |
|
121 |
for(int i = 1; i < size; i++){ |
|
122 |
Coordinate coordinate = (Coordinate) get(i); |
|
123 |
if(SnapCGAlgorithms.snapEquals2D(coordinate, coord, snapTolerance)) |
|
124 |
return; |
|
125 |
} |
|
126 |
}else if(size == 1){ |
|
127 |
Coordinate last = (Coordinate) get(0); |
|
106 | 128 |
if(SnapCGAlgorithms.snapEquals2D(last, coord, snapTolerance)) |
107 | 129 |
return; |
108 |
}//if
|
|
130 |
} |
|
109 | 131 |
}//if |
110 | 132 |
super.add(coord); |
111 | 133 |
} |
Also available in: Unified diff