From 039fbf7e243d4bf0f46b44e7dae2a5d36e978056 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期一, 20 三月 2023 14:32:53 +0800
Subject: [PATCH] Merge branch 'talk' into main-dev

---
 src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java |   36 +++++++++++++++++++++++++++++++++++-
 1 files changed, 35 insertions(+), 1 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java
index 45c5a90..808fc1c 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java
@@ -1,5 +1,6 @@
 package com.genersoft.iot.vmp.gb28181.utils;
 
+import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
 import com.genersoft.iot.vmp.gb28181.bean.RemoteAddressInfo;
 import com.genersoft.iot.vmp.utils.GitUtil;
 import gov.nist.javax.sip.address.AddressImpl;
@@ -122,7 +123,7 @@
     }
 
     public static String getNewCallId() {
-        return (int) Math.floor(Math.random() * 10000) + "";
+        return (int) Math.floor(Math.random() * 1000000000) + "";
     }
 
     public static int getTypeCodeFromGbCode(String deviceId) {
@@ -168,4 +169,37 @@
 
         return new RemoteAddressInfo(remoteAddress, remotePort);
     }
+
+    public static DeviceChannel updateGps(DeviceChannel deviceChannel, String geoCoordSys) {
+        if (deviceChannel.getLongitude()*deviceChannel.getLatitude() > 0) {
+
+            if (geoCoordSys == null) {
+                geoCoordSys = "WGS84";
+            }
+            if ("WGS84".equals(geoCoordSys)) {
+                deviceChannel.setLongitudeWgs84(deviceChannel.getLongitude());
+                deviceChannel.setLatitudeWgs84(deviceChannel.getLatitude());
+                Double[] position = Coordtransform.WGS84ToGCJ02(deviceChannel.getLongitude(), deviceChannel.getLatitude());
+                deviceChannel.setLongitudeGcj02(position[0]);
+                deviceChannel.setLatitudeGcj02(position[1]);
+            }else if ("GCJ02".equals(geoCoordSys)) {
+                deviceChannel.setLongitudeGcj02(deviceChannel.getLongitude());
+                deviceChannel.setLatitudeGcj02(deviceChannel.getLatitude());
+                Double[] position = Coordtransform.GCJ02ToWGS84(deviceChannel.getLongitude(), deviceChannel.getLatitude());
+                deviceChannel.setLongitudeWgs84(position[0]);
+                deviceChannel.setLatitudeWgs84(position[1]);
+            }else {
+                deviceChannel.setLongitudeGcj02(0.00);
+                deviceChannel.setLatitudeGcj02(0.00);
+                deviceChannel.setLongitudeWgs84(0.00);
+                deviceChannel.setLatitudeWgs84(0.00);
+            }
+        }else {
+            deviceChannel.setLongitudeGcj02(deviceChannel.getLongitude());
+            deviceChannel.setLatitudeGcj02(deviceChannel.getLatitude());
+            deviceChannel.setLongitudeWgs84(deviceChannel.getLongitude());
+            deviceChannel.setLatitudeWgs84(deviceChannel.getLatitude());
+        }
+        return deviceChannel;
+    }
 }

--
Gitblit v1.8.0