From da1432df263aa1aa4390f54b2635bb70e7f5207b Mon Sep 17 00:00:00 2001
From: ‘liusuyi’ <1951119284@qq.com>
Date: 星期二, 22 八月 2023 11:24:16 +0800
Subject: [PATCH] 优化实体
---
ard-work/src/main/java/com/ruoyi/utils/tools/Point.java | 9 +++++++++
ard-work/src/main/java/com/ruoyi/utils/tools/GisTool.java | 18 +++++++++---------
ard-work/src/main/java/com/ruoyi/app/position/service/impl/ArdAppPositionServiceImpl.java | 4 +---
ard-work/src/main/java/com/ruoyi/device/camera/service/impl/ArdCamerasServiceImpl.java | 4 +---
ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarServiceImpl.java | 4 +---
5 files changed, 21 insertions(+), 18 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/app/position/service/impl/ArdAppPositionServiceImpl.java b/ard-work/src/main/java/com/ruoyi/app/position/service/impl/ArdAppPositionServiceImpl.java
index 3a88178..a9d10ef 100644
--- a/ard-work/src/main/java/com/ruoyi/app/position/service/impl/ArdAppPositionServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/app/position/service/impl/ArdAppPositionServiceImpl.java
@@ -202,9 +202,7 @@
if (lon == null || lat == null) {
continue;
}
- Point point2D=new Point();
- point2D.setLongitude(lon);
- point2D.setLatitude(lat);
+ Point point2D=new Point(lon,lat);
boolean inPolygon = GisTool.isInPolygon(point2D, partitionLocation);
if (inPolygon) {
Map<String, Object> params = new HashMap<>();
diff --git a/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/ArdCamerasServiceImpl.java b/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/ArdCamerasServiceImpl.java
index 6e25a85..fd602a2 100644
--- a/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/ArdCamerasServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/device/camera/service/impl/ArdCamerasServiceImpl.java
@@ -375,9 +375,7 @@
continue;
}
/*鍒ゆ柇鍧愭爣鏄惁鍦ㄥ杈瑰舰鑼冨洿鍐�*/
- Point camPosition=new Point();
- camPosition.setLongitude(camera.getLongitude());
- camPosition.setLatitude(camera.getLatitude());
+ Point camPosition=new Point(camera.getLongitude(),camera.getLatitude());
boolean inPolygon = GisTool.isInPolygon(camPosition, partitionLocation);
if (inPolygon) {
/*鑾峰彇閫氶亾鍒楄〃*/
diff --git a/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarServiceImpl.java b/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarServiceImpl.java
index 4cf89fa..51d7958 100644
--- a/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/sy/service/impl/ArdSyCarServiceImpl.java
@@ -1143,9 +1143,7 @@
List<Map<String, Object>> carGPSMap = (List<Map<String, Object>>) carGPSTrack.get("list");
Double lng = Double.valueOf((String) carGPSMap.get(0).get("lng"));
Double lat = Double.valueOf((String) carGPSMap.get(0).get("lat"));
- Point point = new Point();
- point.setLongitude(lng);
- point.setLatitude(lat);
+ Point point = new Point(lng,lat);
boolean inPolygon = GisTool.isInPolygon(point, partitionLocation);
if (inPolygon) {
carMap.put("longitude", lng);
diff --git a/ard-work/src/main/java/com/ruoyi/utils/tools/GisTool.java b/ard-work/src/main/java/com/ruoyi/utils/tools/GisTool.java
index 48c156f..4682ff7 100644
--- a/ard-work/src/main/java/com/ruoyi/utils/tools/GisTool.java
+++ b/ard-work/src/main/java/com/ruoyi/utils/tools/GisTool.java
@@ -35,15 +35,15 @@
}
public static void main(String[] args) {
-// // 琚娴嬬殑缁忕含搴︾偣
-// Point point= new Point(126.649261,45.687377);
-// // 鍟嗕笟鍖哄煙锛堢櫨搴﹀杈瑰舰鍖哄煙缁忕含搴﹂泦鍚堬級
-// List<Point> partitionLocation = new ArrayList<>();
-// partitionLocation.add(new Point(126.64459,45.688548));
-// partitionLocation.add(new Point(126.653376,45.68938));
-// partitionLocation.add(new Point(126.645776,45.685048));
-// partitionLocation.add(new Point(126.654184,45.685778));
-// System.out.println(isInPolygon(point,partitionLocation));
+ // 琚娴嬬殑缁忕含搴︾偣
+ Point point= new Point(126.649261,45.687377);
+ // 鍟嗕笟鍖哄煙锛堢櫨搴﹀杈瑰舰鍖哄煙缁忕含搴﹂泦鍚堬級
+ List<Point> partitionLocation = new ArrayList<>();
+ partitionLocation.add(new Point(126.64459,45.688548));
+ partitionLocation.add(new Point(126.653376,45.68938));
+ partitionLocation.add(new Point(126.645776,45.685048));
+ partitionLocation.add(new Point(126.654184,45.685778));
+ System.out.println(isInPolygon(point,partitionLocation));
}
/**
diff --git a/ard-work/src/main/java/com/ruoyi/utils/tools/Point.java b/ard-work/src/main/java/com/ruoyi/utils/tools/Point.java
index eb1daf8..67f6b4a 100644
--- a/ard-work/src/main/java/com/ruoyi/utils/tools/Point.java
+++ b/ard-work/src/main/java/com/ruoyi/utils/tools/Point.java
@@ -1,7 +1,10 @@
package com.ruoyi.utils.tools;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
+import lombok.NoArgsConstructor;
/**
* @Description:
@@ -11,8 +14,14 @@
* @Version: 1.0
**/
@Data
+@NoArgsConstructor
public class Point{
private static final long serialVersionUID = 1L;
private Double longitude;
private Double latitude;
+ @JsonCreator
+ public Point(@JsonProperty("x") Double x, @JsonProperty("y") Double y) {
+ this.longitude = x;
+ this.latitude = y;
+ }
}
--
Gitblit v1.9.3