对密集的点抽稀,保持点的均匀分布。
dis=1000;
double degToMeter = Math.PI * 6378137 / 180.0;//6378137赤道半径,一度对应赤道上的一米
int buf = (int) (dis * 1.0e7 / degToMeter);//1公里对应多少度
List spector = new LinkedList();
for (int kk = 0; kk < list.size(); kk++) {
Feature f = (Feature) list.get(kk).getData();
int x = (int) (f.getGeometry().getCoordinate().x * 1e7);
int y = (int) (f.getGeometry().getCoordinate().y * 1e7);
Pos cur = new Pos(x, y);
cur.setBuffer(buf);
if (spector.contains(cur)) {
fcdel.add(f);//删除点
} else {
spector.add(cur);
fc.add(f);//保留点
}
}
public class Pos {
public int x;
public int y;
private int buf;
public Pos(int x, int y) {
this.x = x;
this.y = y;
}
public void setBuffer(int buf) {
this.buf = buf;
}
public boolean equals(Object pt) {
if (pt instanceof Pos)
return (Math.abs(this.x - ((Pos) pt).x) <= buf && Math.abs(this.y
- ((Pos) pt).y) <= buf);
return false;
}
public int hashCode() {
return Integer.valueOf(x + "" + y);
}
}
注意:重写equal方法。