支持多边形查询
This commit is contained in:
@@ -9,6 +9,7 @@ import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
||||
import com.genersoft.iot.vmp.web.custom.bean.CameraChannel;
|
||||
import com.genersoft.iot.vmp.web.custom.bean.CameraStreamContent;
|
||||
import com.genersoft.iot.vmp.web.custom.bean.IdsQueryParam;
|
||||
import com.genersoft.iot.vmp.web.custom.bean.PolygonQueryParam;
|
||||
import com.genersoft.iot.vmp.web.custom.service.CameraChannelService;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
@@ -99,7 +100,7 @@ public class CameraChannelController {
|
||||
@Parameter(name = "deviceId", description = "通道编号")
|
||||
@Parameter(name = "deviceCode", description = "摄像头设备国标编号, 对于非国标摄像头可以不设置此参数")
|
||||
@Parameter(name = "geoCoordSys", description = "坐标系类型:WGS84,GCJ02、BD09")
|
||||
public CameraChannel getOne(@RequestParam(required = true) String deviceId, @RequestParam(required = true) String deviceCode,
|
||||
public CameraChannel getOne(String deviceId, @RequestParam(required = false) String deviceCode,
|
||||
@RequestParam(required = false) String geoCoordSys) {
|
||||
return channelService.queryOne(deviceId, deviceCode, geoCoordSys);
|
||||
}
|
||||
@@ -125,8 +126,8 @@ public class CameraChannelController {
|
||||
@PostMapping(value = "/camera/list/ids")
|
||||
@ResponseBody
|
||||
@Operation(summary = "根据编号查询多个摄像头信息", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
public List<CameraChannel> queryListByDeviceIds(@RequestBody List<String> deviceIds) {
|
||||
return channelService.queryListByDeviceIds(deviceIds);
|
||||
public List<CameraChannel> queryListByDeviceIds(@RequestBody IdsQueryParam param) {
|
||||
return channelService.queryListByDeviceIds(param.getDeviceIds(), param.getGeoCoordSys());
|
||||
}
|
||||
|
||||
@GetMapping(value = "/camera/list/box")
|
||||
@@ -144,18 +145,14 @@ public class CameraChannelController {
|
||||
@RequestParam(required = false) Integer level,
|
||||
String groupAlias,
|
||||
@RequestParam(required = false) String geoCoordSys) {
|
||||
return null;
|
||||
return channelService.queryListInBox(minLongitude, maxLongitude, minLatitude, maxLatitude, level, groupAlias, geoCoordSys);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/camera/list/polygon")
|
||||
@PostMapping(value = "/camera/list/polygon")
|
||||
@ResponseBody
|
||||
@Operation(summary = "根据多边形查询摄像头", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
@Parameter(name = "position", description = "多边形位置,格式: [{'lng':116.32, 'lat': 39: 39.2}, {'lng':115.32, 'lat': 39: 38.2}, {'lng':125.32, 'lat': 39: 38.2}]")
|
||||
@Parameter(name = "level", description = "地图级别")
|
||||
@Parameter(name = "groupAlias", description = "分组别名")
|
||||
@Parameter(name = "geoCoordSys", description = "坐标系类型:WGS84,GCJ02、BD09")
|
||||
public List<CameraChannel> queryListInPolygon(@RequestBody PolygonQueryParam param) {
|
||||
return null;
|
||||
return channelService.queryListInPolygon(param.getPosition(), param.getGroupAlias(), param.getLevel(), param.getGeoCoordSys());
|
||||
}
|
||||
|
||||
@GetMapping(value = "/camera/list/circle")
|
||||
@@ -164,11 +161,12 @@ public class CameraChannelController {
|
||||
@Parameter(name = "centerLongitude", description = "圆心经度")
|
||||
@Parameter(name = "centerLatitude", description = "圆心纬度")
|
||||
@Parameter(name = "radius", description = "查询范围的半径,单位米")
|
||||
@Parameter(name = "level", description = "地图级别")
|
||||
@Parameter(name = "groupAlias", description = "分组别名")
|
||||
@Parameter(name = "geoCoordSys", description = "坐标系类型:WGS84,GCJ02、BD09")
|
||||
public List<CameraChannel> queryListInCircle(Double centerLongitude, Double centerLatitude, Double radius, String groupAlias,
|
||||
String geoCoordSys) {
|
||||
return null;
|
||||
@RequestParam(required = false) String geoCoordSys, @RequestParam(required = false) Integer level) {
|
||||
return channelService.queryListInCircle(centerLongitude, centerLatitude, radius, level, groupAlias, geoCoordSys);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/camera/list/address")
|
||||
@@ -177,8 +175,8 @@ public class CameraChannelController {
|
||||
@Parameter(name = "address", description = "安装地址")
|
||||
@Parameter(name = "directionType", description = "监视方位")
|
||||
@Parameter(name = "geoCoordSys", description = "坐标系类型:WGS84,GCJ02、BD09")
|
||||
public List<CameraChannel> queryListByAddressAndDirectionType(String address, Integer directionType, String geoCoordSys) {
|
||||
return null;
|
||||
public List<CameraChannel> queryListByAddressAndDirectionType(String address, Integer directionType, @RequestParam(required = false) String geoCoordSys) {
|
||||
return channelService.queryListByAddressAndDirectionType(address, directionType, geoCoordSys);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/camera/control/play")
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.List;
|
||||
public class IdsQueryParam {
|
||||
|
||||
@Schema(description = "通道编号列表")
|
||||
private List<ChannelParam> deviceIds;
|
||||
private List<String> deviceIds;
|
||||
|
||||
@Schema(description = "坐标系类型:WGS84,GCJ02、BD09")
|
||||
private String geoCoordSys;
|
||||
|
||||
@@ -9,9 +9,15 @@ import java.util.List;
|
||||
@Schema(description = "多边形检索摄像头参数")
|
||||
public class PolygonQueryParam {
|
||||
|
||||
@Schema(description = "多边形位置,格式: [{'lng':116.32, 'lat': 39: 39.2}, {'lng':115.32, 'lat': 39: 38.2}, {'lng':125.32, 'lat': 39: 38.2}]")
|
||||
private List<Point> position;
|
||||
|
||||
@Schema(description = "地图级别")
|
||||
private Integer level;
|
||||
|
||||
@Schema(description = "分组别名")
|
||||
private String groupAlias;
|
||||
private String topGroupAlias;
|
||||
|
||||
@Schema(description = "坐标系类型:WGS84,GCJ02、BD09")
|
||||
private String geoCoordSys;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ import com.genersoft.iot.vmp.utils.Coordtransform;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||
import com.genersoft.iot.vmp.web.custom.bean.CameraChannel;
|
||||
import com.genersoft.iot.vmp.web.custom.bean.CameraGroup;
|
||||
import com.genersoft.iot.vmp.web.custom.bean.Point;
|
||||
import com.genersoft.iot.vmp.web.custom.bean.PolygonQueryParam;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.github.xiaoymin.knife4j.core.util.Assert;
|
||||
@@ -166,7 +168,7 @@ public class CameraChannelService implements CommandLineRunner {
|
||||
}
|
||||
|
||||
public CameraChannel queryOne(String deviceId, String deviceCode, String geoCoordSys) {
|
||||
CommonGBChannel channel = channelMapper.queryGbChannelByChannelDeviceIdAndGbDeviceId(deviceId, deviceCode);
|
||||
CameraChannel channel = channelMapper.queryGbChannelByChannelDeviceIdAndGbDeviceId(deviceId, deviceCode);
|
||||
Assert.notNull(channel, "通道不存在");
|
||||
|
||||
if (geoCoordSys != null && channel.getGbLongitude() != null && channel.getGbLatitude() != null
|
||||
@@ -182,11 +184,10 @@ public class CameraChannelService implements CommandLineRunner {
|
||||
channel.setGbLatitude(position[1]);
|
||||
}
|
||||
}
|
||||
CameraChannel resultChannel = (CameraChannel)channel;
|
||||
if (deviceCode != null) {
|
||||
resultChannel.setDeviceCode(deviceCode);
|
||||
channel.setDeviceCode(deviceCode);
|
||||
}
|
||||
return resultChannel;
|
||||
return channel;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -294,10 +295,103 @@ public class CameraChannelService implements CommandLineRunner {
|
||||
channelMapper.update(commonGBChannel);
|
||||
}
|
||||
|
||||
public List<CameraChannel> queryListByDeviceIds(List<String> deviceIds) {
|
||||
return channelMapper.queryListByDeviceIds(deviceIds);
|
||||
public List<CameraChannel> queryListByDeviceIds(List<String> deviceIds, String geoCoordSys) {
|
||||
List<CameraChannel> cameraChannels = channelMapper.queryListByDeviceIds(deviceIds);
|
||||
return addIconPathAndPositionForCameraChannelList(cameraChannels, geoCoordSys);
|
||||
}
|
||||
|
||||
public List<CameraChannel> queryListByAddressAndDirectionType(String address, Integer directionType, String geoCoordSys) {
|
||||
List<CameraChannel> cameraChannels = channelMapper.queryListByAddressAndDirectionType(address, directionType);
|
||||
return addIconPathAndPositionForCameraChannelList(cameraChannels, geoCoordSys);
|
||||
}
|
||||
|
||||
|
||||
public List<CameraChannel> queryListInBox(Double minLongitude, Double maxLongitude, Double minLatitude, Double maxLatitude, Integer level, String groupAlias, String geoCoordSys) {
|
||||
// 构建组织结构信息
|
||||
CameraGroup group = groupMapper.queryGroupByAlias(groupAlias);
|
||||
Assert.notNull(group, "获取组织结构失败");
|
||||
// 获取所有子节点
|
||||
List<CameraGroup> groupList = queryAllGroupChildren(group.getId(), group.getBusinessGroup());
|
||||
groupList.add(group);
|
||||
// 参数坐标系列转换
|
||||
if (geoCoordSys != null) {
|
||||
if (geoCoordSys.equalsIgnoreCase("GCJ02")) {
|
||||
Double[] minPosition = Coordtransform.WGS84ToGCJ02(minLongitude, minLatitude);
|
||||
minLongitude = minPosition[0];
|
||||
minLatitude = minPosition[1];
|
||||
|
||||
Double[] maxPosition = Coordtransform.WGS84ToGCJ02(maxLongitude, maxLatitude);
|
||||
maxLongitude = maxPosition[0];
|
||||
maxLatitude = maxPosition[1];
|
||||
}else if (geoCoordSys.equalsIgnoreCase("BD09")) {
|
||||
Double[] gcj02MinPosition = Coordtransform.WGS84ToGCJ02(minLongitude, minLatitude);
|
||||
Double[] minPosition = Coordtransform.GCJ02ToBD09(gcj02MinPosition[0], gcj02MinPosition[1]);
|
||||
minLongitude = minPosition[0];
|
||||
minLatitude = minPosition[1];
|
||||
|
||||
Double[] gcj02MaxPosition = Coordtransform.WGS84ToGCJ02(maxLongitude, maxLatitude);
|
||||
Double[] maxPosition = Coordtransform.GCJ02ToBD09(gcj02MaxPosition[0], gcj02MaxPosition[1]);
|
||||
maxLongitude = maxPosition[0];
|
||||
maxLatitude = maxPosition[1];
|
||||
}
|
||||
}
|
||||
|
||||
List<CameraChannel> all = channelMapper.queryListInBox(minLongitude, maxLongitude, minLatitude, maxLatitude, level, groupList);
|
||||
return addIconPathAndPositionForCameraChannelList(all, geoCoordSys);
|
||||
}
|
||||
|
||||
public List<CameraChannel> queryListInCircle(Double centerLongitude, Double centerLatitude, Double radius, Integer level, String groupAlias, String geoCoordSys) {
|
||||
// 构建组织结构信息
|
||||
CameraGroup group = groupMapper.queryGroupByAlias(groupAlias);
|
||||
Assert.notNull(group, "获取组织结构失败");
|
||||
// 获取所有子节点
|
||||
List<CameraGroup> groupList = queryAllGroupChildren(group.getId(), group.getBusinessGroup());
|
||||
groupList.add(group);
|
||||
|
||||
// 参数坐标系列转换
|
||||
if (geoCoordSys != null) {
|
||||
if (geoCoordSys.equalsIgnoreCase("GCJ02")) {
|
||||
Double[] position = Coordtransform.WGS84ToGCJ02(centerLongitude, centerLatitude);
|
||||
centerLongitude = position[0];
|
||||
centerLatitude = position[1];
|
||||
|
||||
}else if (geoCoordSys.equalsIgnoreCase("BD09")) {
|
||||
Double[] gcj02Position = Coordtransform.WGS84ToGCJ02(centerLongitude, centerLatitude);
|
||||
Double[] position = Coordtransform.GCJ02ToBD09(gcj02Position[0], gcj02Position[1]);
|
||||
centerLongitude = position[0];
|
||||
centerLatitude = position[1];
|
||||
}
|
||||
}
|
||||
|
||||
List<CameraChannel> all = channelMapper.queryListInCircle(centerLongitude, centerLatitude, radius, level, groupList);
|
||||
return addIconPathAndPositionForCameraChannelList(all, geoCoordSys);
|
||||
}
|
||||
|
||||
public List<CameraChannel> queryListInPolygon(List<Point> pointList, String groupAlias, Integer level, String geoCoordSys) {
|
||||
// 构建组织结构信息
|
||||
CameraGroup group = groupMapper.queryGroupByAlias(groupAlias);
|
||||
Assert.notNull(group, "获取组织结构失败");
|
||||
// 获取所有子节点
|
||||
List<CameraGroup> groupList = queryAllGroupChildren(group.getId(), group.getBusinessGroup());
|
||||
groupList.add(group);
|
||||
|
||||
// 参数坐标系列转换
|
||||
if (geoCoordSys != null) {
|
||||
for (Point point : pointList) {
|
||||
if (geoCoordSys.equalsIgnoreCase("GCJ02")) {
|
||||
Double[] position = Coordtransform.WGS84ToGCJ02(point.getLng(), point.getLat());
|
||||
point.setLng(position[0]);
|
||||
point.setLat(position[1]);
|
||||
}else if (geoCoordSys.equalsIgnoreCase("BD09")) {
|
||||
Double[] gcj02Position = Coordtransform.WGS84ToGCJ02(point.getLng(), point.getLat());
|
||||
Double[] position = Coordtransform.GCJ02ToBD09(gcj02Position[0], gcj02Position[1]);
|
||||
point.setLng(position[0]);
|
||||
point.setLat(position[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<CameraChannel> all = channelMapper.queryListInPolygon(pointList, level, groupList);
|
||||
return addIconPathAndPositionForCameraChannelList(all, geoCoordSys);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user