站点GEO
This commit is contained in:
parent
810126cbd1
commit
aeb74d9da7
@ -34,6 +34,8 @@ public class RedisUtil {
|
||||
|
||||
private final String parkingKey = "parking_geo";
|
||||
|
||||
private final String siteKey = "site_geo";
|
||||
|
||||
private final String operationKey = "operation_geo";
|
||||
private static final GeometryFactory GEOMETRY_FACTORY = new GeometryFactory(new PrecisionModel(1000));
|
||||
|
||||
@ -386,6 +388,49 @@ public class RedisUtil {
|
||||
redisTemplate.opsForHash().delete("parking_area:meta:" + areaId, "mbr"+regionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加站点数据
|
||||
* @param areaId 运营区Id
|
||||
* @param regionId 停车区Id
|
||||
* @param vertices 边缘点
|
||||
*/
|
||||
public void addSiteArea(Long areaId,Long regionId, List<Coordinate> vertices) {
|
||||
Point point = calculateCentroid(vertices);
|
||||
redisTemplate.opsForGeo().add(siteKey+areaId, point, regionId);
|
||||
addSiteAreaMeta(areaId,regionId,vertices);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除站点
|
||||
*
|
||||
*/
|
||||
public void delSiteArea(Long orgId,Long regionId) {
|
||||
redisTemplate.opsForGeo().remove(siteKey+orgId,regionId);
|
||||
delSiteAreaMeta(orgId,regionId);
|
||||
}
|
||||
|
||||
public void delSiteAreaMeta(Long orgId,Long regionId) {
|
||||
redisTemplate.opsForHash().delete("site_area:meta:" + orgId, "vertices"+regionId);
|
||||
redisTemplate.opsForHash().delete("site_area:meta:" + orgId, "mbr"+regionId);
|
||||
}
|
||||
|
||||
public void addSiteAreaMeta(Long areaId,Long regionId, List<Coordinate> vertices) {
|
||||
|
||||
// 计算 MBR
|
||||
double[] mbr = calculateMBR(vertices);
|
||||
String mbrStr = String.format("%f %f %f %f", mbr[0], mbr[1], mbr[2], mbr[3]);
|
||||
|
||||
// 序列化顶点
|
||||
String verticesStr = vertices.stream()
|
||||
.map(c -> c.x + " " + c.y)
|
||||
.collect(Collectors.joining(","));
|
||||
|
||||
// 存储到 Hash
|
||||
redisTemplate.opsForHash().put("site_area:meta:" + areaId, "vertices"+regionId, verticesStr);
|
||||
redisTemplate.opsForHash().put("site_area:meta:" + areaId, "mbr"+regionId, mbrStr);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量删除多个停车区的 GEO 索引和元数据
|
||||
* @param areaIds 停车区 ID 列表
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user