zoukankan      html  css  js  c++  java
  • 多条道路合并

    在路网操作中,会遇到将首尾相连的多条道路合并成一条道路的情况,使用JTS中的LineMerger类,可以很好的完成这个操作,代码:


    WKTReader reader = new WKTReader();
    Geometry geom_1 = reader.read("LINESTRING (116.96832000000000562 36.64882000000000062, 116.96849000000000274 36.64882000000000062)");
    Geometry geom_2 = reader.read("LINESTRING (116.96849000000000274 36.64882000000000062, 116.96862000000000137 36.64882000000000062)");
    Geometry geom_3 = reader.read("LINESTRING (116.96862000000000137 36.64882000000000062, 116.96877999999999531 36.64880999999999744)");
    LineMerger lineMerger = new LineMerger();
    
    //添加几何对象不需要按照顺序,只要道路首尾坐标点重合即可
    lineMerger.add(geom_1);
    lineMerger.add(geom_2);
    lineMerger.add(geom_3);
    Collection mergedLineStrings = lineMerger.getMergedLineStrings();
    System.out.println(mergedLineStrings.toString());
    
    打印结果:[LINESTRING (116.96832 36.64882, 116.96849 36.64882, 116.96862 36.64882, 116.96878 36.64881)]
  • 相关阅读:
    Python-文件阅读(open函数)
    列表推导式练习
    Python-集合(set)
    Python-元组(tuple)
    Python-函数-聚合和打散
    Python-列表-非count的计数方法
    Python-字典(dict)
    Python-列表(list)
    Python-字符串
    求三个元素的最大值,和最小值。
  • 原文地址:https://www.cnblogs.com/gispathfinder/p/12862540.html
Copyright © 2011-2022 走看看