• JTS:09Touches 接触


    版本

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

    JTS Touches

    边接触

    在这里插入图片描述

        public void test00() {
            Coordinate[] coordinates1 = new Coordinate[] {
                    new Coordinate(1, 1), new Coordinate(1, 4), new Coordinate(5, 4), new Coordinate(5, 1), new Coordinate(1, 1)
            };
            Polygon polygon1 = geometryFactory.createPolygon(coordinates1);
    
            Coordinate[] coordinates2 = new Coordinate[] {
                    new Coordinate(5, 1), new Coordinate(5, 4), new Coordinate(9, 4), new Coordinate(9, 1), new Coordinate(5, 1)
            };
            Polygon polygon2 = geometryFactory.createPolygon(coordinates2);
    
            LOGGER.info("polygon1 - polygon2 九交模型值:{}", polygon1.relate(polygon2).toString());
            LOGGER.info("polygon1 - polygon2 接触:{}", polygon1.touches(polygon2));
        }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    10:22:49.799 [main] INFO  pers.stu.geometry.GeometryTouches - polygon1 - polygon2 九交模型值:FF2F11212
    10:22:49.801 [main] INFO  pers.stu.geometry.GeometryTouches - polygon1 - polygon2 接触:true
    
    • 1
    • 2
    角点接触

    在这里插入图片描述

        public void test01() {
            Coordinate[] coordinates1 = new Coordinate[] {
                    new Coordinate(1, 1), new Coordinate(1, 4), new Coordinate(5, 4), new Coordinate(5, 1), new Coordinate(1, 1)
            };
            Polygon polygon1 = geometryFactory.createPolygon(coordinates1);
    
            Coordinate[] coordinates2 = new Coordinate[] {
                    new Coordinate(5, 4), new Coordinate(5, 7), new Coordinate(9, 7), new Coordinate(9, 4), new Coordinate(5, 4)
            };
            Polygon polygon2 = geometryFactory.createPolygon(coordinates2);
    
            LOGGER.info("polygon1 - polygon2 九交模型值:{}", polygon1.relate(polygon2).toString());
            LOGGER.info("polygon1 - polygon2 接触:{}", polygon1.touches(polygon2));
        }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    10:24:20.160 [main] INFO  pers.stu.geometry.GeometryTouches - polygon1 - polygon2 九交模型值:FF2F01212
    10:24:20.162 [main] INFO  pers.stu.geometry.GeometryTouches - polygon1 - polygon2 接触:true
    
    • 1
    • 2
    内部接触

    在这里插入图片描述

        public void test02() {
            Coordinate[] coordinates1 = new Coordinate[] {
                    new Coordinate(1, 1), new Coordinate(1, 4), new Coordinate(5, 4), new Coordinate(5, 1), new Coordinate(1, 1)
            };
            Polygon polygon1 = geometryFactory.createPolygon(coordinates1);
    
            Coordinate[] coordinates2 = new Coordinate[] {
                    new Coordinate(4, 1), new Coordinate(4, 4), new Coordinate(8, 4), new Coordinate(8, 1), new Coordinate(4, 1)
            };
            Polygon polygon2 = geometryFactory.createPolygon(coordinates2);
    
            LOGGER.info("polygon1 - polygon2 九交模型值:{}", polygon1.relate(polygon2).toString());
            LOGGER.info("polygon1 - polygon2 接触:{}", polygon1.touches(polygon2));
        }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    13:48:11.198 [main] INFO  pers.stu.geometry.GeometryTouches - polygon1 - polygon2 九交模型值:212111212
    13:48:11.202 [main] INFO  pers.stu.geometry.GeometryTouches - polygon1 - polygon2 接触:false
    
    • 1
    • 2
    线段交叉

    在这里插入图片描述

        public void test03() {
            Coordinate[] coordinates1 = new Coordinate[] {
                    new Coordinate(2, 3), new Coordinate(10, 4)
            };
            LineString lineString1 = geometryFactory.createLineString(coordinates1);
    
            Coordinate[] coordinates2 = new Coordinate[] {
                    new Coordinate(6, 2), new Coordinate(6, 8)
            };
            LineString lineString2 = geometryFactory.createLineString(coordinates2);
    
            LOGGER.info("polygon1 - polygon2 九交模型值:{}", lineString1.relate(lineString2).toString());
            LOGGER.info("polygon1 - polygon2 接触:{}", lineString1.touches(lineString2));
        }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    13:49:37.309 [main] INFO  pers.stu.geometry.GeometryTouches - polygon1 - polygon2 九交模型值:0F1FF0102
    13:49:37.313 [main] INFO  pers.stu.geometry.GeometryTouches - polygon1 - polygon2 接触:false
    
    • 1
    • 2
    顶点接触
        public void test04() {
            Coordinate[] coordinates1 = new Coordinate[] {
                    new Coordinate(
                            1, 1), new Coordinate(7, 1)
            };
            LineString lineString1 = geometryFactory.createLineString(coordinates1);
    
            Coordinate[] coordinates2 = new Coordinate[] {
                    new Coordinate(7, 6), new Coordinate(7, 1)
            };
            LineString lineString2 = geometryFactory.createLineString(coordinates2);
    
            LOGGER.info("polygon1 - polygon2 九交模型值:{}", lineString1.relate(lineString2).toString());
            LOGGER.info("polygon1 - polygon2 接触:{}", lineString1.touches(lineString2));
        }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    14:10:24.900 [main] INFO  pers.stu.geometry.GeometryTouches - polygon1 - polygon2 九交模型值:FF1F00102
    14:10:24.902 [main] INFO  pers.stu.geometry.GeometryTouches - polygon1 - polygon2 接触:true
    
    • 1
    • 2
  • 相关阅读:
    双端链表LinkedList
    elasticsearch的搜索补全提示
    测试开发(6)软件测试教程——自动化测试selenium(自动化测试介绍、如何实施、Selenium介绍 、Selenium相关的API)
    YoloV8改进策略:NWD小目标检测新范式,助力YoloV5、V8在小目标上暴力涨点
    C++性能分析工具gperftools安装教程与使用案例分析
    速卖通、lazada店铺增加销量有哪些技巧,你知道吗?
    像FBIF一样做会展数字化,你也有可能吸引数万观众
    Linux常用工具集
    Redis(9)----RDB文件结构
    卡特兰数(高精度乘法压位)
  • 原文地址:https://blog.csdn.net/God_Father_kao/article/details/133377333