GeoTools计算线与面的交点

GeoTools计算线与面的交点
强烈推介IDEA2021.1.3破解激活,IntelliJ IDEA 注册码,2021.1.3IDEA 激活码  

大家好,我是架构君,一个会写代码吟诗的架构师。今天说一说GeoTools计算线与面的交点,希望能够帮助大家进步!!!

        //航迹点与终点连线
        String trackLine = "LINESTRING(" + lon + " " + lat + "," + lineEndX + " " + lineStartY + ")";
        //画线
        WKTReader reader = new WKTReader(geometryFactory);
        LineString trackLineString = null;
        try {
            trackLineString = (LineString) reader.read(trackLine);
        } catch (ParseException e) {
            log.error("绘制航迹点与终点线异常:"+e.getMessage(),e);
        }            
            //绘制圆
            Polygon polygonCircleOfHazardousArea=createCircle(maxMinLonLatOfHazardousArea);
            //判断相交
            Geometry geometry=trackLineString.intersection(polygonCircleOfHazardousArea);
            if(null!=geometry){
                //有交点
                Coordinate[] coordinates=geometry.getCoordinates();
                if(null!=coordinates && coordinates.length>0){
                    //取第一个相交的点
                    double intersectionCircleX=coordinates[0].x;
                    double intersectionCircleY=coordinates[0].y;
                }
            }

 

本文来源huayang183,由架构君转载发布,观点不代表Java架构师必看的立场,转载请标明来源出处:https://javajgs.com/archives/17971

发表评论