• JTS: 23 lineDissolver 线段分割


    文章目录

    版本

    org.locationtech.jts:jts-core:1.19.0
    链接: github

    代码

    将一组geometry几何分解成一组最大长度的linestring,其中重叠的部分只出现一次

    在这里插入图片描述

    package pers.stu.dissolve;
    
    import org.locationtech.jts.dissolve.LineDissolver;
    import org.locationtech.jts.geom.Coordinate;
    import org.locationtech.jts.geom.Geometry;
    import org.locationtech.jts.geom.GeometryFactory;
    import org.locationtech.jts.geom.LineString;
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import pers.stu.util.GeoGebraUtil;
    
    /**
     * 
     */
    public class LineDissolverUse {
    
        private static final Logger LOGGER = LoggerFactory.getLogger(LineDissolverUse.class);
    
        private final GeometryFactory geometryFactory = new GeometryFactory();
    
        public static void main(String[] args) {
            LineDissolverUse lineDissolverUse = new LineDissolverUse();
            lineDissolverUse.test00();
        }
    
        public void test00() {
            Coordinate[] coordinate1 = new Coordinate[] {
                  new Coordinate(1.5, 9), new Coordinate(4.5, 9), new Coordinate(7, 11.5)
            };
    
            Coordinate[] coordinate2 = new Coordinate[] {
                    new Coordinate(1.5, 9), new Coordinate(4.5, 9), new Coordinate(7, 9)
            };
    
            Coordinate[] coordinate3 = new Coordinate[] {
                    new Coordinate(4.5, 9), new Coordinate(7, 11.5), new Coordinate(7, 9), new Coordinate(10, 9)
            };
    
            LineString lineString1 = geometryFactory.createLineString(coordinate1);
            LineString lineString2 = geometryFactory.createLineString(coordinate2);
            LineString lineString3 = geometryFactory.createLineString(coordinate3);
    
            LineDissolver lineDissolver = new LineDissolver();
            lineDissolver.add(lineString1);
            lineDissolver.add(lineString2);
            lineDissolver.add(lineString3);
            Geometry geometry = lineDissolver.getResult();
            LOGGER.info(geometry.toText());
            LOGGER.info(GeoGebraUtil.compare(geometry));
        }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
  • 相关阅读:
    嵌入式面试笔试刷题(day14)
    多媒体数据处理实验4:LSH索引
    vue制作自己的组件库(仿ElementUI)
    【Java】线程池源码解析
    Linux Docker容器配置
    Linux(CentOS)安装msf
    sql-lib 搭建&31-40关
    Talk预告 | Salesforce AI研究院研究科学家徐嘉诚:文本生成中的结构化解码
    推荐:6款好用的安全审计工具!
    微信在线点餐怎么做_怎么实现在微信公众号在线点餐
  • 原文地址:https://blog.csdn.net/God_Father_kao/article/details/134425749