JTS:09Touches 接触

这里写目录标题

      • 版本
      • JTS Touches
        • 边接触
        • 角点接触
        • 内部接触
        • 线段交叉
        • 顶点接触

版本

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

JTS Touches

边接触

JTS:09Touches 接触_第1张图片

    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));
    }
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
角点接触

JTS:09Touches 接触_第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));
    }
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
内部接触

JTS:09Touches 接触_第3张图片

    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));
    }
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
线段交叉

JTS:09Touches 接触_第4张图片

    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));
    }
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
顶点接触
    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));
    }
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

你可能感兴趣的:(JTS,JTS)