【geotool】geometry操作

1.intersection

package com.example.geotooltest;

import org.junit.Test;
import org.locationtech.jts.geom.Geometry;

import java.io.IOException;

public class GeometryUtil {

    @Test
    public void intersectionTest() throws IOException {
        DataTypeConvert dtc = new DataTypeConvert();
        String json1 = "{ \"type\": \"Polygon\", \"coordinates\": [ [ [ [ 114.318459657701752, 25.451711491442541 ], [ 114.338936430317901, 25.468215158924203 ], [ 114.365220048899801, 25.458129584352076 ], [ 114.377750611246995, 25.405562347188262 ], [ 114.322127139364355, 25.39822738386308 ], [ 114.318459657701752, 25.451711491442541 ] ] ] ] }";
        Geometry geo1 = dtc.geojson2Geometry(json1);

        String json2 = "{ \"type\": \"Polygon\", \"coordinates\": [ [ [ [ 114.355337061964661, 25.473019331992273 ], [ 114.460986089648614, 25.47481608416377 ], [ 114.47176660267759, 25.380306919943092 ], [ 114.357133814136162, 25.377791466902995 ], [ 114.355337061964661, 25.473019331992273 ] ] ] ] }";
        Geometry geo2 = dtc.geojson2Geometry(json2);

        Geometry geo12_intersect = geo1.intersection(geo2);
        System.out.println(dtc.geometry2Geojson(geo12_intersect));
    }
}

相交结果 橙色为intersection后的结果
在这里插入图片描述

参考

1.JTS Geometry关系判断和分析

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值