JTS: 12 Descriptions 图形覆盖

版本

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

代码

在这里插入图片描述

/**
 * 图形覆盖操作
 * @author LiHan
 * 2023年10月12日 19:34:09
 */
public class GeometryDescriptions {

    private final GeometryFactory geometryFactory = new GeometryFactory();

    private static final Logger LOGGER = LoggerFactory.getLogger(GeometryDescriptions.class);

    private static final WKTWriter WKT_WRITER = new WKTWriter();

    private final Coordinate[] coordinate1 = {new Coordinate(3, 9), new Coordinate(3, 4), new Coordinate(14, 4), new Coordinate(14, 9), new Coordinate(3, 9)};

    private final Coordinate[] coordinate2 = {new Coordinate(3, 6), new Coordinate(3, 1), new Coordinate(14, 1), new Coordinate(14, 6), new Coordinate(3, 6)};

    private final Polygon polygon1 = geometryFactory.createPolygon(coordinate1);

    private final Polygon polygon2 = geometryFactory.createPolygon(coordinate2);

    public static void main(String[] args) {
        GeometryDescriptions geometryDescriptions = new GeometryDescriptions();
        geometryDescriptions.test03();
    }
}
Intersection 交集

在这里插入图片描述

public void test00() {
    LOGGER.info("交集:{}", polygon1.intersection(polygon2));
}
Union 并集

在这里插入图片描述

public void test01() {
   LOGGER.info("并集:{}", polygon1.union(polygon2));
}
Difference 差集

在这里插入图片描述

public void test02() {
    Geometry geometry = polygon1.difference(polygon2);
    LOGGER.info("差集:{}", geometry);
}
SymDifference 补集

在这里插入图片描述

public void test03() {
    Geometry geometry = polygon1.symDifference(polygon2);
    LOGGER.info("补集:{}", geometry);
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值