射线算法&区域定位算法实现逻辑。
package com.yhx.globalPath.logic;
import java.util.ArrayList;
import java.util.List;
/**
* @author :yuanhx.
* @date :Created in 11:12 2020/9/30
* @description:区域定位算法
*/
public class RayAlgorithm {
/**
* 射线算法
*
* @param point 当前位置点
* @param areaPointList 区域点集
* @return 是否在该区域
*/
public static boolean rayAlgorithm(double[] point, List<double[]> areaPointList) {
//区域点集小于3,不能构成区域,返回false
if (areaPointList.size() < 3) {
return false;
}
double y1 = 0;
double y2 = 0;
double x1 = 0;
double x2 = 0;
double ym = 0;
//当前位置x坐标(或者是经度)
double x = point[0];
//当前位置y坐标(或者是纬度)
double y = point[1];
//统计交点数
int sum = 0;
for (int i = 0; i < areaPointList.size(); i++