如何利用jts将点云构造成一个多边形

背景

现有许多离散点,需要将其构造成一个外包多边


原理

利用JTS提供的Tin算法能力

 

实现:

Coordinate[] coordinates = new Coordinate[]{
				new Coordinate(0, 1),
				new Coordinate(3, 4),
				new Coordinate(1, 0),
				new Coordinate(2, 0),
				new Coordinate(2, 3),
				new Coordinate(1, 2),
				new Coordinate(3, 1),
				new Coordinate(1, 1),
				new Coordinate(2, 2)};
		
		/*Coordinate[] coordinates = new Coordinate[]{
				new Coordinate(0, 0),
				new Coordinate(1, 1),
				new Coordinate(2, 3)};*/
		GeometryFactory gf = new GeometryFactory();
		MultiPoint mp = gf.createMultiPoint(coordinates);
		ConformingDelaunayTriangulationBuilder builder = new ConformingDelaunayTriangulationBuilder();
	
		builder.setSites(mp);
		//实际为GeometryCollection(组成的geometry紧密相连)
		Geometry ts = builder.getTriangles(gf);
		
		//以0的距离进行缓冲(因为各多边形两两共边),生成一个多边形
		//此时则将点云构造成了多边形
		Geometry union = ts.buffer(0);
		String text = union.toText();
		System.out.println(text);





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值