点抽稀算法

对密集的点抽稀,保持点的均匀分布。

dis=1000;
double degToMeter = Math.PI * 6378137 / 180.0;//6378137赤道半径。一弧度对应的弧长为111319米
int buf = (int) (dis * 1.0e7 / degToMeter);//1公里对应多少度

List<Pos> spector = new LinkedList<Pos>();
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方法。
 

  • 0
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 10
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值