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); }