版本
org.locationtech.jts:jts-core:1.19.0
鏈接: github文章來源地址http://www.zghlxwxcb.cn/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)]
文章來源:http://www.zghlxwxcb.cn/news/detail-740320.html
到了這里,關于JTS: 14 LineMerger 多線合并的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網!