From 686c587744cf0933b4022a1b741f8f50658e2632 Mon Sep 17 00:00:00 2001
From: zhangnaisong <2434969829@qq.com>
Date: 星期日, 28 四月 2024 15:40:19 +0800
Subject: [PATCH] 视频标签提交

---
 ard-work/src/main/java/com/ruoyi/alarmpoints/well/service/impl/ArdAlarmpointsWellServiceImpl.java |  169 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 169 insertions(+), 0 deletions(-)

diff --git a/ard-work/src/main/java/com/ruoyi/alarmpoints/well/service/impl/ArdAlarmpointsWellServiceImpl.java b/ard-work/src/main/java/com/ruoyi/alarmpoints/well/service/impl/ArdAlarmpointsWellServiceImpl.java
index b6a07eb..0a60235 100644
--- a/ard-work/src/main/java/com/ruoyi/alarmpoints/well/service/impl/ArdAlarmpointsWellServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/alarmpoints/well/service/impl/ArdAlarmpointsWellServiceImpl.java
@@ -1,5 +1,6 @@
 package com.ruoyi.alarmpoints.well.service.impl;
 
+import java.awt.geom.Point2D;
 import java.math.BigDecimal;
 import java.sql.*;
 import java.util.ArrayList;
@@ -25,9 +26,12 @@
 import com.ruoyi.common.utils.bean.BeanValidators;
 import com.ruoyi.common.utils.spring.SpringUtils;
 import com.ruoyi.common.utils.uuid.IdUtils;
+import com.ruoyi.device.camera.domain.ArdCameras;
+import com.ruoyi.device.camera.mapper.ArdCamerasMapper;
 import com.ruoyi.system.mapper.SysDeptMapper;
 import com.ruoyi.utils.data.Query;
 import com.ruoyi.utils.gis.GisUtil;
+import com.ruoyi.utils.gps.GeoTools;
 import lombok.ToString;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -51,6 +55,8 @@
     private ArdAlarmpointsWellMapper ardAlarmpointsWellMapper;
     @Resource
     private ArdWellGuideCameraMapper ardWellGuideCameraMapper;
+    @Resource
+    private ArdCamerasMapper ardCamerasMapper;
 
     @Autowired
     protected Validator validator;
@@ -837,6 +843,169 @@
         return result;
     }
 
+    @Override
+    public List<Map<String, Object>> getCameraVideoLable(Long deptId, String cameraId, Double p, Double t, Double fHorFieldAngle, Double fVerFieldAngle) {
+        ArdCameras ardCameras = ardCamerasMapper.selectArdCamerasById(cameraId);
+        //灏忎笁瑙掑舰鑵�
+        Double xy = Math.tan(Math.PI/2 - (Math.PI * 2 - Math.PI * t/180) - Math.PI * fVerFieldAngle/180/2)*ardCameras.getAltitude()/Math.cos(Math.PI * fHorFieldAngle/180/2);
+        //澶т笁瑙掑舰鑵�
+        Double dy = Math.tan(Math.PI/2 - (Math.PI * 2 - Math.PI * t/180) + Math.PI * fVerFieldAngle/180/2)*ardCameras.getAltitude()/Math.cos(Math.PI * fHorFieldAngle/180/2);
+
+        if(dy < 0){
+            dy = -1 * dy;
+        }
+
+        if(xy < 0){
+            xy = -1 * xy;
+        }
+
+        Double lonA = ardCameras.getLongitude() + xy * Math.sin((p + fHorFieldAngle/2)* Math.PI / 180) * 180 / ( Math.PI * 6371229 * Math.cos(ardCameras.getLatitude() * Math.PI / 180));
+        Double latA = ardCameras.getLatitude() + xy * Math.cos((p + fHorFieldAngle/2)* Math.PI / 180) / ( Math.PI * 6371229 / 180);
+
+        System.out.println("A鐐圭粡搴�:" + lonA);
+        System.out.println("A鐐圭含搴�:" + latA);
+
+        Double lonB = ardCameras.getLongitude() + xy * Math.sin((p - fHorFieldAngle/2)* Math.PI / 180) * 180 / ( Math.PI * 6371229 * Math.cos(ardCameras.getLatitude() * Math.PI / 180));
+        Double latB = ardCameras.getLatitude() + xy * Math.cos((p - fHorFieldAngle/2)* Math.PI / 180) / ( Math.PI * 6371229 / 180);
+
+        System.out.println("B鐐圭粡搴�:" + lonB);
+        System.out.println("B鐐圭含搴�:" + latB);
+
+        Double lonC = ardCameras.getLongitude() + dy * Math.sin((p + fHorFieldAngle/2)* Math.PI / 180) * 180 / ( Math.PI * 6371229 * Math.cos(ardCameras.getLatitude() * Math.PI / 180));
+        Double latC = ardCameras.getLatitude() + dy * Math.cos((p + fHorFieldAngle/2)* Math.PI / 180) / ( Math.PI * 6371229 / 180);
+
+        System.out.println("C鐐圭粡搴�:" + lonC);
+        System.out.println("C鐐圭含搴�:" + latC);
+
+        Double lonD = ardCameras.getLongitude() + dy * Math.sin((p - fHorFieldAngle/2)* Math.PI / 180) * 180 / ( Math.PI * 6371229 * Math.cos(ardCameras.getLatitude() * Math.PI / 180));
+        Double latD = ardCameras.getLatitude() + dy * Math.cos((p - fHorFieldAngle/2)* Math.PI / 180) / ( Math.PI * 6371229 / 180);
+
+        System.out.println("D鐐圭粡搴�:" + lonD);
+        System.out.println("D鐐圭含搴�:" + latD);
+
+        Double dg = Math.tan(Math.PI/2 - (Math.PI * 2 - Math.PI * t/180) - Math.PI * fVerFieldAngle/180/2)*ardCameras.getAltitude();//澶т笁瑙掑舰楂�
+        Double xg = Math.tan(Math.PI/2 - (Math.PI * 2 - Math.PI * t/180) + Math.PI * fVerFieldAngle/180/2)*ardCameras.getAltitude();//灏忎笁瑙掑舰楂�
+
+        if(dg < 0){
+            dg = -1 * dg;
+        }
+
+        if(xg < 0){
+            xg = -1 * xg;
+        }
+
+        Double mg = xg + 0.5 * (dg - xg);
+
+        Double lonM = ardCameras.getLongitude() + mg * Math.sin(p * Math.PI / 180) * 180 / ( Math.PI * 6371229 * Math.cos(ardCameras.getLatitude() * Math.PI / 180));
+        Double latM = ardCameras.getLatitude() + mg * Math.cos(p * Math.PI / 180) / ( Math.PI * 6371229 / 180);
+        System.out.println("涓偣缁忓害:" + lonM);
+        System.out.println("涓偣绾害:" + latM);
+        //鏍规嵁閮ㄩ棬鍙婂厜杞村湴闈㈡姇褰辩瓑鑵版褰腑鐐硅幏鍙栧叴瓒g偣
+        List<ArdAlarmpointsWell> ardAlarmpointsWellResult = ardAlarmpointsWellMapper.getArdAlarmpointsWellByDeptIdAndDistance(deptId, lonM, latM, lonA, latA, lonB, latB, lonC, latC, lonD, latD);
+
+        //璁剧疆澶氳竟褰�
+        List<Point2D.Double> pts = new ArrayList<Point2D.Double>();
+        pts.add(new Point2D.Double(lonA, latA));
+        pts.add(new Point2D.Double(lonB, latB));
+        pts.add(new Point2D.Double(lonD, latD));
+        pts.add(new Point2D.Double(lonC, latC));
+
+        List<ArdAlarmpointsWell> innerList = new ArrayList();//鏌ユ壘澶氳竟褰㈠唴鍏磋叮鐐�
+        for(ArdAlarmpointsWell ardAlarmpointsWell : ardAlarmpointsWellResult){
+            Point2D.Double point = new Point2D.Double(ardAlarmpointsWell.getLongitude(), ardAlarmpointsWell.getLatitude());
+            if(GeoTools.IsPtInPoly(point, pts)){
+                innerList.add(ardAlarmpointsWell);
+            }
+        }
+
+        List<Map<String,Object>> result = new ArrayList();
+        for(ArdAlarmpointsWell ardAlarmpointsWell : innerList){
+            Map<String,Object> map = new HashMap();
+            double distance_Target = RealDistance(ardCameras.getLongitude(),ardCameras.getLongitude(),ardAlarmpointsWell.getLongitude(), ardAlarmpointsWell.getLatitude());
+
+            double Angle_A = GetAngle(ardCameras.getLongitude(),ardCameras.getLongitude(),ardAlarmpointsWell.getLongitude(), ardAlarmpointsWell.getLatitude());
+            double Angle_E = Math.atan((ardCameras.getAltitude() - 0) / distance_Target) * 180 / Math.PI;
+
+            Angle_A = Angle_A - (p - fHorFieldAngle/2);//瑙嗗満瑙掑唴鏂逛綅
+
+            Angle_E = Angle_E - (360 - t - fVerFieldAngle/2);//瑙嗗満瑙掑唴淇话
+
+            map.put("id",ardAlarmpointsWell.getId());
+            map.put("wellId",ardAlarmpointsWell.getWellId());
+            map.put("horFieldProportion",Angle_A/fHorFieldAngle);//妯悜鍗犳瘮
+            map.put("verFieldProportion",Angle_E/fVerFieldAngle);//绾靛悜鍗犳瘮
+            result.add(map);
+        }
+        return result;
+    }
+
+    public static double RealDistance(double base_pos_longitude,double base_pos_latitude,double tar_pos_longitude,double tar_pos_latitude){
+        double er;
+        double f;
+        double g;
+        double l;
+        double sg;
+        double sl;
+        double sf;
+        double s;
+        double c;
+        double w;
+        double r;
+        double d;
+        double h1;
+        double h2;
+        double fl;
+
+        er = 6378.137;
+        fl = 1 / 298.257;
+        f = (base_pos_latitude + tar_pos_latitude)*Math.PI/360;
+        g = (base_pos_latitude - tar_pos_latitude)*Math.PI/360;
+        l = (base_pos_longitude - tar_pos_longitude)*Math.PI/360;
+
+        sg = Math.sin(g);
+        sl = Math.sin(l);
+        sf = Math.sin(f);
+
+        sg = Math.pow(sg,2);
+        sl = Math.pow(sl,2);
+        sf = Math.pow(sf,2);
+
+        s = sg * (1 - sl) + (1 - sf) * sl;
+        c = (1 - sg) * (1 - sl) + sf * sl;
+
+        w = Math.atan(Math.sqrt(s / c));
+        r = Math.sqrt(s * c) / w;
+        d = 2 * w * er;
+        h1 = (3 * r - 1) / 2 / c;
+        h2 = (3 * r + 1) / 2 / s;
+
+        return 1000*d * (1 + fl * (h1 * sf * (1 - sg) - h2 * (1 - sf) * sg));//84
+    }
+
+    public static double GetAngle(double base_pos_longitude,double base_pos_latitude,double tar_pos_longitude,double tar_pos_latitude){
+        double lat1 = base_pos_latitude * Math.PI / 180;
+        double lon1 = base_pos_longitude * Math.PI / 180;
+        double lat2 = tar_pos_latitude * Math.PI / 180;
+        double lon2 = tar_pos_longitude * Math.PI / 180;
+        double d = Math.sin(lat2)*Math.sin(lat1) + Math.cos(lat2)*Math.cos(lat1)*Math.cos(lon2 - lon1);
+        if (d != 1){
+            d = Math.asin(Math.cos(lat2) * Math.sin(lon2 - lon1) / Math.sqrt(1 - d * d));
+            d = d * 180 / Math.PI;
+        }
+        else {
+            d = 0;
+        }
+        if (lat1>lat2) {
+            d = 180 - d;
+        }
+        else {
+            if (lon1>lon2) {
+                d = 360 + d;
+            }
+        }
+        return d;
+    }
+
     public int checkTable(String url, String username, String password, String tableName) throws ClassNotFoundException, SQLException {
         Connection connection = null;
 

--
Gitblit v1.9.3