java电子围栏工具类

实体类

@Data
@Builder
public class CircularDTO {
    /**
     * 圆心
     */
    private PointDTO center;

    /**
     * 半径
     */
    private Double radius;
}
@Data
@Builder
public class FenceResult {
    /**
     * 是否再围栏内
     */
    private Boolean isInline;

    /**
     * 最短距离
     */
    private Double shortestDistance;
}
@Data
@Builder
@AllArgsConstructor
public class GpsPointDTO {
    /**
     * 经度
     */
    private Double longitude;

    /**
     * 纬度
     */
    private Double latitude;
}
@Data
@AllArgsConstructor
public class PointDTO {
    /**
     * x坐标
     */
    private Double x;

    /**
     * y坐标
     */
    private Double y;
}

工具类

public class FenceUtils {
	
	 /**
	  * 点是否在多个围栏内
	  */
    public static FenceResult isPointInPolyFences(PointDTO point, List<List<PointDTO>> polyline) {
        /* 与围栏的最短距离 */
        double shortestDistance = Double.MAX_VALUE;
        for (List<PointDTO> points : polyline) {
            FenceResult pointInPolyFence = isPointInPolyFence(point, points);
            if (pointInPolyFence.getIsInline()) {
                return pointInPolyFence;
            }
            shortestDistance = Math.min(pointInPolyFence.getShortestDistance(), shortestDistance);
        }
        return FenceResult.builder().isInline(false).shortestDistance(shortestDistance).build();
    }
    
	 /**
	  * 点是否在单个围栏内
	  */
    public static FenceResult isPointInPolyFence(PointDTO point, List<PointDTO> points) {
        int length = points.size();

        /* 是否在围栏内 */
        boolean isInside = false;
        /* 与围栏的最短距离 */
        double shortestDistance = Double.MAX_VALUE;

        double x = point.getX();
        double y = point.getY();

        for (int i = 0, j = length - 1; i < length; j = i++) {
            PointDTO startPoint = points.get(j);
            PointDTO endPoint = points.get(i);

            double x1 = startPoint.getX();
            double y1 = startPoint.getY();

            double x2 = endPoint.getX();
            double y2 = endPoint.getY();

            /* 如果point刚好在points[i]上 */
            if (equal(x, x1) && equal(y, y1)) {
                return FenceResult.builder().shortestDistance(0d).isInline(true).build();
            }
            /* 点到当前线段的距离,默认为点到线段两端点距离的最小值 */
            double distance = Double.min(getDistance(point, startPoint), getDistance(point, endPoint));

            /* 如果该线段是平行于x轴 */
            if (equal(y2, y1)) {
                if ((x - x1) * (x - x2) < 0) {
                    /* 如果点在该线段中 */
                    if (equal(y, y1)) {
                        return FenceResult.builder().shortestDistance(0d).isInline(true).build();
                    }

                    distance = Math.abs(y - y1);
                }
            } else {
                /* 求交点的x坐标 */
                double intersectionX = (y - y1) * (x2 - x1) / (y2 - y1) + x1;
                if ((y - y1) * (y - y2) < 0) {
                    /* 如果点在该线段中*/
                    if (equal(intersectionX, x)) {
                        return FenceResult.builder().shortestDistance(0d).isInline(true).build();
                    }
                    if (intersectionX > x) {
                        isInside = !isInside;
                    }
                }
                /* 垂直于(x1,y1),(x2,y2)的直线的斜率 */
                double slope = (x1 - x2) / (y2 - y1);
                if ((slope * (x - x2) + y2 - y) * (slope * (x - x1) + y1 - y) < 0) {
                    /* 如果该线段是垂直于x轴 */
                    if (equal(x2, x1)) {
                        distance = Math.abs(intersectionX - x);
                    } else {
                        distance = Math.abs(intersectionX - x) * Math.sqrt(1 - 1 / (1 + Math.pow((y2 - y1) / (x2 - x1), 2)));
                    }
                }

            }
            shortestDistance = Double.min(shortestDistance, distance);
        }
        return FenceResult.builder().shortestDistance(shortestDistance).isInline(isInside).build();
    }

    public static FenceResult isPointInCircularFence(PointDTO point, CircularDTO circular) {
        double point2Center = getDistance(point, circular.getCenter());

        boolean isInside = point2Center <= circular.getRadius();

        double shortestDistance = Math.abs(point2Center - circular.getRadius());
        return FenceResult.builder().shortestDistance(shortestDistance).isInline(isInside).build();
    }

    public static List<List<PointDTO>> parsePolylineFromStr(String polyStr) throws Exception {
        String[] areaStr = polyStr.split("\\|");
        List<List<PointDTO>> polyline = new ArrayList<>();
        for (String s : areaStr) {
            String[] pointsStr = s.split(";");
            int minSideSize = 3;
            if (pointsStr.length < minSideSize) {
                throw new Exception("围栏格式不正确");
            }
            List<PointDTO> points = new ArrayList<>();
            for (String pointStr : pointsStr) {
                String[] p = pointStr.split(",");
                if (p.length != 2) {
                    throw new Exception("围栏格式不正确");
                }
                GpsPointDTO point = new GpsPointDTO(Double.parseDouble(p[0]), Double.parseDouble(p[1]));
                points.add(mct84Bl2xy(point));
            }
            polyline.add(points);
        }
        return polyline;
    }

    public static CircularDTO parseCircularFromStr(String circularStr) throws Exception {
        String[] str = circularStr.split(";");
        int fieldSize = 2;
        if (str.length != fieldSize) {
            throw new Exception("围栏格式不正确");
        }
        String[] centerStr = str[0].split(",");
        int pointSize = 2;
        if (centerStr.length != pointSize) {
            throw new Exception("围栏格式不正确");
        }
        GpsPointDTO point = new GpsPointDTO(Double.parseDouble(centerStr[0]), Double.parseDouble(centerStr[1]));

        return CircularDTO.builder()
                .center(mct84Bl2xy(point))
                .radius(Double.parseDouble(str[1])).build();
    }

    private static boolean equal(double a, double b) {
        double err = 1e-6;
        return Math.abs(a - b) < err;
    }

    /**
     * 将gps坐标转化为XY坐标
     *
     * @param gpsPoint 要转化的GPS坐标
     * @return XY坐标
     * @throws Exception 解析异常
     */
    public static PointDTO mct84Bl2xy(GpsPointDTO gpsPoint) throws Exception {
        try {
            double longitude = gpsPoint.getLongitude() * Math.PI / 180;
            double latitude = gpsPoint.getLatitude() * Math.PI / 180;
            double b0 = 30 * Math.PI / 180;
            double n, e, a, b, e2, k;
            a = 6378137;
            b = 6356752.3142;
            e = Math.sqrt(1 - (b / a) * (b / a));
            e2 = Math.sqrt((a / b) * (a / b) - 1);
            double cosB0 = Math.cos(b0);
            n = (a * a / b) / Math.sqrt(1 + e2 * e2 * cosB0 * cosB0);
            k = n * cosB0;
            double tan = Math.tan(Math.PI / 4 + latitude / 2);
            e2 = Math.pow((1 - e * Math.sin(latitude)) / (1 + e * Math.sin(latitude)), e / 2);
            double xx = tan * e2;
            double x = k * Math.log(xx);
            double y = k * longitude;
            return new PointDTO(x, y);
        } catch (Exception e) {
            throw new Exception("GPS转XY坐标系错误");
        }
    }

    /**
     * 求两个经纬度的距离
     *
     * @param p1 点1
     * @param p2 点2
     * @return 距离
     */
    public static double getDistance(PointDTO p1, PointDTO p2) {

        double x1 = p1.getX();
        double y1 = p1.getY();

        double x2 = p2.getX();
        double y2 = p2.getY();
        return Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
    }
}

代码示例

@Test
public void test1() throws Exception {
    String pointsStr = "116.779492, 40.021271;116.776293, 40.016283;116.783086, 39.99915;116.776314, 39.993561;116.771908, 39.98082;116.763101, 39.969041;116.765947, 39.964335;116.775097, 39.960843;116.779719, 39.960878;116.779674, 39.966903;116.791887, 39.948969;116.79408, 39.943012;116.787112, 39.938087;116.789682, 39.923473;116.787185, 39.916278;116.792542, 39.894393;116.810601, 39.884271;116.810752, 39.890515;116.814746, 39.890456;116.814946, 39.894968;116.818949, 39.894932;116.819785, 39.88685;116.830772, 39.884362;116.843963, 39.87047;116.853756, 39.864521;116.859383, 39.864913;116.863583, 39.855461;116.87834, 39.848598;116.885208, 39.848739;116.885132, 39.852311;116.892137, 39.851585;116.905577, 39.838422;116.914262, 39.837479;116.908783, 39.854513;116.918313, 39.856776;116.921992, 39.855001;116.934394, 39.838429;116.937076, 39.817797;116.949892, 39.809299;116.941805, 39.806672;116.94368, 39.801024;116.957442, 39.797346;116.960377, 39.793997;116.955078, 39.791216;116.956946, 39.784166;116.941793, 39.787682;116.928021, 39.786096;116.923196, 39.781197;116.92791, 39.775034;116.921175, 39.771311;116.922554, 39.768898;116.917579, 39.768205;116.915237, 39.772849;116.906433, 39.764842;116.908655, 39.761567;116.91425, 39.761681;116.921325, 39.747965;116.917976, 39.744404;116.923288, 39.741878;116.923537, 39.737496;116.911883, 39.736443;116.906395, 39.732261;116.894613, 39.731937;116.889981, 39.724833;116.893625, 39.722212;116.894192, 39.708239;116.90074, 39.702559;116.900896, 39.699378;116.895431, 39.696905;116.897916, 39.693761;116.899829, 39.695998;116.912314, 39.695793;116.91675, 39.689158;116.912659, 39.688298;116.91391, 39.683864;116.903605, 39.679918;116.889362, 39.681709;116.880094, 39.677956;116.881938, 39.674679;116.87833, 39.677509;116.870551, 39.676725;116.866871, 39.673465;116.856507, 39.673617;116.859984, 39.658627;116.848058, 39.655413;116.847737, 39.65005;116.841639, 39.65091;116.841515, 39.647232;116.833834, 39.644294;116.836398, 39.640827;116.833601, 39.638423;116.845269, 39.627885;116.841394, 39.627105;116.842867, 39.622777;116.831861, 39.619351;116.826135, 39.624546;116.797011, 39.616332;116.798986, 39.608058;116.79679, 39.602126;116.791594, 39.599278;116.784808, 39.599466;116.780881, 39.611642;116.777153, 39.61185;116.768775, 39.620131;116.755203, 39.625646;116.744575, 39.621101;116.732176, 39.629971;116.716712, 39.624094;116.711992, 39.627461;116.707241, 39.626833;116.709636, 39.616191;116.72124, 39.608876;116.72516, 39.609161;116.731624, 39.601481;116.73329, 39.603735;116.733757, 39.599325;116.718269, 39.593815;116.709719, 39.595019;116.701584, 39.607186;116.689839, 39.604541;116.689219, 39.606951;116.676173, 39.61147;116.669177, 39.611851;116.661406, 39.60632;116.657192, 39.60679;116.656042, 39.610417;116.656533, 39.606587;116.653426, 39.605794;116.649112, 39.611668;116.642729, 39.611571;116.642027, 39.606431;116.627748, 39.608123;116.623683, 39.620546;116.614795, 39.626071;116.614935, 39.630764;116.606753, 39.628838;116.604395, 39.62416;116.600054, 39.627871;116.596836, 39.625464;116.589491, 39.629944;116.586453, 39.629474;116.586633, 39.625375;116.573311, 39.625619;116.57662, 39.617432;116.573456, 39.616765;116.57365, 39.610134;116.569653, 39.607729;116.55262, 39.602111;116.550509, 39.60959;116.548579, 39.600026;116.537823, 39.605357;116.531491, 39.603101;116.528505, 39.596402;116.530141, 39.590271;116.526793, 39.588252;116.527493, 39.583803;116.532385, 39.583749;116.533385, 39.5796;116.527272, 39.578232;116.52622, 39.572745;116.518654, 39.571821;116.515086, 39.556859;116.500608, 39.555472;116.496796, 39.556153;116.496802, 39.559597;116.48927, 39.557644;116.478093, 39.560082;116.485338, 39.548383;116.484639, 39.540443;116.475161, 39.539349;116.47071, 39.533035;116.443991, 39.531966;116.450768, 39.515025;116.440503, 39.512994;116.438092, 39.516161;116.431606, 39.515549;116.428475, 39.5313;116.414239, 39.531364;116.408647, 39.534041;116.409483, 39.520211;116.414125, 39.518314;116.415017, 39.514088;116.424876, 39.51217;116.429758, 39.502915;116.425554, 39.502058;116.41889, 39.488206;116.433745, 39.493591;116.436793, 39.48739;116.432723, 39.484965;116.435498, 39.482176;116.446482, 39.488981;116.451686, 39.487842;116.451042, 39.483232;116.45409, 39.484535;116.455809, 39.481586;116.455509, 39.470441;116.462231, 39.460944;116.457873, 39.453945;116.441682, 39.448725;116.431751, 39.453698;116.398709, 39.459266;116.394025, 39.456829;116.374199, 39.457547;116.369696, 39.461315;116.35845, 39.461125;116.356967, 39.458506;116.348151, 39.460658;116.331989, 39.468638;116.332517, 39.471598;116.327069, 39.473976;116.326594, 39.479313;116.313494, 39.490748;116.312437, 39.49507;116.29024, 39.500991;116.286891, 39.49737;116.282435, 39.50145;116.265536, 39.506483;116.261292, 39.515793;116.250615, 39.522818;116.253725, 39.525839;116.250239, 39.530332;116.254333, 39.534941;116.252655, 39.556239;116.249018, 39.558861;116.252714, 39.563835;116.247505, 39.570023;116.241785, 39.569739;116.242952, 39.57406;116.234024, 39.572561;116.227521, 39.584967;116.214043, 39.58349;116.208992, 39.589993;116.209611, 39.595221;116.206372, 39.592649;116.206181, 39.595467;116.205256, 39.592598;116.204785, 39.595638;116.202108, 39.592508;116.202435, 39.595447;116.190491, 39.59751;116.182813, 39.596504;116.18278, 39.592418;116.171432, 39.590357;116.161285, 39.590326;116.159793, 39.592848;116.15391, 39.578461;116.151935, 39.581861;116.14428, 39.575045;116.136366, 39.573924;116.136343, 39.575966;116.127655, 39.576557;116.127486, 39.58098;116.119789, 39.576823;116.112979, 39.576774;116.111999, 39.582518;116.107478, 39.585688;116.105348, 39.580905;116.04206, 39.578166;116.037122, 39.581984;116.031202, 39.58195;116.032378, 39.593771;116.026719, 39.592299;116.022848, 39.594424;116.01976, 39.593996;116.021881, 39.592291;116.014279, 39.582908;116.002003, 39.582643;116.003439, 39.588929;115.997485, 39.59223;115.998157, 39.599673;115.98504, 39.601333;115.982937, 39.582651;115.986141, 39.57819;115.982548, 39.578471;115.981428, 39.575245;115.975497, 39.576684;115.974257, 39.570216;115.969841, 39.571373;115.963844, 39.567291;115.961381, 39.572169;115.955487, 39.57259;115.95569, 39.579056;115.949422, 39.580781;115.949709, 39.583626;115.944506, 39.583848;115.936656, 39.599848;115.917015, 39.607062;115.913644, 39.596602;115.915533, 39.590506;115.922365, 39.589431;115.918047, 39.575259;115.913689, 39.57543;115.914587, 39.573219;115.906514, 39.573731;115.906682, 39.576181;115.89699, 39.574673;115.899745, 39.562365;115.894512, 39.561212;115.894056, 39.556715;115.873303, 39.552214;115.872826, 39.55552;115.86892, 39.554427;115.862853, 39.56077;115.858464, 39.556126;115.853602, 39.557103;115.85291, 39.549033;115.846721, 39.547412;115.846934, 39.543202;115.836897, 39.542792;115.835566, 39.547078;115.83524, 39.541513;115.82605, 39.540225;115.826433, 39.528866;115.831182, 39.528412;115.831185, 39.524915;115.826606, 39.524686;115.830354, 39.517962;115.836513, 39.516309;115.835715, 39.513008;115.811732, 39.517829;115.792793, 39.516395;115.774653, 39.522027;115.777897, 39.517092;115.775806, 39.515115;115.772496, 39.520779;115.756705, 39.520003;115.750176, 39.530428;115.745175, 39.552056;115.730668, 39.55452;115.733563, 39.549698;115.728101, 39.549358;115.721329, 39.568154;115.715939, 39.57105;115.705799, 39.569512;115.698841, 39.572375;115.700854, 39.57649;115.705653, 39.576015;115.705953, 39.583172;115.700111, 39.586502;115.701575, 39.592191;115.695535, 39.59871;115.695396, 39.606348;115.679621, 39.614847;115.673519, 39.621832;115.67165, 39.611547;115.661849, 39.605868;115.650907, 39.604774;115.644697, 39.610216;115.640786, 39.609409;115.639019, 39.603345;115.625456, 39.609957;115.616747, 39.60627;115.607125, 39.607168;115.593425, 39.596287;115.587582, 39.595815;115.578674, 39.598258;115.581429, 39.602574;115.575314, 39.604729;115.571223, 39.612937;115.563857, 39.614392;115.552207, 39.625285;115.5409, 39.619908;115.537113, 39.608903;115.524938, 39.603009;115.525447, 39.598935;115.521875, 39.597616;115.519251, 39.615987;115.530352, 39.626174;115.527364, 39.639139;115.5293, 39.646055;115.517821, 39.65092;115.513985, 39.657922;115.50329, 39.658053;115.501206, 39.654449;115.484871, 39.657259;115.488932, 39.668617;115.498867, 39.674673;115.4941, 39.679418;115.495978, 39.687259;115.507242, 39.696082;115.505762, 39.702415;115.496838, 39.707639;115.500176, 39.7141;115.494986, 39.735927;115.499244, 39.744551;115.488767, 39.748498;115.474102, 39.746478;115.459418, 39.755286;115.446636, 39.758726;115.441171, 39.770476;115.442162, 39.776559;115.437931, 39.778537;115.43488, 39.774903;115.432316, 39.780473;115.438026, 39.781859;115.440283, 39.788545;115.449667, 39.791553;115.464422, 39.788407;115.490138, 39.804532;115.502597, 39.799032;115.513641, 39.789278;115.520657, 39.794572;115.550462, 39.801931;115.558558, 39.801013;115.573249, 39.811179;115.575906, 39.819579;115.554357, 39.829123;115.552178, 39.832714;115.537181, 39.836299;115.53031, 39.844828;115.520642, 39.844867;115.518225, 39.850986;115.528901, 39.864494;115.528671, 39.87412;115.533748, 39.87587;115.535893, 39.880831;115.516036, 39.888568;115.529579, 39.904757;115.527265, 39.907784;115.513884, 39.919311;115.494083, 39.929783;115.488382, 39.942039;115.470142, 39.946439;115.450219, 39.958209;115.433157, 39.956707;115.430992, 39.962482;115.43357, 39.972002;115.430651, 39.976775;115.433274, 39.985369;115.442774, 39.997184;115.451965, 40.001588;115.457293, 39.999964;115.455756, 40.008861;115.449485, 40.017077;115.458813, 40.027432;115.462258, 40.036607;115.476253, 40.038407;115.491217, 40.045794;115.497045, 40.053611;115.51234, 40.061854;115.516807, 40.071757;115.53117, 40.081406;115.542282, 40.083771;115.549471, 40.082083;115.55714, 40.08543;115.560416, 40.089125;115.558798, 40.09708;115.568681, 40.10417;115.575871, 40.103554;115.580647, 40.107051;115.583999, 40.102318;115.595773, 40.101989;115.597517, 40.115542;115.600004, 40.11469;115.599794, 40.12128;115.60453, 40.125546;115.646328, 40.121465;115.650464, 40.132731;115.660047, 40.137224;115.663166, 40.133933;115.686818, 40.138829;115.692476, 40.136734;115.698236, 40.138289;115.702399, 40.132879;115.715563, 40.132497;115.717425, 40.134524;115.705706, 40.138458;115.717393, 40.140532;115.730732, 40.134284;115.747268, 40.137718;115.760696, 40.150328;115.75598, 40.158764;115.761052, 40.170388;115.775133, 40.170962;115.780784, 40.181263;115.791748, 40.185127;115.793272, 40.176499;115.812814, 40.159789;115.828046, 40.158961;115.841851, 40.15149;115.840614, 40.156226;115.858645, 40.153974;115.859929, 40.161041;115.856291, 40.165398;115.858916, 40.169076;115.853482, 40.16973;115.850934, 40.173988;115.861343, 40.186219;115.855263, 40.190075;115.861968, 40.195169;115.872155, 40.191851;115.879647, 40.193484;115.884757, 40.207031;115.892982, 40.212085;115.890973, 40.224366;115.90616, 40.242828;115.918662, 40.240855;115.923915, 40.252736;115.937818, 40.261108;115.956618, 40.259986;115.957479, 40.26239;115.970762, 40.263449;115.976524, 40.269925;115.96232, 40.281807;115.958443, 40.294239;115.953541, 40.297355;115.95378, 40.302523;115.947995, 40.310024;115.951368, 40.31673;115.943013, 40.319751;115.937438, 40.32711;115.932904, 40.326147;115.929442, 40.330874;115.933814, 40.33603;115.929191, 40.339991;115.930803, 40.348521;115.92416, 40.361059;115.915304, 40.364329;115.891923, 40.36319;115.884897, 40.365358;115.884336, 40.368972;115.871515, 40.365335;115.869097, 40.367503;115.871191, 40.370092;115.865801, 40.368329;115.868778, 40.370198;115.864668, 40.370232;115.868388, 40.37086;115.865396, 40.37326;115.868545, 40.374143;115.864391, 40.374467;115.869022, 40.37656;115.866924, 40.381321;115.862225, 40.382344;115.864035, 40.386076;115.858883, 40.386732;115.85477, 40.381085;115.848008, 40.38395;115.800892, 40.434303;115.803343, 40.439023;115.796175, 40.438796;115.791686, 40.445587;115.776648, 40.450608;115.780445, 40.454216;115.779227, 40.459072;115.782032, 40.458566;115.78001, 40.464109;115.785487, 40.463378;115.782995, 40.467921;115.786855, 40.470215;115.779226, 40.468715;115.776371, 40.475523;115.788312, 40.499211;115.770665, 40.505509;115.748783, 40.502873;115.742486, 40.510011;115.756023, 40.532862;115.762208, 40.536713;115.759569, 40.544349;115.771024, 40.546886;115.776566, 40.554039;115.797854, 40.567634;115.805739, 40.563942;115.819777, 40.56326;115.82686, 40.565649;115.83439, 40.593724;115.852944, 40.598835;115.861589, 40.596006;115.870829, 40.597918;115.874785, 40.601806;115.892463, 40.601677;115.900975, 40.612713;115.916363, 40.62483;115.934455, 40.61906;115.973405, 40.612852;115.972523, 40.607501;115.978619, 40.607983;115.988307, 40.585217;115.999168, 40.586061;116.00781, 40.580665;116.013038, 40.594323;116.024091, 40.603288;116.022547, 40.607119;116.032301, 40.612928;116.033973, 40.611219;116.035716, 40.613992;116.037489, 40.611766;116.03738, 40.603704;116.069112, 40.61654;116.079377, 40.616965;116.083694, 40.626021;116.102996, 40.635883;116.106773, 40.636725;116.111543, 40.6326;116.128465, 40.635534;116.118987, 40.646827;116.118463, 40.653638;116.136703, 40.660193;116.145081, 40.672912;116.160786, 40.669485;116.170746, 40.672867;116.180216, 40.695725;116.177594, 40.702406;116.187469, 40.718714;116.191938, 40.720382;116.197477, 40.730173;116.21108, 40.73747;116.21168, 40.745613;116.217288, 40.748063;116.220017, 40.746152;116.230739, 40.759994;116.240283, 40.764628;116.236792, 40.768601;116.242363, 40.781381;116.241676, 40.78889;116.253939, 40.797906;116.270452, 40.789069;116.282956, 40.768087;116.296144, 40.770608;116.301753, 40.764313;116.314453, 40.758989;116.317236, 40.761451;116.314487, 40.769931;116.323327, 40.778065;116.351283, 40.778542;116.359121, 40.775519;116.367901, 40.778444;116.3741, 40.776239;116.38806, 40.778809;116.399322, 40.785062;116.414437, 40.786878;116.420866, 40.784572;116.422364, 40.776334;116.430341, 40.774389;116.445241, 40.773058;116.451219, 40.775045;116.460803, 40.771691;116.46847, 40.775452;116.472293, 40.78068;116.466833, 40.787988;116.465302, 40.802469;116.458193, 40.804423;116.453641, 40.811352;116.44747, 40.813728;116.444065, 40.826493;116.428163, 40.829267;116.414547, 40.8381;116.409675, 40.851414;116.398134, 40.861415;116.395982, 40.86857;116.388018, 40.870016;116.372979, 40.882607;116.370645, 40.888314;116.351765, 40.899752;116.347614, 40.906754;116.341294, 40.909943;116.341397, 40.927427;116.350502, 40.938434;116.356091, 40.941893;116.366222, 40.942011;116.371789, 40.948881;116.377008, 40.949533;116.386731, 40.942197;116.39073, 40.929489;116.40532, 40.912286;116.411841, 40.911889;116.417804, 40.906134;116.437484, 40.909063;116.443315, 40.905054;116.464397, 40.906283;116.47104, 40.901834;116.48198, 40.901199;116.484397, 40.90868;116.480367, 40.925489;116.474969, 40.930353;116.474027, 40.936925;116.468234, 40.938029;116.46197, 40.954711;116.454294, 40.959251;116.460298, 40.970535;116.45844, 40.975494;116.462222, 40.986419;116.470754, 40.990036;116.48108, 40.983862;116.492175, 40.988262;116.500055, 40.983952;116.518876, 40.981207;116.541897, 40.99491;116.549328, 40.99619;116.561303, 40.993441;116.568265, 40.999457;116.575853, 40.997465;116.593919, 40.983004;116.604806, 40.980317;116.608705, 40.981829;116.620789, 40.989702;116.624011, 41.005825;116.621544, 41.009991;116.62953, 41.026888;116.628626, 41.03644;116.620554, 41.042835;116.624734, 41.0548;116.621131, 41.059024;116.643601, 41.066947;116.653655, 41.065898;116.671595, 41.05272;116.679295, 41.052473;116.687865, 41.047501;116.696099, 41.050198;116.698397, 41.046909;116.705795, 41.026769;116.689617, 41.006296;116.691074, 40.988282;116.684017, 40.982332;116.684353, 40.977063;116.694002, 40.968554;116.696178, 40.956347;116.709303, 40.946689;116.7105, 40.94191;116.714055, 40.939536;116.72282, 40.941815;116.728885, 40.939358;116.730774, 40.934475;116.723688, 40.927496;116.720083, 40.916126;116.730232, 40.912206;116.737199, 40.903386;116.74625, 40.903163;116.765923, 40.896684;116.767138, 40.886997;116.775261, 40.888742;116.778722, 40.884514;116.786922, 40.882267;116.802631, 40.868369;116.802776, 40.860829;116.808587, 40.856941;116.809863, 40.84886;116.816514, 40.854492;116.827391, 40.854037;116.8331, 40.846217;116.837419, 40.848007;116.84638, 40.844692;116.854601, 40.845388;116.854896, 40.842993;116.863858, 40.840054;116.867811, 40.831679;116.882022, 40.827771;116.889217, 40.819147;116.886303, 40.810568;116.902716, 40.802763;116.900908, 40.786941;116.904847, 40.783042;116.930929, 40.779187;116.928832, 40.775259;116.934914, 40.762351;116.929774, 40.757434;116.933227, 40.750506;116.947427, 40.7457;116.949093, 40.73576;116.969692, 40.724358;116.973697, 40.720609;116.971331, 40.715359;116.976039, 40.712754;116.986958, 40.708943;116.994745, 40.70944;117.013265, 40.700735;117.024205, 40.702127;117.037446, 40.698147;117.042863, 40.703528;117.050982, 40.706127;117.083859, 40.705539;117.116894, 40.714363;117.123842, 40.705993;117.135165, 40.707593;117.145465, 40.703391;117.154979, 40.704685;117.165492, 40.702062;117.172988, 40.705175;117.183908, 40.698821;117.190239, 40.703188;117.213667, 40.700843;117.239238, 40.69053;117.247854, 40.682875;117.267815, 40.687475;117.284985, 40.674186;117.28519, 40.670528;117.296756, 40.665822;117.325273, 40.663578;117.343505, 40.669633;117.349183, 40.679929;117.36566, 40.68007;117.378522, 40.686028;117.38768, 40.685924;117.393681, 40.690414;117.403612, 40.689399;117.42526, 40.693323;117.474027, 40.67924;117.489081, 40.68508;117.5028, 40.680909;117.51999, 40.666046;117.51812, 40.662066;117.508996, 40.658352;117.511112, 40.654206;117.506889, 40.641885;117.486378, 40.641224;117.479562, 40.652494;117.471125, 40.658055;117.463951, 40.658915;117.458277, 40.651786;117.459408, 40.639409;117.452797, 40.634061;117.44064, 40.632096;117.436179, 40.645177;117.429911, 40.644114;117.427073, 40.635802;117.431861, 40.626627;117.425849, 40.622474;117.419594, 40.610685;117.428621, 40.599276;117.429944, 40.587132;117.436559, 40.584408;117.42831, 40.575061;117.410238, 40.58003;117.394345, 40.567066;117.384646, 40.569995;117.372365, 40.582144;117.357598, 40.58647;117.345897, 40.585463;117.33686, 40.581408;117.331495, 40.584097;117.318549, 40.583388;117.30663, 40.572528;117.292691, 40.570954;117.285274, 40.565991;117.277472, 40.56696;117.256053, 40.554465;117.260121, 40.546979;117.256673, 40.543648;117.270634, 40.523185;117.26966, 40.519585;117.262206, 40.521165;117.254006, 40.518402;117.245297, 40.523783;117.235134, 40.517857;117.224845, 40.520248;117.220084, 40.518384;117.214846, 40.5067;117.218545, 40.500998;117.224437, 40.500805;117.234654, 40.487729;117.232151, 40.482631;117.234847, 40.479118;117.243656, 40.47508;117.240486, 40.469378;117.24183, 40.463334;117.250057, 40.461881;117.258428, 40.456581;117.259389, 40.4526;117.269956, 40.447432;117.250863, 40.428259;117.24071, 40.423251;117.244601, 40.413871;117.242079, 40.407576;117.247098, 40.40218;117.233795, 40.390607;117.230556, 40.377787;117.233169, 40.375453;117.249163, 40.376186;117.256523, 40.364876;117.260323, 40.36458;117.266853, 40.341877;117.281496, 40.338471;117.277999, 40.331359;117.281017, 40.314661;117.294659, 40.307112;117.302803, 40.298725;117.299217, 40.291964;117.302506, 40.28388;117.3191, 40.28574;117.323711, 40.290971;117.329833, 40.291084;117.338967, 40.296487;117.34407, 40.27027;117.348886, 40.262476;117.346709, 40.252376;117.352362, 40.241581;117.358332, 40.235831;117.376571, 40.23997;117.396561, 40.23402;117.399895, 40.227142;117.389078, 40.226176;117.385593, 40.221869;117.385893, 40.214243;117.396476, 40.21168;117.387199, 40.205814;117.385937, 40.19758;117.394614, 40.194553;117.405665, 40.199028;117.415386, 40.193946;117.414252, 40.192062;117.397256, 40.183553;117.370289, 40.18481;117.363961, 40.179371;117.357822, 40.179046;117.365124, 40.165743;117.356686, 40.15248;117.362464, 40.152251;117.36261, 40.147941;117.361152, 40.146263;117.358999, 40.148331;117.354985, 40.142865;117.340375, 40.140389;117.330537, 40.146562;117.324993, 40.144114;117.318764, 40.145141;117.305345, 40.128328;117.294958, 40.128355;117.279605, 40.117888;117.265484, 40.118806;117.257144, 40.123257;117.245325, 40.11846;117.230909, 40.105081;117.230708, 40.101179;117.218253, 40.102424;117.220653, 40.09398;117.20939, 40.084649;117.214132, 40.081942;117.211551, 40.076383;117.205302, 40.07308;117.197521, 40.079582;117.196393, 40.088088;117.191638, 40.090649;117.187711, 40.085193;117.192644, 40.081339;117.186787, 40.075395;117.162568, 40.084471;117.166158, 40.081921;117.163131, 40.075762;117.145412, 40.070232;117.133854, 40.072364;117.125751, 40.078689;117.113428, 40.078126;117.111525, 40.080821;117.108453, 40.079034;117.109329, 40.082062;117.09206, 40.080853;117.088827, 40.070939;117.087455, 40.074568;117.076005, 40.073258;117.076984, 40.069868;117.058598, 40.065027;117.059889, 40.058892;117.043808, 40.053468;117.029009, 40.035812;117.020462, 40.039126;117.006804, 40.036313;116.992473, 40.044857;116.980348, 40.043548;116.97637, 40.040536;116.974895, 40.044366;116.978993, 40.050233;116.970443, 40.056931;116.95252, 40.046703;116.951924, 40.054196;116.950598, 40.049796;116.949749, 40.054272;116.945222, 40.051969;116.942691, 40.054083;116.945362, 40.056404;116.936266, 40.060915;116.935354, 40.056992;116.933235, 40.058743;116.930564, 40.053213;116.925137, 40.050671;116.920927, 40.058436;116.914762, 40.058825;116.907627, 40.053514;116.893805, 40.052605;116.877474, 40.047316;116.857221, 40.060744;116.855192, 40.057703;116.838495, 40.056546;116.837946, 40.054081;116.829607, 40.051896;116.826349, 40.03426;116.818453, 40.038123;116.810381, 40.037911;116.80667, 40.034988;116.795889, 40.040269;116.787553, 40.040731;116.784137, 40.035807;116.779775, 40.035242;116.782411, 40.02604;116.779492, 40.021271";

    List<List<PointDTO>> points = FenceUtils.parsePolylineFromStr(pointsStr);
    GpsPointDTO gpsPoint = new GpsPointDTO(114.779492, 40.021270);
    PointDTO point = FenceUtils.mct84Bl2xy(gpsPoint);

    FenceResult result = FenceUtils.isPointInPolyFences(point, points);

    System.out.println(result);
}
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值