Jts(Java Topology Suite)是关于GIS空间数据Java的API。
三角网的创建
Jts中创建Tin时,会自己添加新的点,不是太好(ArcGIS在创建Tin时也是会自己新建点的)
1、创建Delaunay三角网:
DelaunayTriangulationBuilder delaunayBuilder = new DelaunayTriangulationBuilder();
delaunayBuilder.setSites(coorList);
Geometry geo =delaunayBuilder.getEdges(new GeometryFactory());
2、创建Conforming Delaunay三角网
ConformingDelaunayTriangulationBuilder conformTriBuilder = new ConformingDelaunayTriangulationBuilder();
conformTriBuilder.setSites(geoFactory.createMultiPoint(coorList.toArray(new Coordinate[0])));
conformTriBuilder.setConstraints(geoFactory.createMultiLineString(lineStrings));
Geometry geo =delaunayBuilder.getEdges(newGeometryFactory());
注:还有一个ConformingDelaunayTriangulator,这个类里面包含了更多的方法。但是我们在创建的时候不用管这个类,直接用ConformingDelaunayTriangulationBuilder就好,因为在ConformingDelaunayTriangulationBuilder内部,它自己调用了ConformingDelaunayTriangulator。真正的Tin创建工作,都是交给ConformingDelaunayTriangulator的,ConformingDelaunayTriangulationBuilder给我们提供了一个更方便的接口。
ConformingDelaunayTriangulationBuilder部分源码:
3、创建Voronoi图
VoronoiDiagramBuilder voronoiBuilder = newVoronoiDiagramBuilder();
voronoiBuilder.setSites(coorList);
Geometry geo =voronoiBuilder.getDiagram(newGeometryFactory());