From 9dd4bfed9c4f955aba4a005d0a6b6ea1ba73d68f Mon Sep 17 00:00:00 2001 From: attiya <2413103649@qq.com> Date: Wed, 30 Apr 2025 10:49:35 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=8F=E7=BA=AC=E5=BA=A6=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2=E6=88=90GCJ-02?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/cdzy/orders/uitls/RedisUtil.java | 10 ++++------ .../com/cdzy/ebikereport/component/ReoprtHandler.java | 6 ++++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ebike-orders/src/main/java/com/cdzy/orders/uitls/RedisUtil.java b/ebike-orders/src/main/java/com/cdzy/orders/uitls/RedisUtil.java index 2f637dff..57acbdaf 100644 --- a/ebike-orders/src/main/java/com/cdzy/orders/uitls/RedisUtil.java +++ b/ebike-orders/src/main/java/com/cdzy/orders/uitls/RedisUtil.java @@ -1,14 +1,13 @@ package com.cdzy.orders.uitls; -import com.cdzy.common.utils.CoordinateUtil; import com.cdzy.orders.model.dto.res.RedisPoint; -import org.locationtech.jts.geom.*; import org.locationtech.jts.geom.Polygon; +import org.locationtech.jts.geom.*; import org.locationtech.jts.io.ParseException; import org.locationtech.jts.io.WKTReader; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.geo.*; import org.springframework.data.geo.Point; +import org.springframework.data.geo.*; import org.springframework.data.redis.connection.RedisGeoCommands; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Component; @@ -261,10 +260,9 @@ public class RedisUtil { */ public static boolean isPointInPolygon(double lng, double lat, Polygon polygon) { // 1. 高精度坐标转换 - double[] doubles = CoordinateUtil.WGS84ToGCJ02(lng, lat); Coordinate coord = new Coordinate( - BigDecimal.valueOf(doubles[0]).setScale(9, RoundingMode.HALF_UP).doubleValue(), - BigDecimal.valueOf(doubles[1]).setScale(9, RoundingMode.HALF_UP).doubleValue() + BigDecimal.valueOf(lng).setScale(9, RoundingMode.HALF_UP).doubleValue(), + BigDecimal.valueOf(lat).setScale(9, RoundingMode.HALF_UP).doubleValue() ); // 2. 创建几何对象(确认使用双精度) diff --git a/ebike-report/src/main/java/com/cdzy/ebikereport/component/ReoprtHandler.java b/ebike-report/src/main/java/com/cdzy/ebikereport/component/ReoprtHandler.java index f86b0646..101b52b6 100644 --- a/ebike-report/src/main/java/com/cdzy/ebikereport/component/ReoprtHandler.java +++ b/ebike-report/src/main/java/com/cdzy/ebikereport/component/ReoprtHandler.java @@ -3,6 +3,7 @@ package com.cdzy.ebikereport.component; import com.alibaba.fastjson2.JSONObject; import com.cdzy.common.model.EbikeTracking; import com.cdzy.common.model.ResGPSDto; +import com.cdzy.common.utils.CoordinateUtil; import com.cdzy.ebikereport.enums.BitSwitch; import com.cdzy.ebikereport.utils.BinaryUtil; import com.cdzy.ebikereport.utils.RedisUtil; @@ -64,8 +65,9 @@ public class ReoprtHandler { resGpsDto.setIsWheelSpin(isWheelSpin); resGpsDto.setIsMoving(isMoving); redisUtil.set(deviceId, resGpsDto); - redisUtil.addLocation(new Point(resGpsDto.getLongitude(), resGpsDto.getLatitude()),deviceId); - EbikeTracking ebikeTracking = new EbikeTracking(deviceId,resGpsDto.getLatitude(),resGpsDto.getLongitude()); + double[] doubles = CoordinateUtil.WGS84ToGCJ02(resGpsDto.getLongitude(), resGpsDto.getLatitude()); + redisUtil.addLocation(new Point(doubles[0], doubles[1]),deviceId); + EbikeTracking ebikeTracking = new EbikeTracking(deviceId,doubles[1], doubles[0]); operateFeignClient.saveEbikeTracking(ebikeTracking); }