第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

根據(jù)線路獲取線路的輻射區(qū)

標(biāo)簽:
Java MySQL Oracle

项目中需要通过一条线路,计算一个在辐射范围内包含该线路的图形。使用JTS包计算缓冲区即可得到。

1.引入依赖

<!-- jts依赖-->
<dependency>
        <groupId>com.vividsolutions</groupId>
        <artifactId>jts-core</artifactId>
        <version>1.14.0</version>
</dependency>
<!--解析字符串-->
<dependency>
        <groupId>cn.hutool</groupId>
        <artifactId>hutool-all</artifactId>
        <version>5.7.1</version>
</dependency>

2.调用buffer方法获得结果

import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.LineString;

import java.util.List;

/**
 * 获取缓冲区
 */
public class Mytest {
    public static void main(String[] args) {
        String position = "[113.2136306762695,23.2724609375],[113.2136001586914,23.27313613891602],[113.2136001586914,23.27411651611328],[113.2136154174805,23.27562141418457],[113.2136154174805,23.27562141418457],[113.2136459350586,23.27606582641602],[113.2136459350586,23.27606582641602],[113.2151107788086,23.27617835998535],[113.2151107788086,23.27617835998535],[113.2170639038086,23.27627754211426],[113.2213287353516,23.27650451660156],[113.2219467163086,23.27655601501465]";
        JSONObject jsonObject = JSONUtil.parseObj("{\"type\":\"LineString\",\"coordinates\":["+ position +"]}");
        JSONArray jsonArray = jsonObject.getJSONArray("coordinates");
        Coordinate coorArr[] = new Coordinate[jsonArray.size()];
        //封装数据
        for (int i = 0; i < jsonArray.size(); i++){
            String pointArr[] = jsonArray.get(i).toString().replace("[", "").replace("]", "").split(",");
            if (pointArr != null && pointArr.length == 2){
                Coordinate coord = new Coordinate(Double.parseDouble(pointArr[0]),Double.parseDouble(pointArr[1]));
                coorArr[i]=coord;
            }
        }
        GeometryFactory geoFac = new GeometryFactory();
        LineString createLineString = geoFac.createLineString(coorArr);
        // 距离转换角度 = meter / (2*Math.PI*6371004)*360 
        //线路附近100米范围
        Geometry buffer = createLineString.buffer(100 / (2*Math.PI*6371004)*360);
        
        //将结果封装返回
        String subBetween = StrUtil.subBetween(buffer.toString(),"((", "))");
        List<String> split = StrUtil.split(subBetween, ", ");
        String result = "";
        for (String item: split) {
            List<String> split1 = StrUtil.split(item, " ");
            String temp  = "["+ split1.get(0) +"," + split1.get(1) +"]" +",";
            result = result + temp;
        }
        System.out.println(result);

    }
}

3.效果

在这里插入图片描述

4.参考资料

點(diǎn)擊查看更多內(nèi)容
TA 點(diǎn)贊

若覺(jué)得本文不錯(cuò),就分享一下吧!

評(píng)論

作者其他優(yōu)質(zhì)文章

正在加載中
  • 推薦
  • 評(píng)論
  • 收藏
  • 共同學(xué)習(xí),寫(xiě)下你的評(píng)論
感謝您的支持,我會(huì)繼續(xù)努力的~
掃碼打賞,你說(shuō)多少就多少
贊賞金額會(huì)直接到老師賬戶
支付方式
打開(kāi)微信掃一掃,即可進(jìn)行掃碼打賞哦
今天注冊(cè)有機(jī)會(huì)得

100積分直接送

付費(fèi)專欄免費(fèi)學(xué)

大額優(yōu)惠券免費(fèi)領(lǐng)

立即參與 放棄機(jī)會(huì)
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)

舉報(bào)

0/150
提交
取消