Administrator
2023-08-22 e8a4f9014fbea4159ea15642226c6793d57d13ee
ard-work/src/main/java/com/ruoyi/utils/tools/GisTool.java
@@ -35,15 +35,15 @@
    }
    public static void main(String[] args) {
        // 被检测的经纬度点
        Point2D point2D= new Point2D.Double(126.649261,45.687377);
        // 商业区域(百度多边形区域经纬度集合)
        List<Point2D> partitionLocation = new ArrayList<>();
        partitionLocation.add(new Point2D.Double(126.64459,45.688548));
        partitionLocation.add(new Point2D.Double(126.653376,45.68938));
        partitionLocation.add(new Point2D.Double(126.645776,45.685048));
        partitionLocation.add(new Point2D.Double(126.654184,45.685778));
        System.out.println(isInPolygon(point2D,partitionLocation));
//        // 被检测的经纬度点
//        Point point= new Point(126.649261,45.687377);
//        // 商业区域(百度多边形区域经纬度集合)
//        List<Point> partitionLocation = new ArrayList<>();
//        partitionLocation.add(new Point(126.64459,45.688548));
//        partitionLocation.add(new Point(126.653376,45.68938));
//        partitionLocation.add(new Point(126.645776,45.685048));
//        partitionLocation.add(new Point(126.654184,45.685778));
//        System.out.println(isInPolygon(point,partitionLocation));
    }
    /**
@@ -52,17 +52,17 @@
     * @param partitionLocation 区域顶点
     * @return
     */
    public static boolean isInPolygon(Point2D orderLocation,List<Point2D> partitionLocation){
    public static boolean isInPolygon(Point orderLocation,List<Point> partitionLocation){
        double p_x =orderLocation.getX();
        double p_y =orderLocation.getY();
        double p_x =orderLocation.getLongitude();
        double p_y =orderLocation.getLatitude();
        Point2D.Double point = new Point2D.Double(p_x, p_y);
        List<Point2D.Double> pointList= new ArrayList<Point2D.Double>();
        for (Point2D points : partitionLocation){
            double polygonPoint_x=points.getX();
            double polygonPoint_y=points.getY();
        for (Point points : partitionLocation){
            double polygonPoint_x=points.getLongitude();
            double polygonPoint_y=points.getLatitude();
            Point2D.Double polygonPoint = new Point2D.Double(polygonPoint_x,polygonPoint_y);
            pointList.add(polygonPoint);
        }