版本
org.locationtech.jts:jts-core:1.19.0
链接: github文章来源地址https://www.toymoban.com/news/detail-740320.html
代码
public class GeometryLineMerger {
private static final GeometryFactory geometryFactory = new GeometryFactory();
private static final Logger LOGGER = LoggerFactory.getLogger(GeometryConvexHull.class);
private final WKTReader wktReader = new WKTReader();
private ArrayList<LineString> lineStrings = new ArrayList<>();
public static void main(String[] args) {
GeometryLineMerger geometryLineMerger = new GeometryLineMerger();
geometryLineMerger.init();
geometryLineMerger.test00();
}
/**
* 初始化数据
*/
public void init() {
lineStrings.add(geometryFactory.createLineString(new Coordinate[]{new Coordinate(14,8), new Coordinate(3, 8)}));
lineStrings.add(geometryFactory.createLineString(new Coordinate[]{new Coordinate(3,8), new Coordinate(8, 12)}));
lineStrings.add(geometryFactory.createLineString(new Coordinate[]{new Coordinate(8,12), new Coordinate(2, 10)}));
lineStrings.add(geometryFactory.createLineString(new Coordinate[]{new Coordinate(2,10), new Coordinate(0, 2)}));
lineStrings.add(geometryFactory.createLineString(new Coordinate[]{new Coordinate(0,2), new Coordinate(14, 6)}));
lineStrings.add(geometryFactory.createLineString(new Coordinate[]{new Coordinate(20, 8), new Coordinate(14,6)}));
lineStrings.add(geometryFactory.createLineString(new Coordinate[]{new Coordinate(20,8), new Coordinate(20, 12)}));
}
public void test00() {
LineMerger lineMerger = new LineMerger();
lineMerger.add(lineStrings);
Collection<?> collection = lineMerger.getMergedLineStrings();
LOGGER.info(collection.toString());
}
}
20:09:11.046 [main] INFO pers.stu.buff.GeometryConvexHull - [LINESTRING (14 8, 3 8, 8 12, 2 10, 0 2, 14 6, 20 8, 20 12)]
文章来源:https://www.toymoban.com/news/detail-740320.html
到了这里,关于JTS: 14 LineMerger 多线合并的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!