bug修复:运营区判断
This commit is contained in:
parent
265ab3517c
commit
9aef7b04b8
@ -118,29 +118,6 @@ public class RedisUtil {
|
|||||||
.max().orElse(0)*100;
|
.max().orElse(0)*100;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断点是否在多边形内
|
|
||||||
* @param point 待判断点
|
|
||||||
* @param polygon 多边形顶点
|
|
||||||
* @return 是否在多边形内
|
|
||||||
*/
|
|
||||||
public static boolean isPointInPolygon(Point point, List<Point> polygon) {
|
|
||||||
double x = point.getX();
|
|
||||||
double y = point.getY();
|
|
||||||
|
|
||||||
boolean inside = false;
|
|
||||||
for (int i = 0, j = polygon.size() - 1; i < polygon.size(); j = i++) {
|
|
||||||
double xi = polygon.get(i).getX();
|
|
||||||
double yi = polygon.get(i).getY();
|
|
||||||
double xj = polygon.get(j).getX();
|
|
||||||
double yj = polygon.get(j).getY();
|
|
||||||
|
|
||||||
boolean intersect = ((yi > y) != (yj > y))
|
|
||||||
&& (x < (xj - xi) * (y - yi) / (yj - yi) + xi);
|
|
||||||
if (intersect) inside = !inside;
|
|
||||||
}
|
|
||||||
return inside;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除 Redis 键
|
* 删除 Redis 键
|
||||||
|
|||||||
@ -39,6 +39,8 @@ public class RedisUtil {
|
|||||||
|
|
||||||
private static final WKTReader WKT_READER = new WKTReader(GEOMETRY_FACTORY);
|
private static final WKTReader WKT_READER = new WKTReader(GEOMETRY_FACTORY);
|
||||||
|
|
||||||
|
private static final double DEGREE_TO_METERS = 111320.0;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public RedisUtil(RedisTemplate<String, Object> redisTemplate) {
|
public RedisUtil(RedisTemplate<String, Object> redisTemplate) {
|
||||||
this.redisTemplate = redisTemplate;
|
this.redisTemplate = redisTemplate;
|
||||||
@ -396,7 +398,7 @@ public class RedisUtil {
|
|||||||
Geometry bufferedPolygon = polygon.buffer(0.00000899);
|
Geometry bufferedPolygon = polygon.buffer(0.00000899);
|
||||||
|
|
||||||
// 4. 结合距离判断
|
// 4. 结合距离判断
|
||||||
return bufferedPolygon.covers(point) || polygon.distance(point) < 1.0;
|
return bufferedPolygon.covers(point) || polygon.distance(point) * DEGREE_TO_METERS < 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user